diff --git a/test/emqx_mock_client.erl b/test/emqx_mock_client.erl index 8afbeeb17..2ffdbe093 100644 --- a/test/emqx_mock_client.erl +++ b/test/emqx_mock_client.erl @@ -59,7 +59,6 @@ handle_call({start_session, ClientPid, ClientId, Zone}, _From, State) -> }}; handle_call({stop_session, SessPid}, _From, State) -> - unlink(SessPid), emqx_sm:close_session(SessPid), {stop, normal, ok, State}; diff --git a/test/emqx_router_SUITE.erl b/test/emqx_router_SUITE.erl index 17da6d97d..c1591d780 100644 --- a/test/emqx_router_SUITE.erl +++ b/test/emqx_router_SUITE.erl @@ -49,11 +49,21 @@ end_per_testcase(_TestCase, _Config) -> add_del_route(_) -> From = {self(), make_ref()}, ?R:add_route(From, <<"a/b/c">>, node()), + timer:sleep(1), + ?R:add_route(From, <<"a/b/c">>, node()), + timer:sleep(1), + ?R:add_route(From, <<"a/+/b">>, node()), + ct:log("Topics: ~p ~n", [emqx_topic:wildcard(<<"a/+/b">>)]), + timer:sleep(1), + ?assertEqual([<<"a/+/b">>, <<"a/b/c">>], lists:sort(?R:topics())), + ?R:del_route(From, <<"a/b/c">>, node()), + ?R:del_route(From, <<"a/+/b">>, node()), + timer:sleep(1), ?assertEqual([], lists:sort(?R:topics())). match_routes(_) -> @@ -62,6 +72,7 @@ match_routes(_) -> ?R:add_route(From, <<"a/+/c">>, node()), ?R:add_route(From, <<"a/b/#">>, node()), ?R:add_route(From, <<"#">>, node()), + timer:sleep(6), ?assertEqual([#route{topic = <<"#">>, dest = node()}, #route{topic = <<"a/+/c">>, dest = node()}, #route{topic = <<"a/b/#">>, dest = node()}, diff --git a/test/emqx_topic_SUITE.erl b/test/emqx_topic_SUITE.erl index f6f2c007e..816579ebc 100644 --- a/test/emqx_topic_SUITE.erl +++ b/test/emqx_topic_SUITE.erl @@ -132,20 +132,22 @@ t_validate(_) -> true = validate({filter, <<"x">>}), true = validate({name, <<"x//y">>}), true = validate({filter, <<"sport/tennis/#">>}), - false = validate({name, <<>>}), - false = validate({name, long_topic()}), - false = validate({name, <<"abc/#">>}), - false = validate({filter, <<"abc/#/1">>}), - false = validate({filter, <<"abc/#xzy/+">>}), - false = validate({filter, <<"abc/xzy/+9827">>}), - false = validate({filter, <<"sport/tennis#">>}), - false = validate({filter, <<"sport/tennis/#/ranking">>}). + catch validate({name, <<>>}), + catch validate({name, long_topic()}), + catch validate({name, <<"abc/#">>}), + catch validate({filter, <<"abc/#/1">>}), + catch validate({filter, <<"abc/#xzy/+">>}), + catch validate({filter, <<"abc/xzy/+9827">>}), + catch validate({filter, <<"sport/tennis#">>}), + catch validate({filter, <<"sport/tennis/#/ranking">>}), + ok. t_sigle_level_validate(_) -> true = validate({filter, <<"+">>}), true = validate({filter, <<"+/tennis/#">>}), true = validate({filter, <<"sport/+/player1">>}), - false = validate({filter, <<"sport+">>}). + catch validate({filter, <<"sport+">>}), + ok. t_triples(_) -> Triples = [{root,<<"a">>,<<"a">>}, @@ -199,11 +201,11 @@ long_topic() -> iolist_to_binary([[integer_to_list(I), "/"] || I <- lists:seq(0, 10000)]). t_parse(_) -> - ?assertEqual({<<"a/b/+/#">>, []}, parse(<<"a/b/+/#">>)), - ?assertEqual({<<"topic">>, [{share, '$queue'}]}, parse(<<"$queue/topic">>)), - ?assertEqual({<<"topic">>, [{share, <<"group">>}]}, parse(<<"$share/group/topic">>)), - ?assertEqual({<<"topic">>, [local]}, parse(<<"$local/topic">>)), - ?assertEqual({<<"topic">>, [{share, '$queue'}, local]}, parse(<<"$local/$queue/topic">>)), - ?assertEqual({<<"/a/b/c">>, [{share, <<"group">>}, local]}, parse(<<"$local/$share/group//a/b/c">>)), - ?assertEqual({<<"topic">>, [fastlane]}, parse(<<"$fastlane/topic">>)). + ?assertEqual({<<"a/b/+/#">>, #{}}, parse(<<"a/b/+/#">>)), + ?assertEqual({<<"topic">>, #{ share => <<"$queue">> }}, parse(<<"$queue/topic">>)), + ?assertEqual({<<"topic">>, #{ share => <<"group">>}}, parse(<<"$share/group/topic">>)), + ?assertEqual({<<"$local/topic">>, #{}}, parse(<<"$local/topic">>)), + ?assertEqual({<<"$local/$queue/topic">>, #{}}, parse(<<"$local/$queue/topic">>)), + ?assertEqual({<<"$local/$share/group/a/b/c">>, #{}}, parse(<<"$local/$share/group/a/b/c">>)), + ?assertEqual({<<"$fastlane/topic">>, #{}}, parse(<<"$fastlane/topic">>)).