@@ -357,13 +357,17 @@ var _ = Describe("Redis Ring", func() {
357357 ring .AddHook (& hook {
358358 processPipelineHook : func (hook redis.ProcessPipelineHook ) redis.ProcessPipelineHook {
359359 return func (ctx context.Context , cmds []redis.Cmder ) error {
360- Expect (cmds ).To (HaveLen (1 ))
360+ // skip the connection initialization
361+ if cmds [0 ].Name () == "hello" || cmds [0 ].Name () == "client" {
362+ return nil
363+ }
364+ Expect (len (cmds )).To (BeNumerically (">" , 0 ))
361365 Expect (cmds [0 ].String ()).To (Equal ("ping: " ))
362366 stack = append (stack , "ring.BeforeProcessPipeline" )
363367
364368 err := hook (ctx , cmds )
365369
366- Expect (cmds ).To (HaveLen ( 1 ))
370+ Expect (len ( cmds )) .To (BeNumerically ( ">" , 0 ))
367371 Expect (cmds [0 ].String ()).To (Equal ("ping: PONG" ))
368372 stack = append (stack , "ring.AfterProcessPipeline" )
369373
@@ -376,13 +380,17 @@ var _ = Describe("Redis Ring", func() {
376380 shard .AddHook (& hook {
377381 processPipelineHook : func (hook redis.ProcessPipelineHook ) redis.ProcessPipelineHook {
378382 return func (ctx context.Context , cmds []redis.Cmder ) error {
379- Expect (cmds ).To (HaveLen (1 ))
383+ // skip the connection initialization
384+ if cmds [0 ].Name () == "hello" || cmds [0 ].Name () == "client" {
385+ return nil
386+ }
387+ Expect (len (cmds )).To (BeNumerically (">" , 0 ))
380388 Expect (cmds [0 ].String ()).To (Equal ("ping: " ))
381389 stack = append (stack , "shard.BeforeProcessPipeline" )
382390
383391 err := hook (ctx , cmds )
384392
385- Expect (cmds ).To (HaveLen ( 1 ))
393+ Expect (len ( cmds )) .To (BeNumerically ( ">" , 0 ))
386394 Expect (cmds [0 ].String ()).To (Equal ("ping: PONG" ))
387395 stack = append (stack , "shard.AfterProcessPipeline" )
388396
@@ -416,14 +424,18 @@ var _ = Describe("Redis Ring", func() {
416424 processPipelineHook : func (hook redis.ProcessPipelineHook ) redis.ProcessPipelineHook {
417425 return func (ctx context.Context , cmds []redis.Cmder ) error {
418426 defer GinkgoRecover ()
427+ // skip the connection initialization
428+ if cmds [0 ].Name () == "hello" || cmds [0 ].Name () == "client" {
429+ return nil
430+ }
419431
420- Expect (cmds ).To (HaveLen ( 3 ))
432+ Expect (len ( cmds )) .To (BeNumerically ( ">=" , 3 ))
421433 Expect (cmds [1 ].String ()).To (Equal ("ping: " ))
422434 stack = append (stack , "ring.BeforeProcessPipeline" )
423435
424436 err := hook (ctx , cmds )
425437
426- Expect (cmds ).To (HaveLen ( 3 ))
438+ Expect (len ( cmds )) .To (BeNumerically ( ">=" , 3 ))
427439 Expect (cmds [1 ].String ()).To (Equal ("ping: PONG" ))
428440 stack = append (stack , "ring.AfterProcessPipeline" )
429441
@@ -437,14 +449,18 @@ var _ = Describe("Redis Ring", func() {
437449 processPipelineHook : func (hook redis.ProcessPipelineHook ) redis.ProcessPipelineHook {
438450 return func (ctx context.Context , cmds []redis.Cmder ) error {
439451 defer GinkgoRecover ()
452+ // skip the connection initialization
453+ if cmds [0 ].Name () == "hello" || cmds [0 ].Name () == "client" {
454+ return nil
455+ }
440456
441- Expect (cmds ).To (HaveLen ( 3 ))
457+ Expect (len ( cmds )) .To (BeNumerically ( ">=" , 3 ))
442458 Expect (cmds [1 ].String ()).To (Equal ("ping: " ))
443459 stack = append (stack , "shard.BeforeProcessPipeline" )
444460
445461 err := hook (ctx , cmds )
446462
447- Expect (cmds ).To (HaveLen ( 3 ))
463+ Expect (len ( cmds )) .To (BeNumerically ( ">=" , 3 ))
448464 Expect (cmds [1 ].String ()).To (Equal ("ping: PONG" ))
449465 stack = append (stack , "shard.AfterProcessPipeline" )
450466
0 commit comments