@@ -41,7 +41,9 @@ groups() ->
41
41
test_hash_ring_updates_when_exclusive_queues_are_deleted_due_to_connection_closure_case5 ,
42
42
test_hash_ring_updates_when_exclusive_queues_are_deleted_due_to_connection_closure_case6 ,
43
43
test_hash_ring_updates_when_exchange_is_deleted ,
44
- test_hash_ring_updates_when_queue_is_unbound
44
+ test_hash_ring_updates_when_queue_is_unbound ,
45
+ test_hash_ring_updates_when_duplicate_binding_is_created_and_queue_is_deleted ,
46
+ test_hash_ring_updates_when_duplicate_binding_is_created_and_binding_is_deleted
45
47
]}
46
48
].
47
49
@@ -557,6 +559,99 @@ test_hash_ring_updates_when_queue_is_unbound(Config) ->
557
559
rabbit_ct_client_helpers :close_channel (Chan ),
558
560
ok .
559
561
562
+ test_hash_ring_updates_when_duplicate_binding_is_created_and_queue_is_deleted (Config ) ->
563
+ Chan = rabbit_ct_client_helpers :open_channel (Config , 0 ),
564
+
565
+ X = <<" test_hash_ring_updates_when_duplicate_binding_is_created_and_queue_is_deleted" >>,
566
+ amqp_channel :call (Chan , # 'exchange.delete' {exchange = X }),
567
+
568
+ Declare = # 'exchange.declare' {exchange = X ,
569
+ type = <<" x-consistent-hash" >>},
570
+ # 'exchange.declare_ok' {} = amqp_channel :call (Chan , Declare ),
571
+
572
+ Q1 = <<" f-q1" >>,
573
+ # 'queue.declare_ok' {} =
574
+ amqp_channel :call (Chan , # 'queue.declare' {
575
+ queue = Q1 , durable = true , exclusive = false }),
576
+ # 'queue.bind_ok' {} =
577
+ amqp_channel :call (Chan , # 'queue.bind' {queue = Q1 ,
578
+ exchange = X ,
579
+ routing_key = <<" 2" >>}),
580
+
581
+ # 'queue.bind_ok' {} =
582
+ amqp_channel :call (Chan , # 'queue.bind' {queue = Q1 ,
583
+ exchange = X ,
584
+ routing_key = <<" 3" >>}),
585
+
586
+ ? assertEqual (5 , count_buckets_of_exchange (Config , X )),
587
+ assert_ring_consistency (Config , X ),
588
+
589
+ Q2 = <<" f-q2" >>,
590
+ # 'queue.declare_ok' {} =
591
+ amqp_channel :call (Chan , # 'queue.declare' {
592
+ queue = Q2 , durable = true , exclusive = false }),
593
+ # 'queue.bind_ok' {} =
594
+ amqp_channel :call (Chan , # 'queue.bind' {queue = Q2 ,
595
+ exchange = X ,
596
+ routing_key = <<" 4" >>}),
597
+
598
+ ? assertEqual (9 , count_buckets_of_exchange (Config , X )),
599
+ assert_ring_consistency (Config , X ),
600
+
601
+ amqp_channel :call (Chan , # 'queue.delete' {queue = Q1 }),
602
+ ? assertEqual (4 , count_buckets_of_exchange (Config , X )),
603
+ assert_ring_consistency (Config , X ),
604
+
605
+ clean_up_test_topology (Config , X , [Q1 , Q2 ]),
606
+ rabbit_ct_client_helpers :close_channel (Chan ),
607
+ ok .
608
+
609
+ test_hash_ring_updates_when_duplicate_binding_is_created_and_binding_is_deleted (Config ) ->
610
+ Chan = rabbit_ct_client_helpers :open_channel (Config , 0 ),
611
+
612
+ X = <<" test_hash_ring_updates_when_duplicate_binding_is_created_and_binding_is_deleted" >>,
613
+ amqp_channel :call (Chan , # 'exchange.delete' {exchange = X }),
614
+
615
+ Declare = # 'exchange.declare' {exchange = X ,
616
+ type = <<" x-consistent-hash" >>},
617
+ # 'exchange.declare_ok' {} = amqp_channel :call (Chan , Declare ),
618
+
619
+ Q1 = <<" f-q1" >>,
620
+ # 'queue.declare_ok' {} =
621
+ amqp_channel :call (Chan , # 'queue.declare' {
622
+ queue = Q1 , durable = true , exclusive = false }),
623
+ # 'queue.bind_ok' {} =
624
+ amqp_channel :call (Chan , # 'queue.bind' {queue = Q1 ,
625
+ exchange = X ,
626
+ routing_key = <<" 2" >>}),
627
+
628
+ # 'queue.bind_ok' {} =
629
+ amqp_channel :call (Chan , # 'queue.bind' {queue = Q1 ,
630
+ exchange = X ,
631
+ routing_key = <<" 3" >>}),
632
+
633
+ Q2 = <<" f-q2" >>,
634
+ # 'queue.declare_ok' {} =
635
+ amqp_channel :call (Chan , # 'queue.declare' {
636
+ queue = Q2 , durable = true , exclusive = false }),
637
+ # 'queue.bind_ok' {} =
638
+ amqp_channel :call (Chan , # 'queue.bind' {queue = Q2 ,
639
+ exchange = X ,
640
+ routing_key = <<" 4" >>}),
641
+
642
+ ? assertEqual (9 , count_buckets_of_exchange (Config , X )),
643
+ assert_ring_consistency (Config , X ),
644
+
645
+ % % Both bindings to Q1 will be deleted
646
+ amqp_channel :call (Chan , # 'queue.unbind' {queue = Q1 ,
647
+ exchange = X ,
648
+ routing_key = <<" 3" >>}),
649
+ ? assertEqual (4 , count_buckets_of_exchange (Config , X )),
650
+ assert_ring_consistency (Config , X ),
651
+
652
+ clean_up_test_topology (Config , X , [Q1 , Q2 ]),
653
+ rabbit_ct_client_helpers :close_channel (Chan ),
654
+ ok .
560
655
561
656
% %
562
657
% % Helpers
0 commit comments