1818
1919-include_lib (" common_test/include/ct.hrl" ).
2020-include_lib (" amqp_client/include/amqp_client.hrl" ).
21+ -include_lib (" eunit/include/eunit.hrl" ).
2122
2223-compile (export_all ).
2324
@@ -53,7 +54,8 @@ groups() ->
5354 forget_offline_removes_things ,
5455 force_boot ,
5556 status_with_alarm ,
56- wait_fails_when_cluster_fails
57+ pid_file_and_await_node_startup ,
58+ await_running_count
5759 ]},
5860 {cluster_size_4 , [], [
5961 forget_promotes_offline_slave
@@ -611,7 +613,7 @@ status_with_alarm(Config) ->
611613 ok = alarm_information_on_each_node (R , Rabbit , Hare ).
612614
613615
614- wait_fails_when_cluster_fails (Config ) ->
616+ pid_file_and_await_node_startup (Config ) ->
615617 [Rabbit , Hare ] = rabbit_ct_broker_helpers :get_node_configs (Config ,
616618 nodename ),
617619 RabbitConfig = rabbit_ct_broker_helpers :get_node_config (Config ,Rabbit ),
@@ -636,6 +638,46 @@ wait_fails_when_cluster_fails(Config) ->
636638 {error , _ , _ } = rabbit_ct_broker_helpers :rabbitmqctl (Config , Rabbit ,
637639 [" wait" , RabbitPidFile ]).
638640
641+ await_running_count (Config ) ->
642+ [Rabbit , Hare ] = rabbit_ct_broker_helpers :get_node_configs (Config ,
643+ nodename ),
644+ RabbitConfig = rabbit_ct_broker_helpers :get_node_config (Config ,Rabbit ),
645+ RabbitPidFile = ? config (pid_file , RabbitConfig ),
646+ {ok , _ } = rabbit_ct_broker_helpers :rabbitmqctl (Config , Rabbit ,
647+ [" wait" , RabbitPidFile ]),
648+ % % stop both nodes
649+ ok = rabbit_ct_broker_helpers :stop_node (Config , Hare ),
650+ ok = rabbit_ct_broker_helpers :stop_node (Config , Rabbit ),
651+ % % start one node in the background
652+ rabbit_ct_broker_helpers :start_node (Config , Rabbit ),
653+ {ok , _ } = rabbit_ct_broker_helpers :rabbitmqctl (Config , Rabbit ,
654+ [" wait" , RabbitPidFile ]),
655+ ? assertEqual (ok , rabbit_ct_broker_helpers :rpc (Config , Rabbit ,
656+ rabbit_nodes ,
657+ await_running_count , [1 , 30000 ])),
658+ ? assertEqual ({error , timeout },
659+ rabbit_ct_broker_helpers :rpc (Config , Rabbit ,
660+ rabbit_nodes ,
661+ await_running_count , [2 , 1000 ])),
662+ ? assertEqual ({error , timeout },
663+ rabbit_ct_broker_helpers :rpc (Config , Rabbit ,
664+ rabbit_nodes ,
665+ await_running_count , [5 , 1000 ])),
666+ rabbit_ct_broker_helpers :start_node (Config , Hare ),
667+ % % this now succeeds
668+ ? assertEqual (ok , rabbit_ct_broker_helpers :rpc (Config , Rabbit ,
669+ rabbit_nodes ,
670+ await_running_count , [2 , 30000 ])),
671+ % % this still succeeds
672+ ? assertEqual (ok , rabbit_ct_broker_helpers :rpc (Config , Rabbit ,
673+ rabbit_nodes ,
674+ await_running_count , [1 , 30000 ])),
675+ % % this still fails
676+ ? assertEqual ({error , timeout },
677+ rabbit_ct_broker_helpers :rpc (Config , Rabbit ,
678+ rabbit_nodes ,
679+ await_running_count , [5 , 1000 ])).
680+
639681% % ----------------------------------------------------------------------------
640682% % Internal utils
641683% % ----------------------------------------------------------------------------
0 commit comments