@@ -579,116 +579,122 @@ lookup_exchange_status(Config) ->
579579 clean_up_federation_related_bits (Config ).
580580
581581child_id_format (Config ) ->
582- [UpstreamNode ,
583- OldNodeA ,
584- NewNodeB ,
585- OldNodeC ,
586- NewNodeD ] = rabbit_ct_broker_helpers :get_node_configs (
587- Config , nodename ),
588-
589- % % Create a cluster with the nodes running the old version of RabbitMQ in
590- % % mixed-version testing.
591- % %
592- % % Note: we build this on the assumption that `rabbit_ct_broker_helpers'
593- % % starts nodes this way:
594- % % Node 1: the primary copy of RabbitMQ the test is started from
595- % % Node 2: the secondary umbrella (if any)
596- % % Node 3: the primary copy
597- % % Node 4: the secondary umbrella
598- % % ...
599- % %
600- % % Therefore, `UpstreamNode' will use the primary copy, `OldNodeA' the
601- % % secondary umbrella, `NewNodeB' the primary copy, and so on.
602- Config1 = rabbit_ct_broker_helpers :cluster_nodes (
603- Config , [OldNodeA , OldNodeC ]),
604-
605- % % Prepare the whole federated exchange on that old cluster.
606- UpstreamName = <<" fed_on_upgrade" >>,
607- rabbit_ct_broker_helpers :set_parameter (
608- Config1 , OldNodeA , <<" federation-upstream" >>, UpstreamName ,
609- [
610- {<<" uri" >>, rabbit_ct_broker_helpers :node_uri (Config1 , UpstreamNode )}
611- ]),
612-
613- rabbit_ct_broker_helpers :set_policy (
614- Config1 , OldNodeA ,
615- <<" fed_on_upgrade_policy" >>, <<" ^fed_" >>, <<" all" >>,
616- [
617- {<<" federation-upstream-pattern" >>, UpstreamName }
618- ]),
619-
620- XName = <<" fed_ex_on_upgrade_cluster" >>,
621- X = exchange_declare_method (XName , <<" direct" >>),
622- {Conn1 , Ch1 } = rabbit_ct_client_helpers :open_connection_and_channel (
623- Config1 , OldNodeA ),
624- ? assertEqual ({'exchange.declare_ok' }, declare_exchange (Ch1 , X )),
625- rabbit_ct_client_helpers :close_channel (Ch1 ),
626- rabbit_ct_client_helpers :close_connection (Conn1 ),
627-
628- % % Verify the format of the child ID. In the main branch, the format was
629- % % temporarily a size-2 tuple with a list as the first element. This was
630- % % not kept later and the original ID format is used in old and new nodes.
631- [{Id , _ , _ , _ }] = rabbit_ct_broker_helpers :rpc (
632- Config1 , OldNodeA ,
633- mirrored_supervisor , which_children ,
634- [rabbit_federation_exchange_link_sup_sup ]),
635- case Id of
636- % % This is the format we expect everywhere.
637- # exchange {name = # resource {name = XName }} ->
638- % % Verify that the supervisors exist on all nodes.
639- lists :foreach (
640- fun (Node ) ->
641- ? assertMatch (
642- [{# exchange {name = # resource {name = XName }},
643- _ , _ , _ }],
644- rabbit_ct_broker_helpers :rpc (
645- Config1 , Node ,
646- mirrored_supervisor , which_children ,
647- [rabbit_federation_exchange_link_sup_sup ]))
648- end , [OldNodeA , OldNodeC ]),
649-
650- % % Simulate a rolling upgrade by:
651- % % 1. adding new nodes to the old cluster
652- % % 2. stopping the old nodes
653- % %
654- % % After that, the supervisors run on the new code.
655- Config2 = rabbit_ct_broker_helpers :cluster_nodes (
656- Config1 , OldNodeA , [NewNodeB , NewNodeD ]),
657- ok = rabbit_ct_broker_helpers :stop_broker (Config2 , OldNodeA ),
658- ok = rabbit_ct_broker_helpers :reset_node (Config1 , OldNodeA ),
659- ok = rabbit_ct_broker_helpers :stop_broker (Config2 , OldNodeC ),
660- ok = rabbit_ct_broker_helpers :reset_node (Config2 , OldNodeC ),
661-
662- % % Verify that the supervisors still use the same IDs.
663- lists :foreach (
664- fun (Node ) ->
665- ? assertMatch (
666- [{# exchange {name = # resource {name = XName }},
667- _ , _ , _ }],
668- rabbit_ct_broker_helpers :rpc (
669- Config2 , Node ,
670- mirrored_supervisor , which_children ,
671- [rabbit_federation_exchange_link_sup_sup ]))
672- end , [NewNodeB , NewNodeD ]),
673-
674- % % Delete the exchange: it should work because the ID format is the
675- % % one expected.
676- % %
677- % % During the transient period where the ID format was changed,
678- % % this would crash with a badmatch because the running
679- % % supervisor's ID would not match the content of the database.
680- {Conn2 , Ch2 } = rabbit_ct_client_helpers :open_connection_and_channel (
681- Config2 , NewNodeB ),
682- ? assertEqual ({'exchange.delete_ok' }, delete_exchange (Ch2 , XName )),
683- rabbit_ct_client_helpers :close_channel (Ch2 ),
684- rabbit_ct_client_helpers :close_connection (Conn2 );
685-
686- % % This is the transient format we are not interested in as it only
687- % % lived in a development branch.
688- {List , # exchange {name = # resource {name = XName }}}
689- when is_list (List ) ->
690- {skip , " Testcase skipped with the transiently changed ID format" }
691- end .
582+ case rabbit_ct_helpers :is_mixed_versions () of
583+ false ->
584+ [UpstreamNode ,
585+ OldNodeA ,
586+ NewNodeB ,
587+ OldNodeC ,
588+ NewNodeD ] = rabbit_ct_broker_helpers :get_node_configs (
589+ Config , nodename ),
590+
591+ % % Create a cluster with the nodes running the old version of RabbitMQ in
592+ % % mixed-version testing.
593+ % %
594+ % % Note: we build this on the assumption that `rabbit_ct_broker_helpers'
595+ % % starts nodes this way:
596+ % % Node 1: the primary copy of RabbitMQ the test is started from
597+ % % Node 2: the secondary umbrella (if any)
598+ % % Node 3: the primary copy
599+ % % Node 4: the secondary umbrella
600+ % % ...
601+ % %
602+ % % Therefore, `UpstreamNode' will use the primary copy, `OldNodeA' the
603+ % % secondary umbrella, `NewNodeB' the primary copy, and so on.
604+ Config1 = rabbit_ct_broker_helpers :cluster_nodes (
605+ Config , [OldNodeA , OldNodeC ]),
606+
607+ % % Prepare the whole federated exchange on that old cluster.
608+ UpstreamName = <<" fed_on_upgrade" >>,
609+ rabbit_ct_broker_helpers :set_parameter (
610+ Config1 , OldNodeA , <<" federation-upstream" >>, UpstreamName ,
611+ [
612+ {<<" uri" >>, rabbit_ct_broker_helpers :node_uri (Config1 , UpstreamNode )}
613+ ]),
614+
615+ rabbit_ct_broker_helpers :set_policy (
616+ Config1 , OldNodeA ,
617+ <<" fed_on_upgrade_policy" >>, <<" ^fed_" >>, <<" all" >>,
618+ [
619+ {<<" federation-upstream-pattern" >>, UpstreamName }
620+ ]),
621+
622+ XName = <<" fed_ex_on_upgrade_cluster" >>,
623+ X = exchange_declare_method (XName , <<" direct" >>),
624+ {Conn1 , Ch1 } = rabbit_ct_client_helpers :open_connection_and_channel (
625+ Config1 , OldNodeA ),
626+ ? assertEqual ({'exchange.declare_ok' }, declare_exchange (Ch1 , X )),
627+ rabbit_ct_client_helpers :close_channel (Ch1 ),
628+ rabbit_ct_client_helpers :close_connection (Conn1 ),
629+
630+ % % Verify the format of the child ID. In the main branch, the format was
631+ % % temporarily a size-2 tuple with a list as the first element. This was
632+ % % not kept later and the original ID format is used in old and new nodes.
633+ [{Id , _ , _ , _ }] = rabbit_ct_broker_helpers :rpc (
634+ Config1 , OldNodeA ,
635+ mirrored_supervisor , which_children ,
636+ [rabbit_federation_exchange_link_sup_sup ]),
637+ case Id of
638+ % % This is the format we expect everywhere.
639+ # exchange {name = # resource {name = XName }} ->
640+ % % Verify that the supervisors exist on all nodes.
641+ lists :foreach (
642+ fun (Node ) ->
643+ ? assertMatch (
644+ [{# exchange {name = # resource {name = XName }},
645+ _ , _ , _ }],
646+ rabbit_ct_broker_helpers :rpc (
647+ Config1 , Node ,
648+ mirrored_supervisor , which_children ,
649+ [rabbit_federation_exchange_link_sup_sup ]))
650+ end , [OldNodeA , OldNodeC ]),
651+
652+ % % Simulate a rolling upgrade by:
653+ % % 1. adding new nodes to the old cluster
654+ % % 2. stopping the old nodes
655+ % %
656+ % % After that, the supervisors run on the new code.
657+ Config2 = rabbit_ct_broker_helpers :cluster_nodes (
658+ Config1 , OldNodeA , [NewNodeB , NewNodeD ]),
659+ ok = rabbit_ct_broker_helpers :stop_broker (Config2 , OldNodeA ),
660+ ok = rabbit_ct_broker_helpers :reset_node (Config1 , OldNodeA ),
661+ ok = rabbit_ct_broker_helpers :stop_broker (Config2 , OldNodeC ),
662+ ok = rabbit_ct_broker_helpers :reset_node (Config2 , OldNodeC ),
663+
664+ % % Verify that the supervisors still use the same IDs.
665+ lists :foreach (
666+ fun (Node ) ->
667+ ? assertMatch (
668+ [{# exchange {name = # resource {name = XName }},
669+ _ , _ , _ }],
670+ rabbit_ct_broker_helpers :rpc (
671+ Config2 , Node ,
672+ mirrored_supervisor , which_children ,
673+ [rabbit_federation_exchange_link_sup_sup ]))
674+ end , [NewNodeB , NewNodeD ]),
675+
676+ % % Delete the exchange: it should work because the ID format is the
677+ % % one expected.
678+ % %
679+ % % During the transient period where the ID format was changed,
680+ % % this would crash with a badmatch because the running
681+ % % supervisor's ID would not match the content of the database.
682+ {Conn2 , Ch2 } = rabbit_ct_client_helpers :open_connection_and_channel (
683+ Config2 , NewNodeB ),
684+ ? assertEqual ({'exchange.delete_ok' }, delete_exchange (Ch2 , XName )),
685+ rabbit_ct_client_helpers :close_channel (Ch2 ),
686+ rabbit_ct_client_helpers :close_connection (Conn2 );
687+
688+ % % This is the transient format we are not interested in as it only
689+ % % lived in a development branch.
690+ {List , # exchange {name = # resource {name = XName }}}
691+ when is_list (List ) ->
692+ {skip , " Testcase skipped with the transiently changed ID format" }
693+ end ;
694+ true ->
695+ % % skip the test in mixed version mode
696+ {skip , " Should not run in mixed version environments" }
697+ end .
692698
693699% %
694700% % Test helpers
0 commit comments