Skip to content

Commit

Permalink
Remove some synchrony driver support code
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Aug 12, 2022
1 parent 71c2deb commit 5c44568
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 77 deletions.
12 changes: 6 additions & 6 deletions test/cluster/commands_on_pub_sub_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_publish_subscribe_unsubscribe_pubsub
sub_cnt = 0
messages = {}

wire = Wire.new do
thread = Thread.new do
redis.subscribe('channel1', 'channel2') do |on|
on.subscribe { |_c, t| sub_cnt = t }
on.unsubscribe { |_c, t| sub_cnt = t }
Expand All @@ -23,7 +23,7 @@ def test_publish_subscribe_unsubscribe_pubsub
end
end

Wire.pass until sub_cnt == 2
Thread.pass until sub_cnt == 2

publisher = build_another_client

Expand All @@ -38,7 +38,7 @@ def test_publish_subscribe_unsubscribe_pubsub
publisher.publish('channel1', 'one')
publisher.publish('channel2', 'two')

wire.join
thread.join

assert_equal({ 'channel1' => 'one', 'channel2' => 'two' }, messages.sort.to_h)

Expand All @@ -55,7 +55,7 @@ def test_publish_psubscribe_punsubscribe_pubsub
sub_cnt = 0
messages = {}

wire = Wire.new do
thread = Thread.new do
redis.psubscribe('guc*', 'her*') do |on|
on.psubscribe { |_c, t| sub_cnt = t }
on.punsubscribe { |_c, t| sub_cnt = t }
Expand All @@ -67,7 +67,7 @@ def test_publish_psubscribe_punsubscribe_pubsub
end
end

Wire.pass until sub_cnt == 2
Thread.pass until sub_cnt == 2

publisher = build_another_client

Expand All @@ -83,7 +83,7 @@ def test_publish_psubscribe_punsubscribe_pubsub
publisher.publish('gucci2', 'two')
publisher.publish('hermes3', 'three')

wire.join
thread.join

assert_equal({ 'gucci2' => 'two', 'hermes3' => 'three' }, messages.sort.to_h)

Expand Down
10 changes: 5 additions & 5 deletions test/distributed/publish_subscribe_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_subscribe_and_unsubscribe_with_tags
@subscribed = false
@unsubscribed = false

wire = Wire.new do
thread = Thread.new do
r.subscribe("foo") do |on|
on.subscribe do |_channel, total|
@subscribed = true
Expand All @@ -41,11 +41,11 @@ def test_subscribe_and_unsubscribe_with_tags
end

# Wait until the subscription is active before publishing
Wire.pass until @subscribed
Thread.pass until @subscribed

Redis::Distributed.new(NODES).publish("foo", "s1")

wire.join
thread.join

assert @subscribed
assert_equal 1, @t1
Expand All @@ -57,7 +57,7 @@ def test_subscribe_and_unsubscribe_with_tags
def test_subscribe_within_subscribe
@channels = []

wire = Wire.new do
thread = Thread.new do
r.subscribe("foo") do |on|
on.subscribe do |channel, _total|
@channels << channel
Expand All @@ -68,7 +68,7 @@ def test_subscribe_within_subscribe
end
end

wire.join
thread.join

assert_equal ["foo", "bar"], @channels
end
Expand Down
1 change: 0 additions & 1 deletion test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
require "redis/connection/#{ENV['DRIVER']}"

require_relative "support/redis_mock"
require_relative "support/connection/#{ENV['DRIVER']}"
require_relative 'support/cluster/orchestrator'

PORT = 6381
Expand Down
6 changes: 3 additions & 3 deletions test/lint/streams.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,13 @@ def test_xread_with_block_option
def test_xread_does_not_raise_timeout_error_when_the_block_option_is_zero_msec
prepared = false
actual = nil
wire = Wire.new do
thread = Thread.new do
prepared = true
actual = redis.xread('s1', 0, block: 0)
end
Wire.pass until prepared
Thread.pass until prepared
redis.dup.xadd('s1', { f: 'v1' }, id: '0-1')
wire.join
thread.join

assert_equal(['v1'], actual.fetch('s1').map { |i| i.last['f'] })
end
Expand Down
40 changes: 20 additions & 20 deletions test/redis/publish_subscribe_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_subscribe_and_unsubscribe
@subscribed = false
@unsubscribed = false

wire = Wire.new do
thread = Thread.new do
r.subscribe("foo") do |on|
on.subscribe do |_channel, total|
@subscribed = true
Expand All @@ -34,11 +34,11 @@ def test_subscribe_and_unsubscribe
end

# Wait until the subscription is active before publishing
Wire.pass until @subscribed
Thread.pass until @subscribed

Redis.new(OPTIONS).publish("foo", "s1")

wire.join
thread.join

