Set jmx port to -1 to force failure of startup in JMX app.

- even if run as root or port is already in use (as JMX failure in that case will allow the Java app to continue to run).
This commit is contained in:
Doug Rohrer 2016-06-01 16:38:25 -04:00
parent 5c321fbf12
commit 19c44d982c

View File

@ -118,7 +118,10 @@ confirm() ->
pass.
test_supervision() ->
JMXPort = 22,
%% Specifically invalid port number to make JMX startup fail.
%% NOTE: using a priveleged port doesn't work in some test environments
%% as tests/riak are running as root. For this test, -1 is fine.
JMXPort = -1,
Config = [{riak_jmx, [{enabled, true}, {port, JMXPort}]}],
[Node|[]] = rt:deploy_nodes(1, Config),
timer:sleep(20000),
@ -148,11 +151,11 @@ test_supervision() ->
%% Error logging is 0-based, so look for Retry #9
{Delay, _Retry} = rt:get_retry_settings(),
TwoMinutes = 2*60*1000,
TwoMinutsOfRetry = TwoMinutes div Delay,
Retries = TwoMinutes div Delay,
?assertEqual(true, rt:expect_in_log(Node, "JMX server monitor .* exited with code .*\. Retry #9",
TwoMinutsOfRetry, Delay)),
Retries, Delay)),
?assertEqual(true, rt:expect_in_log(Node, "JMX server monitor .* exited with code .*\. Reached maximum retries of 10",
TwoMinutsOfRetry, Delay)),
Retries, Delay)),
rt:stop(Node),
ok_ok.
@ -222,4 +225,4 @@ jmx_dump(Cmd) ->
lager:info("Dumping JMX stats using command ~s", [Cmd]),
Output = string:strip(os:cmd(Cmd), both, $\n),
JSONOutput = mochijson2:decode(Output),
[ {Key, Value} || {struct, [{Key, Value}]} <- JSONOutput].
[ {Key, Value} || {struct, [{Key, Value}]} <- JSONOutput].