Skip to content

Commit

Permalink
Merge pull request #3514 from esl/fix_async_pool_metric
Browse files Browse the repository at this point in the history
Fix async metrics test
  • Loading branch information
chrzaszcz committed Jan 25, 2022
2 parents a0e9c6a + 717ef07 commit c9b7d21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit c9b7d21

Please sign in to comment.