Skip to content

Commit

Permalink
Test that the metric can be fetched
Browse files Browse the repository at this point in the history
Note that escalus_mongooseim doesn't currently support exometer
counters, which is an insane fail, but anyway, out of the scope of this
PR, so here I do the fetching manually.
  • Loading branch information
NelsonVides committed Jan 17, 2022
1 parent d6d522f commit 4572526
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
check_user_exist/1,
metric_incremented_on_archive_request/1,
metric_incremented_when_store_message/1,
metrics_incremented_for_async_pools/1,
archive_chat_markers/1,
dont_archive_chat_markers/1,
save_unicode_messages/1,
Expand Down Expand Up @@ -400,7 +401,9 @@ muc_text_search_cases() ->

archived_cases() ->
[archived,
filter_forwarded].
filter_forwarded,
metrics_incremented_for_async_pools
].

stanzaid_cases() ->
[message_with_stanzaid,
Expand Down Expand Up @@ -888,6 +891,13 @@ end_state(C, muc_light, Config) ->
end_state(_, _, Config) ->
Config.

init_per_testcase(C=metrics_incremented_for_async_pools, Config) ->
case ?config(configuration, Config) of
rdbms_async_pool ->
escalus:init_per_testcase(C, clean_archives(Config));
_ ->
{skip, "Not an async-pool test"}
end;
init_per_testcase(C=metric_incremented_when_store_message, ConfigIn) ->
Config = case ?config(configuration, ConfigIn) of
rdbms_async_pool ->
Expand Down Expand Up @@ -3074,6 +3084,24 @@ metric_incremented_on_archive_request(ConfigIn) ->
Config = [{mongoose_metrics, MongooseMetrics} | ConfigIn],
escalus_fresh:story(Config, [{alice, 1}], F).

metrics_incremented_for_async_pools(Config) ->
Val0 = get_mongoose_async_metrics(),
archived(Config),
Val1 = get_mongoose_async_metrics(),
?assert_equal(false, Val0 =:= Val1).

get_mongoose_async_metrics() ->
HostType = domain_helper:host_type(mim),
HostTypePrefix = domain_helper:make_metrics_prefix(HostType),
#{batch_flushes => get_mongoose_async_metrics(HostTypePrefix, batch_flushes),
timed_flushes => get_mongoose_async_metrics(HostTypePrefix, timed_flushes)}.

get_mongoose_async_metrics(HostTypePrefix, MetricName) ->
Metric = [HostTypePrefix, mongoose_async_pools, pm_mam, MetricName],
{ok, Value} = rpc(mim(), mongoose_metrics, get_metric_value, [Metric]),
{value, Count} = lists:keyfind(value, 1, Value),
Count.

metric_incremented_when_store_message(Config) ->
archived(Config).

Expand Down

0 comments on commit 4572526

Please sign in to comment.