diff options
| author | Michael Klishin <mklishin@pivotal.io> | 2019-05-03 02:55:32 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-03 02:55:32 +0300 |
| commit | 3cfcacbbd929c3cf0788628b65380c0c5dc92b1f (patch) | |
| tree | f5870099ca9187e36c333384ed7c2e4b43dcf935 | |
| parent | 70a5250db2445e124e0c10dc8d2bdfa2173b84bb (diff) | |
| parent | 0222ee638c1470be813804cf77a12833186ca8be (diff) | |
| download | rabbitmq-server-git-3cfcacbbd929c3cf0788628b65380c0c5dc92b1f.tar.gz | |
Merge pull request #1999 from rabbitmq/queue-master-location-validation
Policy validation must return 'ok' or an error
| -rw-r--r-- | src/rabbit_queue_location_validator.erl | 5 | ||||
| -rw-r--r-- | test/queue_master_location_SUITE.erl | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/rabbit_queue_location_validator.erl b/src/rabbit_queue_location_validator.erl index ad6bb292ab..2638b79a59 100644 --- a/src/rabbit_queue_location_validator.erl +++ b/src/rabbit_queue_location_validator.erl @@ -33,7 +33,10 @@ validate_policy(KeyList) -> case proplists:lookup(<<"queue-master-locator">> , KeyList) of - {_, Strategy} -> validate_strategy(Strategy); + {_, Strategy} -> case validate_strategy(Strategy) of + {error, _} = Er -> Er; + _ -> ok + end; _ -> {error, "queue-master-locator undefined"} end. diff --git a/test/queue_master_location_SUITE.erl b/test/queue_master_location_SUITE.erl index f8018552d9..fa5344667b 100644 --- a/test/queue_master_location_SUITE.erl +++ b/test/queue_master_location_SUITE.erl @@ -51,6 +51,7 @@ groups() -> {cluster_size_3, [], [ declare_args, declare_policy, + declare_invalid_policy, declare_policy_nodes, declare_policy_all, declare_policy_exactly, @@ -129,6 +130,19 @@ declare_policy(Config) -> declare(Config, QueueName, false, false, _Args=[], none), verify_min_master(Config, Q). +declare_invalid_policy(Config) -> + %% Tests that queue masters location returns 'ok', otherwise the validation of + %% any other parameter might be skipped and invalid policy accepted. + setup_test_environment(Config), + unset_location_config(Config), + Policy = [{<<"queue-master-locator">>, <<"min-masters">>}, + {<<"ha-mode">>, <<"exactly">>}, + %% this field is expected to be an integer + {<<"ha-params">>, <<"2">>}], + {error_string, _} = rabbit_ct_broker_helpers:rpc( + Config, 0, rabbit_policy, set, + [<<"/">>, ?POLICY, <<".*">>, Policy, 0, <<"queues">>, <<"acting-user">>]). + declare_policy_nodes(Config) -> setup_test_environment(Config), unset_location_config(Config), |
