@@ -357,13 +357,17 @@ var _ = Describe("Redis Ring", func() {
357
357
ring .AddHook (& hook {
358
358
processPipelineHook : func (hook redis.ProcessPipelineHook ) redis.ProcessPipelineHook {
359
359
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 ))
361
365
Expect (cmds [0 ].String ()).To (Equal ("ping: " ))
362
366
stack = append (stack , "ring.BeforeProcessPipeline" )
363
367
364
368
err := hook (ctx , cmds )
365
369
366
- Expect (cmds ).To (HaveLen ( 1 ))
370
+ Expect (len ( cmds )) .To (BeNumerically ( ">" , 0 ))
367
371
Expect (cmds [0 ].String ()).To (Equal ("ping: PONG" ))
368
372
stack = append (stack , "ring.AfterProcessPipeline" )
369
373
@@ -376,13 +380,17 @@ var _ = Describe("Redis Ring", func() {
376
380
shard .AddHook (& hook {
377
381
processPipelineHook : func (hook redis.ProcessPipelineHook ) redis.ProcessPipelineHook {
378
382
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 ))
380
388
Expect (cmds [0 ].String ()).To (Equal ("ping: " ))
381
389
stack = append (stack , "shard.BeforeProcessPipeline" )
382
390
383
391
err := hook (ctx , cmds )
384
392
385
- Expect (cmds ).To (HaveLen ( 1 ))
393
+ Expect (len ( cmds )) .To (BeNumerically ( ">" , 0 ))
386
394
Expect (cmds [0 ].String ()).To (Equal ("ping: PONG" ))
387
395
stack = append (stack , "shard.AfterProcessPipeline" )
388
396
@@ -416,14 +424,18 @@ var _ = Describe("Redis Ring", func() {
416
424
processPipelineHook : func (hook redis.ProcessPipelineHook ) redis.ProcessPipelineHook {
417
425
return func (ctx context.Context , cmds []redis.Cmder ) error {
418
426
defer GinkgoRecover ()
427
+ // skip the connection initialization
428
+ if cmds [0 ].Name () == "hello" || cmds [0 ].Name () == "client" {
429
+ return nil
430
+ }
419
431
420
- Expect (cmds ).To (HaveLen ( 3 ))
432
+ Expect (len ( cmds )) .To (BeNumerically ( ">=" , 3 ))
421
433
Expect (cmds [1 ].String ()).To (Equal ("ping: " ))
422
434
stack = append (stack , "ring.BeforeProcessPipeline" )
423
435
424
436
err := hook (ctx , cmds )
425
437
426
- Expect (cmds ).To (HaveLen ( 3 ))
438
+ Expect (len ( cmds )) .To (BeNumerically ( ">=" , 3 ))
427
439
Expect (cmds [1 ].String ()).To (Equal ("ping: PONG" ))
428
440
stack = append (stack , "ring.AfterProcessPipeline" )
429
441
@@ -437,14 +449,18 @@ var _ = Describe("Redis Ring", func() {
437
449
processPipelineHook : func (hook redis.ProcessPipelineHook ) redis.ProcessPipelineHook {
438
450
return func (ctx context.Context , cmds []redis.Cmder ) error {
439
451
defer GinkgoRecover ()
452
+ // skip the connection initialization
453
+ if cmds [0 ].Name () == "hello" || cmds [0 ].Name () == "client" {
454
+ return nil
455
+ }
440
456
441
- Expect (cmds ).To (HaveLen ( 3 ))
457
+ Expect (len ( cmds )) .To (BeNumerically ( ">=" , 3 ))
442
458
Expect (cmds [1 ].String ()).To (Equal ("ping: " ))
443
459
stack = append (stack , "shard.BeforeProcessPipeline" )
444
460
445
461
err := hook (ctx , cmds )
446
462
447
- Expect (cmds ).To (HaveLen ( 3 ))
463
+ Expect (len ( cmds )) .To (BeNumerically ( ">=" , 3 ))
448
464
Expect (cmds [1 ].String ()).To (Equal ("ping: PONG" ))
449
465
stack = append (stack , "shard.AfterProcessPipeline" )
450
466
0 commit comments