Skip to content

Commit

Permalink
Nhse o32 orkv.i58 backport (#36)
Browse files Browse the repository at this point in the history
* sys_monitor_count moved to manual call

* Add testing of timeout for stats

* Fix issues with backport
  • Loading branch information
martinsumner authored Jan 24, 2025
1 parent 9eda795 commit f89856e
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/verify_riak_stats.erl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ confirm() ->

verify_inc(Stats7, Stats8, inc_by_one(dscp_totals())),

verify_sys_monitor_count(Node1),

verify_timeout(Node1),

pass.

verify_inc(Prev, Props, Keys) ->
Expand All @@ -191,6 +195,30 @@ verify_inc(Prev, Props, Keys) ->
verify_nz(Props, Keys) ->
[?assertNotEqual(proplists:get_value(Key,Props,0), 0) || Key <- Keys].

verify_sys_monitor_count(Node) ->
C = erpc:call(Node, riak_kv_util, sys_monitor_count, []),
?assert(is_integer(C)).

verify_timeout(Node) ->
StatsCommandT0 =
io_lib:format("curl -s -S ~s/stats?timeout=0", [rt:http_url(Node)]),
StatsCommandT1 =
io_lib:format("curl -s -S ~s/stats?timeout=1", [rt:http_url(Node)]),
StatsCommandT5000 =
io_lib:format("curl -s -S ~s/stats?timeout=5000", [rt:http_url(Node)]),
?assertMatch("Bad timeout value \"0\"", os:cmd(StatsCommandT0)),
lager:info("Waiting for HTTP cache to be expire before testing timeout"),
timer:sleep(1001),
lager:info("Here's hoping this won't respond in < 1ms"),
lager:info("Intercepts wll be required in the future if this gets faster"),
?assertMatch("Request timed out after 1 ms", os:cmd(StatsCommandT1)),
lager:info("Again waiting for cache expiry before testing cache"),
timer:sleep(1001),
JSON = os:cmd(StatsCommandT5000),
?assertMatch(struct, element(1, mochijson2:decode(JSON))),
JSONCached = os:cmd(StatsCommandT5000),
?assertMatch(JSON, JSONCached).

has_head_support(leveled) ->
true;
has_head_support(_Backend) ->
Expand Down Expand Up @@ -849,7 +877,6 @@ common_stats() ->
<<"sys_global_heaps_size">>,
<<"sys_heap_type">>,
<<"sys_logical_processors">>,
<<"sys_monitor_count">>,
<<"sys_otp_release">>,
<<"sys_port_count">>,
<<"sys_process_count">>,
Expand Down

0 comments on commit f89856e

Please sign in to comment.