@@ -60,6 +60,7 @@ all_tests() ->
6060 passed = test_user_management (),
6161 passed = test_runtime_parameters (),
6262 passed = test_policy_validation (),
63+ passed = test_ha_policy_validation (),
6364 passed = test_server_status (),
6465 passed = test_amqp_connection_refusal (),
6566 passed = test_confirms (),
@@ -1101,6 +1102,34 @@ test_policy_validation() ->
11011102 rabbit_runtime_parameters_test :unregister_policy_validator (),
11021103 passed .
11031104
1105+ test_ha_policy_validation () ->
1106+ Set = fun (JSON ) -> control_action (set_policy , [" name" , " .*" , JSON ]) end ,
1107+ OK = fun (JSON ) -> ok = Set (JSON ) end ,
1108+ Fail = fun (JSON ) -> {error_string , _ } = Set (JSON ) end ,
1109+
1110+ OK (" {\" ha-mode\" :\" all\" }" ),
1111+ Fail (" {\" ha-mode\" :\" made_up\" }" ),
1112+
1113+ Fail (" {\" ha-mode\" :\" nodes\" }" ),
1114+ Fail (" {\" ha-mode\" :\" nodes\" ,\" ha-params\" :2}" ),
1115+ Fail (" {\" ha-mode\" :\" nodes\" ,\" ha-params\" :[\" a\" ,2]}" ),
1116+ OK (" {\" ha-mode\" :\" nodes\" ,\" ha-params\" :[\" a\" ,\" b\" ]}" ),
1117+ Fail (" {\" ha-params\" :[\" a\" ,\" b\" ]}" ),
1118+
1119+ Fail (" {\" ha-mode\" :\" exactly\" }" ),
1120+ Fail (" {\" ha-mode\" :\" exactly\" ,\" ha-params\" :[\" a\" ,\" b\" ]}" ),
1121+ OK (" {\" ha-mode\" :\" exactly\" ,\" ha-params\" :2}" ),
1122+ Fail (" {\" ha-params\" :2}" ),
1123+
1124+ OK (" {\" ha-mode\" :\" all\" ,\" ha-sync-mode\" :\" manual\" }" ),
1125+ OK (" {\" ha-mode\" :\" all\" ,\" ha-sync-mode\" :\" automatic\" }" ),
1126+ Fail (" {\" ha-mode\" :\" all\" ,\" ha-sync-mode\" :\" made_up\" }" ),
1127+ Fail (" {\" ha-sync-mode\" :\" manual\" }" ),
1128+ Fail (" {\" ha-sync-mode\" :\" automatic\" }" ),
1129+
1130+ ok = control_action (clear_policy , [" name" ]),
1131+ passed .
1132+
11041133test_server_status () ->
11051134 % % create a few things so there is some useful information to list
11061135 {_Writer , Limiter , Ch } = test_channel (),
0 commit comments