Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix async metrics test #3514

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3084,10 +3084,12 @@ metric_incremented_on_archive_request(ConfigIn) ->
escalus_fresh:story(Config, [{alice, 1}], F).

metrics_incremented_for_async_pools(Config) ->
Val0 = get_mongoose_async_metrics(),
OldValue = get_mongoose_async_metrics(),
archived(Config),
Val1 = get_mongoose_async_metrics(),
?assert_equal(false, Val0 =:= Val1).
Validator = fun(NewValue) -> OldValue =/= NewValue end,
mongoose_helper:wait_until(
fun get_mongoose_async_metrics/0,
true, #{validator => Validator, name => ?FUNCTION_NAME}).

get_mongoose_async_metrics() ->
HostType = domain_helper:host_type(mim),
Expand Down
5 changes: 4 additions & 1 deletion src/mongoose_batch_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ init({HostType, PoolId, Interval, MaxSize, FlushCallback, FlushExtra}) ->
flush_extra = FlushExtra}}.

-spec handle_call(term(), {pid(), term()}, state()) -> {reply, term(), state()}.
handle_call(sync, _From, State = #state{flush_queue = [_|_]}) ->
handle_call(sync, _From, State = #state{host_type = HostType,
pool_id = PoolId,
flush_queue = [_|_]}) ->
mongoose_metrics:update(HostType, [mongoose_async_pools, PoolId, timed_flushes], 1),
{reply, ok, run_flush(State)};
handle_call(sync, _From, State = #state{flush_queue = []}) ->
{reply, skipped, State};
Expand Down