Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
chrzaszcz committed Jul 11, 2024
1 parent a5407fb commit a9882a2
Show file tree
Hide file tree
Showing 18 changed files with 345 additions and 480 deletions.
2 changes: 1 addition & 1 deletion big_tests/default.spec
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
{suites, "tests", graphql_http_upload_SUITE}.
{suites, "tests", graphql_server_SUITE}.
{suites, "tests", graphql_metric_SUITE}.
{suites, "tests", instrument_cets_SUITE}.
{suites, "tests", instrument_SUITE}.
{suites, "tests", inbox_SUITE}.
{suites, "tests", inbox_extensions_SUITE}.
{suites, "tests", jingle_SUITE}.
Expand Down
2 changes: 1 addition & 1 deletion big_tests/dynamic_domains.spec
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
{suites, "tests", graphql_server_SUITE}.
{suites, "tests", graphql_metric_SUITE}.

{suites, "tests", instrument_cets_SUITE}.
{suites, "tests", instrument_SUITE}.

{suites, "tests", inbox_SUITE}.
{suites, "tests", inbox_extensions_SUITE}.
Expand Down
4 changes: 1 addition & 3 deletions big_tests/tests/cets_disco_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,7 @@ start_cets_discovery_with_file_backnend(Config) ->

stop_cets_discovery() ->
ok = rpc(mim(), supervisor, terminate_child, [ejabberd_sup, cets_discovery]),
ok = rpc(mim2(), supervisor, terminate_child, [ejabberd_sup, cets_discovery]),
rpc(mim(), mongoose_instrument_probe_cets, stop, []),
rpc(mim2(), mongoose_instrument_probe_cets, stop, []).
ok = rpc(mim2(), supervisor, terminate_child, [ejabberd_sup, cets_discovery]).

