test: fix expected result from timeout error

This commit is contained in:
Stefan Strigler 2023-01-23 16:42:23 +01:00
parent 8f3b1f8744
commit 2d62de5188
4 changed files with 28 additions and 28 deletions

View File

@ -19,8 +19,6 @@
-compile(export_all).
-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").
-include("emqx_resource.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
@ -772,7 +770,10 @@ t_healthy_timeout(_) ->
%% the ?TEST_RESOURCE always returns the `Mod:on_get_status/2` 300ms later.
#{health_check_interval => 200}
),
?assertError(timeout, emqx_resource:query(?ID, get_state, #{timeout => 1_000})),
?assertMatch(
{error, {resource_error, #{reason := timeout}}},
emqx_resource:query(?ID, get_state, #{timeout => 1_000})
),
?assertMatch({ok, _Group, #{status := disconnected}}, emqx_resource_manager:ets_lookup(?ID)),
ok = emqx_resource:remove_local(?ID).
@ -1583,8 +1584,8 @@ do_t_expiration_before_sending(QueryMode) ->
spawn_link(fun() ->
case QueryMode of
sync ->
?assertError(
timeout,
?assertMatch(
{error, {resource_error, #{reason := timeout}}},
emqx_resource:query(?ID, {inc_counter, 99}, #{timeout => TimeoutMS})
);
async ->
@ -1690,8 +1691,8 @@ do_t_expiration_before_sending_partial_batch(QueryMode) ->
spawn_link(fun() ->
case QueryMode of
sync ->
?assertError(
timeout,
?assertMatch(
{error, {resource_error, #{reason := timeout}}},
emqx_resource:query(?ID, {inc_counter, 199}, #{timeout => TimeoutMS})
);
async ->
@ -2043,8 +2044,8 @@ do_t_expiration_retry(IsBatch) ->
ResumeInterval * 2
),
spawn_link(fun() ->
?assertError(
timeout,
?assertMatch(
{error, {resource_error, #{reason := timeout}}},
emqx_resource:query(
?ID,
{inc_counter, 1},
@ -2127,8 +2128,8 @@ t_expiration_retry_batch_multiple_times(_Config) ->
),
TimeoutMS = 100,
spawn_link(fun() ->
?assertError(
timeout,
?assertMatch(
{error, {resource_error, #{reason := timeout}}},
emqx_resource:query(
?ID,
{inc_counter, 1},
@ -2137,8 +2138,8 @@ t_expiration_retry_batch_multiple_times(_Config) ->
)
end),
spawn_link(fun() ->
?assertError(
timeout,
?assertMatch(
{error, {resource_error, #{reason := timeout}}},
emqx_resource:query(
?ID,
{inc_counter, 2},

View File

@ -910,12 +910,10 @@ t_write_failure(Config) ->
sync ->
{_, {ok, _}} =
?wait_async_action(
try
?assertMatch(
{error, {resource_error, #{reason := timeout}}},
send_message(Config, SentData)
catch
error:timeout ->
{error, timeout}
end,
),
#{?snk_kind := buffer_worker_flush_nack},
1_000
);

View File

@ -406,7 +406,10 @@ t_write_failure(Config) ->
emqx_common_test_helpers:with_failure(down, ProxyName, ProxyHost, ProxyPort, fun() ->
case QueryMode of
sync ->
?assertError(timeout, send_message(Config, SentData));
?assertMatch(
{error, {resource_error, #{reason := timeout}}},
send_message(Config, SentData)
);
async ->
send_message(Config, SentData)
end
@ -439,8 +442,8 @@ t_write_timeout(Config) ->
SentData = #{payload => Val, timestamp => 1668602148000},
Timeout = 1000,
emqx_common_test_helpers:with_failure(timeout, ProxyName, ProxyHost, ProxyPort, fun() ->
?assertError(
timeout,
?assertMatch(
{error, {resource_error, #{reason := timeout}}},
query_resource(Config, {send_message, SentData, [], Timeout})
)
end),

View File

@ -426,12 +426,7 @@ t_write_failure(Config) ->
?wait_async_action(
case QueryMode of
sync ->
try
send_message(Config, SentData)
catch
error:timeout ->
{error, timeout}
end;
?assertMatch({error, _}, send_message(Config, SentData));
async ->
send_message(Config, SentData)
end,
@ -467,7 +462,10 @@ t_write_timeout(Config) ->
SentData = #{payload => Val, timestamp => 1668602148000},
Timeout = 1000,
emqx_common_test_helpers:with_failure(timeout, ProxyName, ProxyHost, ProxyPort, fun() ->
?assertError(timeout, query_resource(Config, {send_message, SentData, [], Timeout}))
?assertMatch(
{error, {resource_error, #{reason := timeout}}},
query_resource(Config, {send_message, SentData, [], Timeout})
)
end),
ok.