assert @subscribed
assert_equal 1, @t1
Expand All @@ -51,7 +51,7 @@ def test_psubscribe_and_punsubscribe
@subscribed = false
@unsubscribed = false

wire = Wire.new do
thread = Thread.new do
r.psubscribe("f*") do |on|
on.psubscribe do |_pattern, total|
@subscribed = true
Expand All @@ -73,11 +73,11 @@ def test_psubscribe_and_punsubscribe
end

# Wait until the subscription is active before publishing
Wire.pass until @subscribed
Thread.pass until @subscribed

Redis.new(OPTIONS).publish("foo", "s1")

wire.join
thread.join

assert @subscribed
assert_equal 1, @t1
Expand All @@ -88,39 +88,39 @@ def test_psubscribe_and_punsubscribe

def test_pubsub_with_numpat_subcommand
@subscribed = false
wire = Wire.new do
thread = Thread.new do
r.psubscribe("f*") do |on|
on.psubscribe { |_channel, _total| @subscribed = true }
on.pmessage { |_pattern, _channel, _message| r.punsubscribe }
end
end
Wire.pass until @subscribed
Thread.pass until @subscribed
redis = Redis.new(OPTIONS)
numpat_result = redis.pubsub(:numpat)

redis.publish("foo", "s1")
wire.join
thread.join

assert_equal redis.pubsub(:numpat), 0
assert_equal numpat_result, 1
end

def test_pubsub_with_channels_and_numsub_subcommnads
@subscribed = false
wire = Wire.new do
thread = Thread.new do
r.subscribe("foo") do |on|
on.subscribe { |_channel, _total| @subscribed = true }
on.message { |_channel, _message| r.unsubscribe }
end
end
Wire.pass until @subscribed
Thread.pass until @subscribed
redis = Redis.new(OPTIONS)
channels_result = redis.pubsub(:channels)
channels_result.delete('__sentinel__:hello')
numsub_result = redis.pubsub(:numsub, 'foo', 'boo')

redis.publish("foo", "s1")
wire.join
thread.join

assert_equal channels_result, ['foo']
assert_equal numsub_result, ['foo', 1, 'boo', 0]
Expand All @@ -129,7 +129,7 @@ def test_pubsub_with_channels_and_numsub_subcommnads
def test_subscribe_connection_usable_after_raise
@subscribed = false

wire = Wire.new do
thread = Thread.new do
r.subscribe("foo") do |on|
on.subscribe do |_channel, _total|
@subscribed = true
Expand All @@ -143,19 +143,19 @@ def test_subscribe_connection_usable_after_raise
end

# Wait until the subscription is active before publishing
Wire.pass until @subscribed
Thread.pass until @subscribed

Redis.new(OPTIONS).publish("foo", "s1")

wire.join
thread.join

assert_equal "PONG", r.ping
end

def test_psubscribe_connection_usable_after_raise
@subscribed = false

wire = Wire.new do
thread = Thread.new do
r.psubscribe("f*") do |on|
on.psubscribe do |_pattern, _total|
@subscribed = true
Expand All @@ -169,19 +169,19 @@ def test_psubscribe_connection_usable_after_raise
end

# Wait until the subscription is active before publishing
Wire.pass until @subscribed
Thread.pass until @subscribed

Redis.new(OPTIONS).publish("foo", "s1")

wire.join
thread.join

assert_equal "PONG", r.ping
end

def test_subscribe_within_subscribe
@channels = []

wire = Wire.new do
thread = Thread.new do
r.subscribe("foo") do |on|
on.subscribe do |channel, _total|
@channels << channel
Expand All @@ -192,7 +192,7 @@ def test_subscribe_within_subscribe
end
end

wire.join
thread.join

assert_equal ["foo", "bar"], @channels
end
Expand Down
6 changes: 3 additions & 3 deletions test/redis/remote_server_control_commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ def test_info_commandstats
def test_monitor_redis
log = []

wire = Wire.new do
thread = Thread.new do
Redis.new(OPTIONS).monitor do |line|
log << line
break if line =~ /set/
end
end

Wire.pass while log.empty? # Faster than sleep
Thread.pass while log.empty? # Faster than sleep

r.set "foo", "s1"

wire.join
thread.join

assert log[-1] =~ /\b15\b.* "set" "foo" "s1"/
end
Expand Down
3 changes: 0 additions & 3 deletions test/support/connection/hiredis.rb

This file was deleted.

3 changes: 0 additions & 3 deletions test/support/connection/ruby.rb

This file was deleted.

26 changes: 0 additions & 26 deletions test/support/wire/synchrony.rb

This file was deleted.

7 changes: 0 additions & 7 deletions test/support/wire/thread.rb

This file was deleted.

0 comments on commit 5c44568

Please sign in to comment.