test(emqx_mgmt_api_trace_SUITE): fix bad test cases
This commit is contained in:
parent
76ccef7ce3
commit
b9cd75eef0
|
@ -290,54 +290,125 @@ t_http_test_json_formatter(_Config) ->
|
||||||
end
|
end
|
||||||
|| JSONEntry <- LogEntries
|
|| JSONEntry <- LogEntries
|
||||||
],
|
],
|
||||||
|
ListIterFun =
|
||||||
|
fun
|
||||||
|
ListIterFunRec([]) ->
|
||||||
|
ok;
|
||||||
|
ListIterFunRec([Item | Rest]) ->
|
||||||
|
receive
|
||||||
|
From ->
|
||||||
|
From ! {list_iter_item, Item}
|
||||||
|
end,
|
||||||
|
ListIterFunRec(Rest)
|
||||||
|
end,
|
||||||
|
ListIter = spawn_link(fun() -> ListIterFun(DecodedLogEntries) end),
|
||||||
|
NextFun =
|
||||||
|
fun() ->
|
||||||
|
ListIter ! self(),
|
||||||
|
receive
|
||||||
|
{list_iter_item, Item} ->
|
||||||
|
Item
|
||||||
|
end
|
||||||
|
end,
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
[
|
#{<<"meta">> := #{<<"payload">> := <<"log_this_message">>}},
|
||||||
#{<<"meta">> := #{<<"payload">> := <<"log_this_message">>}},
|
NextFun()
|
||||||
#{<<"meta">> := #{<<"payload">> := <<"\nlog\nthis\nmessage">>}},
|
),
|
||||||
#{
|
?assertMatch(
|
||||||
<<"meta">> := #{<<"payload">> := <<"\\\nlog\n_\\n_this\nmessage\\">>}
|
#{<<"meta">> := #{<<"payload">> := <<"\nlog\nthis\nmessage">>}},
|
||||||
},
|
NextFun()
|
||||||
#{<<"meta">> := #{<<"payload">> := <<"\"log_this_message\"">>}},
|
),
|
||||||
#{<<"meta">> := #{<<"str">> := <<"str">>}},
|
?assertMatch(
|
||||||
#{<<"meta">> := #{<<"term">> := <<"{notjson}">>}},
|
#{
|
||||||
#{<<"meta">> := <<_/binary>>},
|
<<"meta">> := #{<<"payload">> := <<"\\\nlog\n_\\n_this\nmessage\\">>}
|
||||||
#{<<"meta">> := #{<<"integer">> := 42}},
|
},
|
||||||
#{<<"meta">> := #{<<"float">> := 1.2}},
|
NextFun()
|
||||||
#{<<"meta">> := <<_/binary>>},
|
),
|
||||||
#{<<"meta">> := <<_/binary>>},
|
?assertMatch(
|
||||||
#{<<"meta">> := <<_/binary>>},
|
#{<<"meta">> := #{<<"payload">> := <<"\"log_this_message\"">>}},
|
||||||
#{<<"meta">> := #{<<"sub">> := #{}}},
|
NextFun()
|
||||||
#{<<"meta">> := #{<<"sub">> := #{<<"key">> := <<"value">>}}},
|
),
|
||||||
#{<<"meta">> := #{<<"true">> := <<"true">>, <<"false">> := <<"false">>}},
|
?assertMatch(
|
||||||
#{
|
#{<<"meta">> := #{<<"str">> := <<"str">>}},
|
||||||
<<"meta">> := #{
|
NextFun()
|
||||||
<<"list">> := #{
|
),
|
||||||
<<"key">> := <<"value">>,
|
?assertMatch(
|
||||||
<<"key2">> := <<"value2">>
|
#{<<"meta">> := #{<<"term">> := <<"{notjson}">>}},
|
||||||
}
|
NextFun()
|
||||||
}
|
),
|
||||||
},
|
?assertMatch(
|
||||||
#{
|
#{<<"meta">> := <<_/binary>>},
|
||||||
<<"meta">> := #{
|
NextFun()
|
||||||
<<"client_ids">> := [<<"a">>, <<"b">>, <<"c">>]
|
),
|
||||||
}
|
?assertMatch(
|
||||||
},
|
#{<<"meta">> := #{<<"integer">> := 42}},
|
||||||
#{
|
NextFun()
|
||||||
<<"meta">> := #{
|
),
|
||||||
<<"rule_ids">> := [<<"a">>, <<"b">>, <<"c">>]
|
?assertMatch(
|
||||||
}
|
#{<<"meta">> := #{<<"float">> := 1.2}},
|
||||||
},
|
NextFun()
|
||||||
#{
|
),
|
||||||
<<"meta">> := #{
|
?assertMatch(
|
||||||
<<"action_info">> := #{
|
#{<<"meta">> := <<_/binary>>},
|
||||||
<<"type">> := <<"http">>,
|
NextFun()
|
||||||
<<"name">> := <<"emqx_bridge_http_test_lib">>
|
),
|
||||||
}
|
?assertMatch(
|
||||||
|
#{<<"meta">> := <<_/binary>>},
|
||||||
|
NextFun()
|
||||||
|
),
|
||||||
|
?assertMatch(
|
||||||
|
#{<<"meta">> := <<_/binary>>},
|
||||||
|
NextFun()
|
||||||
|
),
|
||||||
|
?assertMatch(
|
||||||
|
#{<<"meta">> := #{<<"sub">> := #{}}},
|
||||||
|
NextFun()
|
||||||
|
),
|
||||||
|
?assertMatch(
|
||||||
|
#{<<"meta">> := #{<<"sub">> := #{<<"key">> := <<"value">>}}},
|
||||||
|
NextFun()
|
||||||
|
),
|
||||||
|
?assertMatch(
|
||||||
|
#{<<"meta">> := #{<<"true">> := true, <<"false">> := false}},
|
||||||
|
NextFun()
|
||||||
|
),
|
||||||
|
?assertMatch(
|
||||||
|
#{
|
||||||
|
<<"meta">> := #{
|
||||||
|
<<"list">> := #{
|
||||||
|
<<"key">> := <<"value">>,
|
||||||
|
<<"key2">> := <<"value2">>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| _
|
},
|
||||||
],
|
NextFun()
|
||||||
DecodedLogEntries
|
),
|
||||||
|
?assertMatch(
|
||||||
|
#{
|
||||||
|
<<"meta">> := #{
|
||||||
|
<<"client_ids">> := [<<"a">>, <<"b">>, <<"c">>]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
NextFun()
|
||||||
|
),
|
||||||
|
?assertMatch(
|
||||||
|
#{
|
||||||
|
<<"meta">> := #{
|
||||||
|
<<"rule_ids">> := [<<"a">>, <<"b">>, <<"c">>]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
NextFun()
|
||||||
|
),
|
||||||
|
?assertMatch(
|
||||||
|
#{
|
||||||
|
<<"meta">> := #{
|
||||||
|
<<"action_info">> := #{
|
||||||
|
<<"type">> := <<"http">>,
|
||||||
|
<<"name">> := <<"emqx_bridge_http_test_lib">>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
NextFun()
|
||||||
),
|
),
|
||||||
{ok, Delete} = request_api(delete, api_path("trace/" ++ binary_to_list(Name))),
|
{ok, Delete} = request_api(delete, api_path("trace/" ++ binary_to_list(Name))),
|
||||||
?assertEqual(<<>>, Delete),
|
?assertEqual(<<>>, Delete),
|
||||||
|
@ -495,7 +566,7 @@ create_trace(Name, Type, TypeValue, Start) ->
|
||||||
?block_until(#{?snk_kind := update_trace_done})
|
?block_until(#{?snk_kind := update_trace_done})
|
||||||
end,
|
end,
|
||||||
fun(Trace) ->
|
fun(Trace) ->
|
||||||
?assertMatch([#{}], ?of_kind(update_trace_done, Trace))
|
?assertMatch([#{} | _], ?of_kind(update_trace_done, Trace))
|
||||||
end
|
end
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue