From 366c75795997b014ba2a81471dc06b79d2251d30 Mon Sep 17 00:00:00 2001 From: Tobias Lindahl Date: Mon, 6 Dec 2021 10:42:19 +0100 Subject: [PATCH 1/3] test(flaky_tests): fix persistent_session_SUITE Increase timeout on message receive and ensure more info when the test fails. --- apps/emqx/test/emqx_persistent_session_SUITE.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/emqx/test/emqx_persistent_session_SUITE.erl b/apps/emqx/test/emqx_persistent_session_SUITE.erl index fd9640aeb..756f7bb97 100644 --- a/apps/emqx/test/emqx_persistent_session_SUITE.erl +++ b/apps/emqx/test/emqx_persistent_session_SUITE.erl @@ -245,7 +245,7 @@ receive_messages(Count, Msgs) -> receive_messages(Count-1, [Msg|Msgs]); _Other -> receive_messages(Count, Msgs) - after 1000 -> + after 5000 -> Msgs end. @@ -576,7 +576,7 @@ t_publish_while_client_is_gone(Config) -> | Config]), {ok, _} = emqtt:ConnFun(Client2), Msgs = receive_messages(2), - ?assertEqual(length(Msgs), 2), + ?assertMatch([_, _], Msgs), [Msg2, Msg1] = Msgs, ?assertEqual({ok, iolist_to_binary(Payload1)}, maps:find(payload, Msg1)), ?assertEqual({ok, 2}, maps:find(qos, Msg1)), From e62b094f3b84f6f002f83011b98ab1044cabd506 Mon Sep 17 00:00:00 2001 From: Tobias Lindahl Date: Mon, 6 Dec 2021 11:16:20 +0100 Subject: [PATCH 2/3] test(snabbkaffe): Update to latest snabbkaffe In particular, this should remove the flaky snabbkaffe failures in persistent session SUITE where the snabbkaffe_nemesis is trying to make an ets:lookup in a table that no longer exists. --- apps/emqx/rebar.config | 2 +- rebar.config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/emqx/rebar.config b/apps/emqx/rebar.config index 5adcbd3bb..f8c6c23ce 100644 --- a/apps/emqx/rebar.config +++ b/apps/emqx/rebar.config @@ -20,7 +20,7 @@ , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.22.0"}}} , {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}} , {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}} - , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.15.0"}}} + , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.16.0"}}} ]}. {plugins, [{rebar3_proper, "0.12.1"}]}. diff --git a/rebar.config b/rebar.config index 33c1244d2..b923bb936 100644 --- a/rebar.config +++ b/rebar.config @@ -63,7 +63,7 @@ , {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.4"}}} , {observer_cli, "1.7.1"} % NOTE: depends on recon 2.5.x , {getopt, "1.0.2"} - , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.15.0"}}} + , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.16.0"}}} , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.22.0"}}} , {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.4.1"}}} , {esasl, {git, "https://github.com/emqx/esasl", {tag, "0.2.0"}}} From 6ed3dbd39b1e0c0fdee743ed404c6f840bf2aa04 Mon Sep 17 00:00:00 2001 From: Tobias Lindahl Date: Mon, 6 Dec 2021 12:40:58 +0100 Subject: [PATCH 3/3] test(persistent_session_SUITE): protect against non-atom sinks --- apps/emqx/test/emqx_persistent_session_SUITE.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/emqx/test/emqx_persistent_session_SUITE.erl b/apps/emqx/test/emqx_persistent_session_SUITE.erl index 756f7bb97..0fa73ebe2 100644 --- a/apps/emqx/test/emqx_persistent_session_SUITE.erl +++ b/apps/emqx/test/emqx_persistent_session_SUITE.erl @@ -768,7 +768,7 @@ t_lost_messages_because_of_gc(Config) -> check_snabbkaffe_vanilla(Trace) -> ResumeTrace = [T || #{?snk_kind := K} = T <- Trace, - re:run(atom_to_list(K), "^ps_") /= nomatch], + re:run(to_list(K), "^ps_") /= nomatch], ?assertMatch([_|_], ResumeTrace), [_Sid] = lists:usort(?projection(sid, ResumeTrace)), %% Check internal flow of the emqx_cm resuming @@ -811,6 +811,10 @@ check_snabbkaffe_vanilla(Trace) -> [Markers] = ?projection(markers, ?of_kind(ps_node_markers, Trace)), ?assertMatch([_], Markers). +to_list(L) when is_list(L) -> L; +to_list(A) when is_atom(A) -> atom_to_list(A); +to_list(B) when is_binary(B) -> binary_to_list(B). + %%-------------------------------------------------------------------- %% Snabbkaffe tests %%--------------------------------------------------------------------