From 41a4e41d0c221b6b617e44ba5692583e7d3ba547 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Wed, 14 Dec 2022 12:39:24 +0300 Subject: [PATCH] fix(ct): prevent testcase flapping Testcase `t_log_file` was flapping when run happened to pass through boundary of a second. Archive files' `ctime`s could differ between consecutive archive downloads. --- .../test/emqx_mgmt_api_trace_SUITE.erl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/emqx_management/test/emqx_mgmt_api_trace_SUITE.erl b/apps/emqx_management/test/emqx_mgmt_api_trace_SUITE.erl index d73cb79fd..d0f22f134 100644 --- a/apps/emqx_management/test/emqx_mgmt_api_trace_SUITE.erl +++ b/apps/emqx_management/test/emqx_mgmt_api_trace_SUITE.erl @@ -209,20 +209,27 @@ t_log_file(_Config) -> ?assertMatch([#{<<"mtime">> := _, <<"size">> := _, <<"node">> := _}], json(Detail)), {ok, Binary} = request_api(get, api_path("trace/test_client_id/download"), Header), {ok, [ - _Comment, + Comment, #zip_file{ name = ZipName, info = #file_info{size = Size, type = regular, access = read_write} } - ]} = - ZipTab = - zip:table(Binary), + ]} = zip:table(Binary), ?assert(Size > 0), ZipNamePrefix = lists:flatten(io_lib:format("~s-trace_~s", [node(), Name])), ?assertNotEqual(nomatch, re:run(ZipName, [ZipNamePrefix])), Path = api_path("trace/test_client_id/download?node=" ++ atom_to_list(node())), {ok, Binary2} = request_api(get, Path, Header), - ?assertEqual(ZipTab, zip:table(Binary2)), + ?assertMatch( + {ok, [ + Comment, + #zip_file{ + name = ZipName, + info = #file_info{size = Size, type = regular, access = read_write} + } + ]}, + zip:table(Binary2) + ), {error, {_, 400, _}, _} = request_api( get,