summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rabbit_runtime_parameters_test.erl31
-rw-r--r--src/rabbit_tests.erl31
2 files changed, 62 insertions, 0 deletions
diff --git a/src/rabbit_runtime_parameters_test.erl b/src/rabbit_runtime_parameters_test.erl
new file mode 100644
index 0000000000..24cdfce901
--- /dev/null
+++ b/src/rabbit_runtime_parameters_test.erl
@@ -0,0 +1,31 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License
+%% at http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and
+%% limitations under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
+%%
+
+-module(rabbit_runtime_parameters_test).
+-behaviour(rabbit_runtime_parameter).
+
+-export([validate/3, notify/3, notify_clear/2]).
+-export([register/0]).
+
+register() ->
+ rabbit_registry:register(runtime_parameter, <<"test">>, ?MODULE).
+
+validate(<<"test">>, <<"good">>, _Term) -> ok;
+validate(<<"test">>, <<"maybe">>, <<"good">>) -> ok;
+validate(<<"test">>, _, _) -> {error, "meh", []}.
+
+notify(_, _, _) -> ok.
+notify_clear(_, _) -> ok.
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index 55e4a6f854..d80f3162b5 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -53,6 +53,7 @@ all_tests() ->
passed = test_option_parser(),
passed = test_cluster_management(),
passed = test_user_management(),
+ passed = test_runtime_parameters(),
passed = test_server_status(),
passed = test_confirms(),
passed = maybe_run_cluster_dependent_tests(),
@@ -1096,6 +1097,36 @@ test_user_management() ->
passed.
+test_runtime_parameters() ->
+ rabbit_runtime_parameters_test:register(),
+ Good = fun(L) -> ok = control_action(set_parameter, L) end,
+ Bad = fun(L) -> {error_string, _} = control_action(set_parameter, L) end,
+
+ %% Acceptable for bijection
+ Good(["test", "good", "<<\"ignore\">>"]),
+ Good(["test", "good", "123"]),
+ Good(["test", "good", "true"]),
+ Good(["test", "good", "false"]),
+ Good(["test", "good", "null"]),
+ Good(["test", "good", "[{<<\"key\">>, <<\"value\">>}]"]),
+
+ %% Various forms of fail due to non-bijectability
+ Bad(["test", "good", "atom"]),
+ Bad(["test", "good", "{tuple, foo}"]),
+ Bad(["test", "good", "[{<<\"key\">>, <<\"value\">>, 1}]"]),
+ Bad(["test", "good", "[{key, <<\"value\">>}]"]),
+
+ %% Test actual validation hook
+ Good(["test", "maybe", "<<\"good\">>"]),
+ Bad(["test", "maybe", "<<\"bad\">>"]),
+
+ ok = control_action(list_parameters, []),
+
+ ok = control_action(clear_parameter, ["test", "good"]),
+ ok = control_action(clear_parameter, ["test", "maybe"]),
+
+ passed.
+
test_server_status() ->
%% create a few things so there is some useful information to list
Writer = spawn(fun () -> receive shutdown -> ok end end),