@@ -52,7 +52,8 @@ groups() ->
52
52
reset_removes_things ,
53
53
forget_offline_removes_things ,
54
54
force_boot ,
55
- status_with_alarm
55
+ status_with_alarm ,
56
+ wait_fails_when_cluster_fails
56
57
]},
57
58
{cluster_size_4 , [], [
58
59
forget_promotes_offline_slave
@@ -73,8 +74,10 @@ suite() ->
73
74
init_per_suite (Config ) ->
74
75
rabbit_ct_helpers :log_environment (),
75
76
Config1 = rabbit_ct_helpers :merge_app_env (
76
- Config ,
77
- {rabbit , [{mnesia_table_loading_retry_limit , 1 }]}),
77
+ Config , {rabbit , [
78
+ {mnesia_table_loading_retry_limit , 2 },
79
+ {mnesia_table_loading_retry_timeout ,1000 }
80
+ ]}),
78
81
rabbit_ct_helpers :run_setup_steps (Config1 ).
79
82
80
83
end_per_suite (Config ) ->
@@ -595,8 +598,49 @@ status_with_alarm(Config) ->
595
598
ok = alarm_information_on_each_node (R , Rabbit , Hare ).
596
599
597
600
601
+ wait_fails_when_cluster_fails (Config ) ->
602
+ [Rabbit , Hare ] = rabbit_ct_broker_helpers :get_node_configs (Config ,
603
+ nodename ),
604
+ RabbitConfig = rabbit_ct_broker_helpers :get_node_config (Config ,Rabbit ),
605
+ RabbitPidFile = ? config (pid_file , RabbitConfig ),
606
+ % % ensure pid file is readable
607
+ {ok , _ } = file :read_file (RabbitPidFile ),
608
+ % % ensure wait works on running node
609
+ {ok , _ } = rabbit_ct_broker_helpers :rabbitmqctl (Config , Rabbit ,
610
+ [" wait" , RabbitPidFile ]),
611
+ % % stop both nodes
612
+ ok = rabbit_ct_broker_helpers :stop_node (Config , Rabbit ),
613
+ ok = rabbit_ct_broker_helpers :stop_node (Config , Hare ),
614
+ % % starting first node fails - it was not the last node to stop
615
+ {error , _ } = rabbit_ct_broker_helpers :start_node (Config , Rabbit ),
616
+ % % start first node in the background
617
+ spawn_link (fun () ->
618
+ rabbit_ct_broker_helpers :start_node (Config , Rabbit )
619
+ end ),
620
+ Attempts = 10 ,
621
+ Timeout = 500 ,
622
+ wait_for_pid_file_to_contain_running_process_pid (RabbitPidFile , Attempts , Timeout ),
623
+ {error , _ , _ } = rabbit_ct_broker_helpers :rabbitmqctl (Config , Rabbit ,
624
+ [" wait" , RabbitPidFile ]).
625
+
598
626
% % ----------------------------------------------------------------------------
599
627
% % Internal utils
628
+ % % ----------------------------------------------------------------------------
629
+
630
+ wait_for_pid_file_to_contain_running_process_pid (_ , 0 , _ ) ->
631
+ error (timeout_waiting_for_pid_file_to_have_running_pid );
632
+ wait_for_pid_file_to_contain_running_process_pid (PidFile , Attempts , Timeout ) ->
633
+ Pid = pid_from_file (PidFile ),
634
+ case rabbit_misc :is_os_process_alive (Pid ) of
635
+ true -> ok ;
636
+ false ->
637
+ ct :sleep (Timeout ),
638
+ wait_for_pid_file_to_contain_running_process_pid (PidFile , Attempts - 1 , Timeout )
639
+ end .
640
+
641
+ pid_from_file (PidFile ) ->
642
+ {ok , Content } = file :read_file (PidFile ),
643
+ string :strip (binary_to_list (Content ), both , $\n ).
600
644
601
645
cluster_members (Config ) ->
602
646
rabbit_ct_broker_helpers :get_node_configs (Config , nodename ).
0 commit comments