test(listen): stabilize flaky testcase
This commit is contained in:
parent
baf46c9aa2
commit
a6c26ce992
|
@ -83,6 +83,28 @@
|
||||||
end)()
|
end)()
|
||||||
).
|
).
|
||||||
|
|
||||||
|
-define(assertExceptionOneOf(CT1, CT2, EXPR),
|
||||||
|
(fun() ->
|
||||||
|
X__Attrs = [
|
||||||
|
{module, ?MODULE},
|
||||||
|
{line, ?LINE},
|
||||||
|
{expression, (??EXPR)},
|
||||||
|
{pattern, "[ " ++ (??CT1) ++ ", " ++ (??CT2) ++ " ]"}
|
||||||
|
],
|
||||||
|
X__Exc =
|
||||||
|
try (EXPR) of
|
||||||
|
X__V -> erlang:error({assertException, [{unexpected_success, X__V} | X__Attrs]})
|
||||||
|
catch
|
||||||
|
X__C:X__T:X__S -> {X__C, X__T, X__S}
|
||||||
|
end,
|
||||||
|
case {element(1, X__Exc), element(2, X__Exc)} of
|
||||||
|
CT1 -> ok;
|
||||||
|
CT2 -> ok;
|
||||||
|
_ -> erlang:error({assertException, [{unexpected_exception, X__Exc} | X__Attrs]})
|
||||||
|
end
|
||||||
|
end)()
|
||||||
|
).
|
||||||
|
|
||||||
-define(retrying(CONFIG, NUM_RETRIES, TEST_BODY_FN), begin
|
-define(retrying(CONFIG, NUM_RETRIES, TEST_BODY_FN), begin
|
||||||
__TEST_CASE = ?FUNCTION_NAME,
|
__TEST_CASE = ?FUNCTION_NAME,
|
||||||
(fun
|
(fun
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
-include_lib("emqx/include/emqx.hrl").
|
-include_lib("emqx/include/emqx.hrl").
|
||||||
-include_lib("emqx/include/emqx_schema.hrl").
|
-include_lib("emqx/include/emqx_schema.hrl").
|
||||||
|
-include_lib("emqx/include/asserts.hrl").
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
-include_lib("common_test/include/ct.hrl").
|
-include_lib("common_test/include/ct.hrl").
|
||||||
|
|
||||||
|
@ -247,8 +248,9 @@ t_ssl_update_opts(Config) ->
|
||||||
),
|
),
|
||||||
|
|
||||||
%% Unable to connect with old SSL options, certificate is now required.
|
%% Unable to connect with old SSL options, certificate is now required.
|
||||||
?assertError(
|
?assertExceptionOneOf(
|
||||||
{ssl_error, _Socket, {tls_alert, {certificate_required, _}}},
|
{error, {ssl_error, _Socket, {tls_alert, {certificate_required, _}}}},
|
||||||
|
{error, closed},
|
||||||
emqtt_connect_ssl(Host, Port, [
|
emqtt_connect_ssl(Host, Port, [
|
||||||
{cacertfile, filename:join(PrivDir, "ca-next.pem")} | ClientSSLOpts
|
{cacertfile, filename:join(PrivDir, "ca-next.pem")} | ClientSSLOpts
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue