Merge branch 'emq24'
This commit is contained in:
commit
85124242df
4
Makefile
4
Makefile
|
@ -8,9 +8,9 @@ dep_goldrush = git https://github.com/basho/goldrush 0.1.9
|
||||||
dep_gproc = git https://github.com/uwiger/gproc
|
dep_gproc = git https://github.com/uwiger/gproc
|
||||||
dep_getopt = git https://github.com/jcomellas/getopt v0.8.2
|
dep_getopt = git https://github.com/jcomellas/getopt v0.8.2
|
||||||
dep_lager = git https://github.com/basho/lager master
|
dep_lager = git https://github.com/basho/lager master
|
||||||
dep_esockd = git https://github.com/emqtt/esockd master
|
dep_esockd = git https://github.com/emqtt/esockd v5.1
|
||||||
dep_ekka = git https://github.com/emqtt/ekka master
|
dep_ekka = git https://github.com/emqtt/ekka master
|
||||||
dep_mochiweb = git https://github.com/emqtt/mochiweb master
|
dep_mochiweb = git https://github.com/emqtt/mochiweb v4.2.0
|
||||||
dep_pbkdf2 = git https://github.com/emqtt/pbkdf2 2.0.1
|
dep_pbkdf2 = git https://github.com/emqtt/pbkdf2 2.0.1
|
||||||
dep_lager_syslog = git https://github.com/basho/lager_syslog
|
dep_lager_syslog = git https://github.com/basho/lager_syslog
|
||||||
dep_bcrypt = git https://github.com/smarkets/erlang-bcrypt master
|
dep_bcrypt = git https://github.com/smarkets/erlang-bcrypt master
|
||||||
|
|
|
@ -58,7 +58,6 @@
|
||||||
all() ->
|
all() ->
|
||||||
[{group, protocol},
|
[{group, protocol},
|
||||||
{group, pubsub},
|
{group, pubsub},
|
||||||
{group, router},
|
|
||||||
{group, session},
|
{group, session},
|
||||||
{group, broker},
|
{group, broker},
|
||||||
{group, metrics},
|
{group, metrics},
|
||||||
|
@ -81,10 +80,6 @@ groups() ->
|
||||||
t_local_subscribe,
|
t_local_subscribe,
|
||||||
t_shared_subscribe,
|
t_shared_subscribe,
|
||||||
'pubsub#', 'pubsub+']},
|
'pubsub#', 'pubsub+']},
|
||||||
{router, [sequence],
|
|
||||||
[router_add_del,
|
|
||||||
router_print,
|
|
||||||
router_unused]},
|
|
||||||
{session, [sequence],
|
{session, [sequence],
|
||||||
[start_session]},
|
[start_session]},
|
||||||
{broker, [sequence],
|
{broker, [sequence],
|
||||||
|
@ -291,53 +286,6 @@ loop_recv(Topic, Timeout, Acc) ->
|
||||||
Timeout -> {ok, Acc}
|
Timeout -> {ok, Acc}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Router Test
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
|
|
||||||
router_add_del(_) ->
|
|
||||||
%% Add
|
|
||||||
emqttd_router:add_route(<<"#">>),
|
|
||||||
emqttd_router:add_route(<<"a/b/c">>),
|
|
||||||
emqttd_router:add_route(<<"+/#">>),
|
|
||||||
Routes = [R1, R2 | _] = [
|
|
||||||
#mqtt_route{topic = <<"#">>, node = node()},
|
|
||||||
#mqtt_route{topic = <<"+/#">>, node = node()},
|
|
||||||
#mqtt_route{topic = <<"a/b/c">>, node = node()}],
|
|
||||||
Routes = lists:sort(emqttd_router:match(<<"a/b/c">>)),
|
|
||||||
|
|
||||||
%% Batch Add
|
|
||||||
lists:foreach(fun(R) -> emqttd_router:add_route(R) end, Routes),
|
|
||||||
Routes = lists:sort(emqttd_router:match(<<"a/b/c">>)),
|
|
||||||
|
|
||||||
%% Del
|
|
||||||
emqttd_router:del_route(<<"a/b/c">>),
|
|
||||||
[R1, R2] = lists:sort(emqttd_router:match(<<"a/b/c">>)),
|
|
||||||
{atomic, []} = mnesia:transaction(fun emqttd_trie:lookup/1, [<<"a/b/c">>]),
|
|
||||||
|
|
||||||
%% Batch Del
|
|
||||||
R3 = #mqtt_route{topic = <<"#">>, node = 'a@127.0.0.1'},
|
|
||||||
emqttd_router:add_route(R3),
|
|
||||||
emqttd_router:del_route(R1),
|
|
||||||
emqttd_router:del_route(R2),
|
|
||||||
emqttd_router:del_route(R3),
|
|
||||||
[] = lists:sort(emqttd_router:match(<<"a/b/c">>)).
|
|
||||||
|
|
||||||
router_print(_) ->
|
|
||||||
Routes = [#mqtt_route{topic = <<"a/b/c">>, node = node()},
|
|
||||||
#mqtt_route{topic = <<"#">>, node = node()},
|
|
||||||
#mqtt_route{topic = <<"+/#">>, node = node()}],
|
|
||||||
lists:foreach(fun(R) -> emqttd_router:add_route(R) end, Routes),
|
|
||||||
emqttd_router:print(<<"a/b/c">>),
|
|
||||||
emqttd_router:del_route(<<"+/#">>),
|
|
||||||
emqttd_router:del_route(<<"a/b/c">>),
|
|
||||||
emqttd_router:del_route(<<"#">>).
|
|
||||||
|
|
||||||
router_unused(_) ->
|
|
||||||
gen_server:call(emqttd_router, bad_call),
|
|
||||||
gen_server:cast(emqttd_router, bad_msg),
|
|
||||||
emqttd_router ! bad_info.
|
|
||||||
|
|
||||||
recv_loop(Msgs) ->
|
recv_loop(Msgs) ->
|
||||||
receive
|
receive
|
||||||
{dispatch, _Topic, Msg} ->
|
{dispatch, _Topic, Msg} ->
|
||||||
|
|
|
@ -34,7 +34,8 @@ groups() ->
|
||||||
t_add_del_route,
|
t_add_del_route,
|
||||||
t_match_route,
|
t_match_route,
|
||||||
t_print,
|
t_print,
|
||||||
t_has_route]},
|
t_has_route,
|
||||||
|
router_unused]},
|
||||||
{local_route, [sequence],
|
{local_route, [sequence],
|
||||||
[t_get_local_topics,
|
[t_get_local_topics,
|
||||||
t_add_del_local_route,
|
t_add_del_local_route,
|
||||||
|
@ -86,11 +87,6 @@ t_match_route(_) ->
|
||||||
#mqtt_route{topic = <<"a/b/c">>, node = Node}],
|
#mqtt_route{topic = <<"a/b/c">>, node = Node}],
|
||||||
lists:sort(?R:match(<<"a/b/c">>))).
|
lists:sort(?R:match(<<"a/b/c">>))).
|
||||||
|
|
||||||
t_print(_) ->
|
|
||||||
?R:add_route(<<"topic">>),
|
|
||||||
?R:add_route(<<"topic/#">>),
|
|
||||||
?R:print(<<"topic">>).
|
|
||||||
|
|
||||||
t_has_route(_) ->
|
t_has_route(_) ->
|
||||||
?R:add_route(<<"devices/+/messages">>),
|
?R:add_route(<<"devices/+/messages">>),
|
||||||
?assert(?R:has_route(<<"devices/+/messages">>)).
|
?assert(?R:has_route(<<"devices/+/messages">>)).
|
||||||
|
@ -130,3 +126,49 @@ clear_tables() ->
|
||||||
?R:clean_local_routes(),
|
?R:clean_local_routes(),
|
||||||
lists:foreach(fun mnesia:clear_table/1, [mqtt_route, mqtt_trie, mqtt_trie_node]).
|
lists:foreach(fun mnesia:clear_table/1, [mqtt_route, mqtt_trie, mqtt_trie_node]).
|
||||||
|
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% Router Test
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
router_add_del(_) ->
|
||||||
|
%% Add
|
||||||
|
?R:add_route(<<"#">>),
|
||||||
|
?R:add_route(<<"a/b/c">>),
|
||||||
|
?R:add_route(<<"+/#">>),
|
||||||
|
Routes = [R1, R2 | _] = [
|
||||||
|
#mqtt_route{topic = <<"#">>, node = node()},
|
||||||
|
#mqtt_route{topic = <<"+/#">>, node = node()},
|
||||||
|
#mqtt_route{topic = <<"a/b/c">>, node = node()}],
|
||||||
|
Routes = lists:sort(?R:match(<<"a/b/c">>)),
|
||||||
|
|
||||||
|
%% Batch Add
|
||||||
|
lists:foreach(fun(R) -> ?R:add_route(R) end, Routes),
|
||||||
|
Routes = lists:sort(?R:match(<<"a/b/c">>)),
|
||||||
|
|
||||||
|
%% Del
|
||||||
|
?R:del_route(<<"a/b/c">>),
|
||||||
|
[R1, R2] = lists:sort(?R:match(<<"a/b/c">>)),
|
||||||
|
{atomic, []} = mnesia:transaction(fun emqttd_trie:lookup/1, [<<"a/b/c">>]),
|
||||||
|
|
||||||
|
%% Batch Del
|
||||||
|
R3 = #mqtt_route{topic = <<"#">>, node = 'a@127.0.0.1'},
|
||||||
|
?R:add_route(R3),
|
||||||
|
?R:del_route(R1),
|
||||||
|
?R:del_route(R2),
|
||||||
|
?R:del_route(R3),
|
||||||
|
[] = lists:sort(?R:match(<<"a/b/c">>)).
|
||||||
|
|
||||||
|
t_print(_) ->
|
||||||
|
Routes = [#mqtt_route{topic = <<"a/b/c">>, node = node()},
|
||||||
|
#mqtt_route{topic = <<"#">>, node = node()},
|
||||||
|
#mqtt_route{topic = <<"+/#">>, node = node()}],
|
||||||
|
lists:foreach(fun(R) -> ?R:add_route(R) end, Routes),
|
||||||
|
?R:print(<<"a/b/c">>),
|
||||||
|
?R:del_route(<<"+/#">>),
|
||||||
|
?R:del_route(<<"a/b/c">>),
|
||||||
|
?R:del_route(<<"#">>).
|
||||||
|
|
||||||
|
router_unused(_) ->
|
||||||
|
gen_server:call(emqttd_router, bad_call),
|
||||||
|
gen_server:cast(emqttd_router, bad_msg),
|
||||||
|
emqttd_router ! bad_info.
|
||||||
|
|
Loading…
Reference in New Issue