Explorar el Código

Add test cases for topic match

HuangDan hace 8 años
padre
commit
947df6ce35
Se han modificado 2 ficheros con 12 adiciones y 4 borrados
  1. 3 3
      test/emqttd_SUITE.erl
  2. 9 1
      test/emqttd_topic_SUITE.erl

+ 3 - 3
test/emqttd_SUITE.erl

@@ -129,7 +129,6 @@ init_per_suite(Config) ->
     NewConfig = generate_config(),
     lists:foreach(fun set_app_env/1, NewConfig),
     application:ensure_all_started(?APP),
-    timer:sleep(6000),
     Config.
 
 end_per_suite(_Config) ->
@@ -590,8 +589,9 @@ conflict_listeners(_) ->
                {current_clients, esockd:get_current_clients(Pid)},
                {shutdown_count, esockd:get_shutdown_count(Pid)}]}
               end, esockd:listeners()),
-    ?assertEqual(1, proplists:get_value(current_clients, proplists:get_value("mqtt:tcp:0.0.0.0:1883", Listeners))),
-    ?assertEqual([{conflict,1}], proplists:get_value(shutdown_count, proplists:get_value("mqtt:tcp:0.0.0.0:1883", Listeners))),
+    L =proplists:get_value("mqtt:tcp:0.0.0.0:1883", Listeners),
+    ?assertEqual(1, proplists:get_value(current_clients, L)),
+    ?assertEqual(1, proplists:get_value(conflict, L)),
     emqttc:disconnect(C2).
 
 cli_vm(_) ->

+ 9 - 1
test/emqttd_topic_SUITE.erl

@@ -26,7 +26,7 @@
 
 -define(N, 10000).
 
-all() -> [t_wildcard, t_match, t_match2, t_validate, t_triples, t_join,
+all() -> [t_wildcard, t_match, t_match2, t_match3, t_validate, t_triples, t_join,
           t_words, t_systop, t_feed_var, t_sys_match, 't_#_match',
           t_sigle_level_validate, t_sigle_level_match, t_match_perf,
           t_triples_perf, t_parse].
@@ -71,6 +71,14 @@ t_match2(_) ->
     false = match(<<"$shared/x/y">>, <<"+/+/#">>),
     false = match(<<"house/1/sensor/0">>, <<"house/+">>).
 
+t_match3(_) ->
+    true = match(<<"device/60019423a83c/fw">>, <<"device/60019423a83c/#">>),
+    false = match(<<"device/60019423a83c/$fw">>, <<"device/60019423a83c/#">>),
+    true = match(<<"device/60019423a83c/$fw/fw">>, <<"device/60019423a83c/$fw/#">>),
+    true = match(<<"device/60019423a83c/fw/checksum">>, <<"device/60019423a83c/#">>),
+    false = match(<<"device/60019423a83c/$fw/checksum">>, <<"device/60019423a83c/#">>),
+    true = match(<<"device/60019423a83c/dust/type">>, <<"device/60019423a83c/#">>).
+
 t_sigle_level_match(_) ->
     true  = match(<<"sport/tennis/player1">>, <<"sport/tennis/+">>),
     false = match(<<"sport/tennis/player1/ranking">>, <<"sport/tennis/+">>),