@@ -1001,7 +1001,8 @@ stop_rabbitmq_nodes(Config) ->
1001
1001
fun (NodeConfig ) ->
1002
1002
stop_rabbitmq_node (Config , NodeConfig )
1003
1003
end ),
1004
- find_crashes_in_logs (NodeConfigs ),
1004
+ IgnoredCrashes = [" ** force_vhost_failure" ],
1005
+ find_crashes_in_logs (NodeConfigs , IgnoredCrashes ),
1005
1006
proplists :delete (rmq_nodes , Config ).
1006
1007
1007
1008
stop_rabbitmq_node (Config , NodeConfig ) ->
@@ -1022,68 +1023,83 @@ stop_rabbitmq_node(Config, NodeConfig) ->
1022
1023
end ,
1023
1024
NodeConfig .
1024
1025
1025
- find_crashes_in_logs (NodeConfigs ) ->
1026
+ find_crashes_in_logs (NodeConfigs , IgnoredCrashes ) ->
1026
1027
ct :pal (
1027
1028
" Looking up any crash reports in the nodes' log files. If we find "
1028
1029
" some, they will appear below:" ),
1029
1030
CrashesCount = lists :foldl (
1030
1031
fun (NodeConfig , Total ) ->
1031
- Count = count_crashes_in_logs (NodeConfig ),
1032
+ Count = count_crashes_in_logs (
1033
+ NodeConfig , IgnoredCrashes ),
1032
1034
Total + Count
1033
1035
end , 0 , NodeConfigs ),
1034
1036
ct :pal (" Found ~b crash report(s)" , [CrashesCount ]),
1035
1037
? assertEqual (0 , CrashesCount ).
1036
1038
1037
- count_crashes_in_logs (NodeConfig ) ->
1039
+ count_crashes_in_logs (NodeConfig , IgnoredCrashes ) ->
1038
1040
LogLocations = ? config (log_locations , NodeConfig ),
1039
1041
lists :foldl (
1040
1042
fun (LogLocation , Total ) ->
1041
- Count = count_crashes_in_log (LogLocation ),
1043
+ Count = count_crashes_in_log (LogLocation , IgnoredCrashes ),
1042
1044
Total + Count
1043
1045
end , 0 , LogLocations ).
1044
1046
1045
- count_crashes_in_log (LogLocation ) ->
1047
+ count_crashes_in_log (LogLocation , IgnoredCrashes ) ->
1046
1048
case file :read_file (LogLocation ) of
1047
- {ok , Content } -> count_crashes_in_content (Content );
1049
+ {ok , Content } -> count_crashes_in_content (Content , IgnoredCrashes );
1048
1050
_ -> 0
1049
1051
end .
1050
1052
1051
- count_crashes_in_content (Content ) ->
1053
+ count_crashes_in_content (Content , IgnoredCrashes ) ->
1052
1054
ReOpts = [multiline ],
1053
1055
Lines = re :split (Content , " ^" , ReOpts ),
1054
- count_gen_server_terminations (Lines ).
1056
+ count_gen_server_terminations (Lines , IgnoredCrashes ).
1055
1057
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 ).
1058
1060
1059
- count_gen_server_terminations ([Line | Rest ], Count ) ->
1061
+ count_gen_server_terminations ([Line | Rest ], Count , IgnoredCrashes ) ->
1060
1062
ReOpts = [{capture , all_but_first , list }],
1061
1063
Ret = re :run (
1062
1064
Line ,
1063
1065
" (<[0-9.]+> )[*]{2} Generic server .+ terminating$" ,
1064
1066
ReOpts ),
1065
1067
case Ret of
1066
1068
{match , [Prefix ]} ->
1067
- capture_gen_server_termination (Rest , Prefix , [Line ], Count + 1 );
1069
+ capture_gen_server_termination (
1070
+ Rest , Prefix , [Line ], Count , IgnoredCrashes );
1068
1071
nomatch ->
1069
- count_gen_server_terminations (Rest , Count )
1072
+ count_gen_server_terminations (Rest , Count , IgnoredCrashes )
1070
1073
end ;
1071
- count_gen_server_terminations ([], Count ) ->
1074
+ count_gen_server_terminations ([], Count , _IgnoredCrashes ) ->
1072
1075
Count .
1073
1076
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 ),
1077
1081
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 ;
1080
1091
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 )
1083
1094
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 ).
1087
1103
1088
1104
% % -------------------------------------------------------------------
1089
1105
% % Helpers for partition simulation
@@ -1332,6 +1348,8 @@ delete_vhost(Config, Node, VHost) ->
1332
1348
delete_vhost (Config , Node , VHost , Username ) ->
1333
1349
catch rpc (Config , Node , rabbit_vhost , delete , [VHost , Username ]).
1334
1350
1351
+ -define (FORCE_VHOST_FAILURE_REASON , force_vhost_failure ).
1352
+
1335
1353
force_vhost_failure (Config , VHost ) -> force_vhost_failure (Config , 0 , VHost ).
1336
1354
1337
1355
force_vhost_failure (Config , Node , VHost ) ->
@@ -1345,7 +1363,8 @@ force_vhost_failure(Config, Node, VHost, Attempts) ->
1345
1363
try
1346
1364
MessageStorePid = get_message_store_pid (Config , Node , VHost ),
1347
1365
rpc (Config , Node ,
1348
- erlang , exit , [MessageStorePid , force_vhost_failure ]),
1366
+ erlang , exit ,
1367
+ [MessageStorePid , ? FORCE_VHOST_FAILURE_REASON ]),
1349
1368
% % Give it a time to fail
1350
1369
timer :sleep (300 ),
1351
1370
force_vhost_failure (Config , Node , VHost , Attempts - 1 )
0 commit comments