File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ def test_pipelined_with_many_commands
168168 results . each_with_index { |got , i | assert_equal ( i . to_s , got ) }
169169 end
170170
171- def test_pubsub
171+ def test_global_pubsub
172172 10 . times do |i |
173173 pubsub = @client . pubsub
174174 pubsub . call ( 'SUBSCRIBE' , "channel#{ i } " )
@@ -189,6 +189,28 @@ def test_pubsub
189189 assert_equal ( [ 'message' , channel , 'hello world' ] , sub . resume )
190190 end
191191
192+ def test_sharded_pubsub
193+ if TEST_REDIS_MAJOR_VERSION < 7
194+ skip ( 'Sharded Pub/Sub is supported by Redis 7+.' )
195+ return
196+ end
197+
198+ 10 . times do |i |
199+ sub = Fiber . new do |client |
200+ channel = "my-channel-#{ i } "
201+ pubsub = client . pubsub
202+ pubsub . call ( 'SSUBSCRIBE' , channel )
203+ assert_equal ( [ 'ssubscribe' , channel , 1 ] , pubsub . next_event ( TEST_TIMEOUT_SEC ) )
204+ Fiber . yield ( channel )
205+ Fiber . yield ( pubsub . next_event ( TEST_TIMEOUT_SEC ) )
206+ end
207+
208+ channel = sub . resume ( @client )
209+ @client . call ( 'SPUBLISH' , channel , "hello world #{ i } " )
210+ assert_equal ( [ 'smessage' , channel , "hello world #{ i } " ] , sub . resume )
211+ end
212+ end
213+
192214 def test_close
193215 assert_nil ( @client . close )
194216 end
You can’t perform that action at this time.
0 commit comments