@@ -1001,7 +1001,8 @@ stop_rabbitmq_nodes(Config) ->
10011001 fun (NodeConfig ) ->
10021002 stop_rabbitmq_node (Config , NodeConfig )
10031003 end ),
1004- find_crashes_in_logs (NodeConfigs ),
1004+ IgnoredCrashes = [" ** force_vhost_failure" ],
1005+ find_crashes_in_logs (NodeConfigs , IgnoredCrashes ),
10051006 proplists :delete (rmq_nodes , Config ).
10061007
10071008stop_rabbitmq_node (Config , NodeConfig ) ->
@@ -1022,68 +1023,83 @@ stop_rabbitmq_node(Config, NodeConfig) ->
10221023 end ,
10231024 NodeConfig .
10241025
1025- find_crashes_in_logs (NodeConfigs ) ->
1026+ find_crashes_in_logs (NodeConfigs , IgnoredCrashes ) ->
10261027 ct :pal (
10271028 " Looking up any crash reports in the nodes' log files. If we find "
10281029 " some, they will appear below:" ),
10291030 CrashesCount = lists :foldl (
10301031 fun (NodeConfig , Total ) ->
1031- Count = count_crashes_in_logs (NodeConfig ),
1032+ Count = count_crashes_in_logs (
1033+ NodeConfig , IgnoredCrashes ),
10321034 Total + Count
10331035 end , 0 , NodeConfigs ),
10341036 ct :pal (" Found ~b crash report(s)" , [CrashesCount ]),
10351037 ? assertEqual (0 , CrashesCount ).
10361038
1037- count_crashes_in_logs (NodeConfig ) ->
1039+ count_crashes_in_logs (NodeConfig , IgnoredCrashes ) ->
10381040 LogLocations = ? config (log_locations , NodeConfig ),
10391041 lists :foldl (
10401042 fun (LogLocation , Total ) ->
1041- Count = count_crashes_in_log (LogLocation ),
1043+ Count = count_crashes_in_log (LogLocation , IgnoredCrashes ),
10421044 Total + Count
10431045 end , 0 , LogLocations ).
10441046
1045- count_crashes_in_log (LogLocation ) ->
1047+ count_crashes_in_log (LogLocation , IgnoredCrashes ) ->
10461048 case file :read_file (LogLocation ) of
1047- {ok , Content } -> count_crashes_in_content (Content );
1049+ {ok , Content } -> count_crashes_in_content (Content , IgnoredCrashes );
10481050 _ -> 0
10491051 end .
10501052
1051- count_crashes_in_content (Content ) ->
1053+ count_crashes_in_content (Content , IgnoredCrashes ) ->
10521054 ReOpts = [multiline ],
10531055 Lines = re :split (Content , " ^" , ReOpts ),
1054- count_gen_server_terminations (Lines ).
1056+ count_gen_server_terminations (Lines , IgnoredCrashes ).
10551057
1056- count_gen_server_terminations (Lines ) ->
1057- count_gen_server_terminations (Lines , 0 ).
1058+ count_gen_server_terminations (Lines , IgnoredCrashes ) ->
1059+ count_gen_server_terminations (Lines , 0 , IgnoredCrashes ).
10581060
1059- count_gen_server_terminations ([Line | Rest ], Count ) ->
1061+ count_gen_server_terminations ([Line | Rest ], Count , IgnoredCrashes ) ->
10601062 ReOpts = [{capture , all_but_first , list }],
10611063 Ret = re :run (
10621064 Line ,
10631065 " (<[0-9.]+> )[*]{2} Generic server .+ terminating$" ,
10641066 ReOpts ),
10651067 case Ret of
10661068 {match , [Prefix ]} ->
1067- capture_gen_server_termination (Rest , Prefix , [Line ], Count + 1 );
1069+ capture_gen_server_termination (
1070+ Rest , Prefix , [Line ], Count , IgnoredCrashes );
10681071 nomatch ->
1069- count_gen_server_terminations (Rest , Count )
1072+ count_gen_server_terminations (Rest , Count , IgnoredCrashes )
10701073 end ;
1071- count_gen_server_terminations ([], Count ) ->
1074+ count_gen_server_terminations ([], Count , _IgnoredCrashes ) ->
10721075 Count .
10731076
1074- capture_gen_server_termination ([Line | Rest ] = Lines , Prefix , Acc , Count ) ->
1075- ReOpts = [{capture , none }],
1076- Ret = re :run (Line , Prefix ++ " ( |\\ *|$)" , ReOpts ),
1077+ capture_gen_server_termination (
1078+ [Line | Rest ] = Lines , Prefix , Acc , Count , IgnoredCrashes ) ->
1079+ ReOpts = [{capture , all_but_first , list }],
1080+ Ret = re :run (Line , Prefix ++ " ( .*|\\ *.*|)$" , ReOpts ),
10771081 case Ret of
1078- match ->
1079- capture_gen_server_termination (Rest , Prefix , [Line | Acc ], Count );
1082+ {match , [Suffix ]} ->
1083+ case lists :member (Suffix , IgnoredCrashes ) of
1084+ false ->
1085+ capture_gen_server_termination (
1086+ Rest , Prefix , [Line | Acc ], Count , IgnoredCrashes );
1087+ true ->
1088+ count_gen_server_terminations (
1089+ Lines , Count , IgnoredCrashes )
1090+ end ;
10801091 nomatch ->
1081- ct : pal ( " gen_server termination: ~n~n~s " , [ lists : reverse ( Acc )]),
1082- count_gen_server_terminations ( Lines , Count )
1092+ found_gen_server_termiation (
1093+ lists : reverse ( Acc ), Lines , Count , IgnoredCrashes )
10831094 end ;
1084- capture_gen_server_termination ([] = Rest , _Prefix , Acc , Count ) ->
1085- ct :pal (" gen_server termination:~n~n~s " , [lists :reverse (Acc )]),
1086- count_gen_server_terminations (Rest , Count ).
1095+ capture_gen_server_termination (
1096+ [] = Rest , _Prefix , Acc , Count , IgnoredCrashes ) ->
1097+ found_gen_server_termiation (
1098+ lists :reverse (Acc ), Rest , Count , IgnoredCrashes ).
1099+
1100+ found_gen_server_termiation (Message , Lines , Count , IgnoredCrashes ) ->
1101+ ct :pal (" gen_server termination:~n~n~s " , [Message ]),
1102+ count_gen_server_terminations (Lines , Count + 1 , IgnoredCrashes ).
10871103
10881104% % -------------------------------------------------------------------
10891105% % Helpers for partition simulation
@@ -1332,6 +1348,8 @@ delete_vhost(Config, Node, VHost) ->
13321348delete_vhost (Config , Node , VHost , Username ) ->
13331349 catch rpc (Config , Node , rabbit_vhost , delete , [VHost , Username ]).
13341350
1351+ -define (FORCE_VHOST_FAILURE_REASON , force_vhost_failure ).
1352+
13351353force_vhost_failure (Config , VHost ) -> force_vhost_failure (Config , 0 , VHost ).
13361354
13371355force_vhost_failure (Config , Node , VHost ) ->
@@ -1345,7 +1363,8 @@ force_vhost_failure(Config, Node, VHost, Attempts) ->
13451363 try
13461364 MessageStorePid = get_message_store_pid (Config , Node , VHost ),
13471365 rpc (Config , Node ,
1348- erlang , exit , [MessageStorePid , force_vhost_failure ]),
1366+ erlang , exit ,
1367+ [MessageStorePid , ? FORCE_VHOST_FAILURE_REASON ]),
13491368 % % Give it a time to fail
13501369 timer :sleep (300 ),
13511370 force_vhost_failure (Config , Node , VHost , Attempts - 1 )
0 commit comments