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.
This commit is contained in:
Andrew Mayorov 2022-12-14 12:39:24 +03:00
parent 4f00f0968d
commit 41a4e41d0c
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
1 changed files with 12 additions and 5 deletions

View File

@ -209,20 +209,27 @@ t_log_file(_Config) ->
?assertMatch([#{<<"mtime">> := _, <<"size">> := _, <<"node">> := _}], json(Detail)), ?assertMatch([#{<<"mtime">> := _, <<"size">> := _, <<"node">> := _}], json(Detail)),
{ok, Binary} = request_api(get, api_path("trace/test_client_id/download"), Header), {ok, Binary} = request_api(get, api_path("trace/test_client_id/download"), Header),
{ok, [ {ok, [
_Comment, Comment,
#zip_file{ #zip_file{
name = ZipName, name = ZipName,
info = #file_info{size = Size, type = regular, access = read_write} info = #file_info{size = Size, type = regular, access = read_write}
} }
]} = ]} = zip:table(Binary),
ZipTab =
zip:table(Binary),
?assert(Size > 0), ?assert(Size > 0),
ZipNamePrefix = lists:flatten(io_lib:format("~s-trace_~s", [node(), Name])), ZipNamePrefix = lists:flatten(io_lib:format("~s-trace_~s", [node(), Name])),
?assertNotEqual(nomatch, re:run(ZipName, [ZipNamePrefix])), ?assertNotEqual(nomatch, re:run(ZipName, [ZipNamePrefix])),
Path = api_path("trace/test_client_id/download?node=" ++ atom_to_list(node())), Path = api_path("trace/test_client_id/download?node=" ++ atom_to_list(node())),
{ok, Binary2} = request_api(get, Path, Header), {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, _}, _} = {error, {_, 400, _}, _} =
request_api( request_api(
get, get,