stop_and_delete_cets_discovery() ->
stop_cets_discovery(),
Expand Down
35 changes: 26 additions & 9 deletions big_tests/tests/cluster_commands_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,21 @@ init_per_suite(Config) ->
NodeCtlPath = distributed_helper:ctl_path(Node1, Config3),
Node2CtlPath = distributed_helper:ctl_path(Node2, Config3),
Node3CtlPath = distributed_helper:ctl_path(Node3, Config3),
escalus:init_per_suite([{ctl_path_atom(Node1), NodeCtlPath},
{ctl_path_atom(Node2), Node2CtlPath},
{ctl_path_atom(Node3), Node3CtlPath}]
++ Config3).
Config4 = escalus:init_per_suite([{ctl_path_atom(Node1), NodeCtlPath},
{ctl_path_atom(Node2), Node2CtlPath},
{ctl_path_atom(Node3), Node3CtlPath}]
++ Config3),
Config5 = mongoose_helper:backup_and_set_config_option(
Config4, [instrumentation, probe_interval], 1),
restart(mongoose_system_probes),
instrument_helper:start([{system_dist_data, #{}}]),
Config5.

end_per_suite(Config) ->
escalus:end_per_suite(Config).
mongoose_helper:restore_config_option(Config, [instrumentation, probe_interval]),
restart(mongoose_system_probes),
escalus:end_per_suite(Config),
instrument_helper:stop().

init_per_group(Group, Config) when Group == clustered orelse Group == mnesia ->
Node2 = mim2(),
Expand Down Expand Up @@ -164,10 +172,10 @@ end_per_testcase(CaseName, Config) ->
%% Message tests
%%--------------------------------------------------------------------

one_to_one_message(ConfigIn) ->
one_to_one_message(Config) ->
%% Given Alice connected to node one and ClusterGuy connected to node two
Metrics = [{[global, data, dist], [{recv_oct, '>'}, {send_oct, '>'}]}],
Config = [{mongoose_metrics, Metrics} | ConfigIn],
#{send_oct := InitialSendOct, recv_oct := InitialRecvOct}
= rpc(mim(), mongoose_system_probes, probe, [system_dist_data, #{}]),
escalus:story(Config, [{alice, 1}, {clusterguy, 1}], fun(Alice, ClusterGuy) ->
%% When Alice sends a message to ClusterGuy
Msg1 = escalus_stanza:chat_to(ClusterGuy, <<"Hi!">>),
Expand All @@ -182,7 +190,12 @@ one_to_one_message(ConfigIn) ->
%% Then Alice also receives it
Stanza2 = escalus:wait_for_stanza(Alice, 5000),
escalus:assert(is_chat_message, [<<"Oh hi!">>], Stanza2)
end).
end),
instrument_helper:wait_and_assert(
system_dist_data, #{},
fun(#{send_oct := SendOct, recv_oct := RecvOct}) ->
SendOct > InitialSendOct andalso RecvOct > InitialRecvOct
end).

%%--------------------------------------------------------------------
%% Manage cluster commands tests
Expand Down Expand Up @@ -469,3 +482,7 @@ wait_for_process_to_stop(Pid, Timeout) ->
after Timeout ->
ct:fail(wait_for_process_to_stop_timeout)
end.

restart(Module) ->
rpc(mim(), Module, stop, []),
rpc(mim(), Module, start, []).
58 changes: 20 additions & 38 deletions big_tests/tests/graphql_metric_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -119,38 +119,23 @@ type_to_keys(<<"counter">>) ->
type_to_keys(<<"spiral">>) ->
[<<"one">>, <<"count">>];
type_to_keys(<<"gauge">>) ->
[<<"value">>];
type_to_keys(<<"merged_inet_stats">>) ->
[<<"connections">>, <<"recv_cnt">>, <<"recv_max">>, <<"recv_oct">>,
<<"send_cnt">>, <<"send_max">>, <<"send_oct">>, <<"send_pend">>];
type_to_keys(<<"rdbms_stats">>) ->
[<<"workers">>, <<"recv_cnt">>, <<"recv_max">>, <<"recv_oct">>,
<<"send_cnt">>, <<"send_max">>, <<"send_oct">>, <<"send_pend">>];
type_to_keys(<<"vm_stats_memory">>) ->
[<<"atom_used">>, <<"binary">>, <<"ets">>,
<<"processes_used">>, <<"system">>, <<"total">>];
type_to_keys(<<"vm_system_info">>) ->
[<<"ets_limit">>, <<"port_count">>, <<"port_limit">>,
<<"process_count">>, <<"process_limit">>];
type_to_keys(<<"probe_queues">>) ->
[<<"fsm">>, <<"regular">>, <<"total">>].
[<<"value">>].

cets_info_keys() ->
[<<"available_nodes">>, <<"unavailable_nodes">>,
<<"remote_nodes_without_disco">>, <<"joined_nodes">>,
<<"remote_nodes_with_unknown_tables">>, <<"remote_unknown_tables">>,
<<"remote_nodes_with_missing_tables">>, <<"remote_missing_tables">>,
<<"conflict_nodes">>, <<"conflict_tables">>,
<<"discovered_nodes">>, <<"discovery_works">>].
<<"remote_nodes_without_disco">>, <<"joined_nodes">>,
<<"remote_nodes_with_unknown_tables">>, <<"remote_unknown_tables">>,
<<"remote_nodes_with_missing_tables">>, <<"remote_missing_tables">>,
<<"conflict_nodes">>, <<"conflict_tables">>,
<<"discovered_nodes">>, <<"discovery_works">>].

get_by_name_global_erlang_metrics(Config) ->
%% Filter by name works
Result = get_metrics([<<"global">>, <<"erlang">>], Config),
Result = get_metrics([<<"global">>, <<"system_info">>], Config),
ParsedResult = get_ok_value([data, metric, getMetrics], Result),
Map = maps:from_list([{Name, X} || X = #{<<"name">> := Name} <- ParsedResult]),
Info = maps:get([<<"global">>, <<"erlang">>, <<"system_info">>], Map),
%% VMSystemInfoMetric type
#{<<"type">> := <<"vm_system_info">>} = Info,
Info = maps:get([<<"global">>, <<"system_info">>, <<"port_count">>], Map),
#{<<"type">> := <<"counter">>} = Info,
check_metric_by_type(Info),
%% Other metrics are filtered out
undef = maps:get(roster_reads_key(), Map, undef).
Expand Down Expand Up @@ -178,30 +163,27 @@ get_metrics_for_specific_host_type(Config) ->
[_|_] = ParsedResult.

get_process_queue_length(Config) ->
Result = get_metrics([<<"global">>, <<"processQueueLengths">>], Config),
Result = get_metrics([<<"global">>, <<"system_process_queue_lengths">>], Config),
ParsedResult = get_ok_value([data, metric, getMetrics], Result),
Map = maps:from_list([{Name, X} || X = #{<<"name">> := Name} <- ParsedResult]),
Lens = maps:get([<<"global">>, <<"processQueueLengths">>], Map),
%% ProbeQueuesMetric type
#{<<"type">> := <<"probe_queues">>} = Lens,
Lens = maps:get([<<"global">>, <<"system_process_queue_lengths">>, <<"total">>], Map),
#{<<"type">> := <<"counter">>} = Lens,
check_metric_by_type(Lens).

get_inet_stats(Config) ->
Result = get_metrics([<<"global">>, <<"data">>, <<"dist">>], Config),
Result = get_metrics([<<"global">>, <<"system_dist_data">>], Config),
ParsedResult = get_ok_value([data, metric, getMetrics], Result),
Map = maps:from_list([{Name, X} || X = #{<<"name">> := Name} <- ParsedResult]),
Stats = maps:get([<<"global">>, <<"data">>, <<"dist">>], Map),
%% MergedInetStatsMetric type
#{<<"type">> := <<"merged_inet_stats">>} = Stats,
Stats = maps:get([<<"global">>, <<"system_dist_data">>, <<"connections">>], Map),
#{<<"type">> := <<"counter">>} = Stats,
check_metric_by_type(Stats).

get_vm_stats_memory(Config) ->
Result = get_metrics([<<"global">>], Config),
ParsedResult = get_ok_value([data, metric, getMetrics], Result),
Map = maps:from_list([{Name, X} || X = #{<<"name">> := Name} <- ParsedResult]),
Mem = maps:get([<<"global">>, <<"erlang">>, <<"memory">>], Map),
%% VMStatsMemoryMetric type
#{<<"type">> := <<"vm_stats_memory">>} = Mem,
Mem = maps:get([<<"global">>, <<"system_memory">>, <<"total">>], Map),
#{<<"type">> := <<"counter">>} = Mem,
check_metric_by_type(Mem).

get_cets_system(Config) ->
Expand Down Expand Up @@ -265,17 +247,17 @@ get_metrics_as_dicts_empty_args(Config) ->
[#{<<"key">> := <<"median">>, <<"value">> := Median}] = maps:get(RecvName, Map),
?assert(is_integer(Median)),
%% Empty keys
Result2 = get_metrics_as_dicts([<<"global">>, <<"erlang">>], [], Config),
Result2 = get_metrics_as_dicts([<<"global">>, <<"system_info">>], [], Config),
ParsedResult2 = get_ok_value([data, metric, getMetricsAsDicts], Result2),
?assertEqual(length(ParsedResult2), 2).
?assertEqual(6, length(ParsedResult2)).

get_metrics_as_dicts_empty_strings(Config) ->
%% Name is an empty string
Result = get_metrics_as_dicts([<<>>], [<<"median">>], Config),
ParsedResult = get_ok_value([data, metric, getMetricsAsDicts], Result),
[] = ParsedResult,
%% Key is an empty string
Result2 = get_metrics_as_dicts([<<"global">>, <<"erlang">>], [<<>>], Config),
Result2 = get_metrics_as_dicts([<<"global">>, <<"system_info">>], [<<>>], Config),
ParsedResult2 = get_ok_value([data, metric, getMetricsAsDicts], Result2),
[_|_] = ParsedResult2.

Expand Down
Loading

0 comments on commit a9882a2

Please sign in to comment.