Просмотр исходного кода

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.
Andrew Mayorov 3 лет назад
Родитель
Сommit
41a4e41d0c
1 измененных файлов с 12 добавлено и 5 удалено
  1. 12 5
      apps/emqx_management/test/emqx_mgmt_api_trace_SUITE.erl

+ 12 - 5
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,