fix CT errors
This commit is contained in:
parent
e5efa77078
commit
f998d2a41d
4
Makefile
4
Makefile
|
@ -17,11 +17,11 @@ TEST_ERLC_OPTS += +debug_info
|
||||||
TEST_ERLC_OPTS += +'{parse_transform, lager_transform}'
|
TEST_ERLC_OPTS += +'{parse_transform, lager_transform}'
|
||||||
|
|
||||||
EUNIT_OPTS = verbose
|
EUNIT_OPTS = verbose
|
||||||
EUNIT_ERL_OPTS = -args_file test_data/ct_vm.args -config test_data/ct_sys.config
|
# EUNIT_ERL_OPTS =
|
||||||
|
|
||||||
CT_SUITES = emqttd emqttd_access emqttd_backend emqttd_lib emqttd_mod emqttd_net \
|
CT_SUITES = emqttd emqttd_access emqttd_backend emqttd_lib emqttd_mod emqttd_net \
|
||||||
emqttd_mqueue emqttd_protocol emqttd_topic emqttd_trie
|
emqttd_mqueue emqttd_protocol emqttd_topic emqttd_trie
|
||||||
CT_OPTS = -cover test/ct.cover.spec -erl_args -args_file test_data/ct_vm.args -config test_data/ct_sys.config
|
CT_OPTS = -cover test/ct.cover.spec -erl_args -name emqttd_ct@127.0.0.1
|
||||||
|
|
||||||
COVER = true
|
COVER = true
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,8 @@ match(Client, Topic, [Rule|Rules]) ->
|
||||||
|
|
||||||
%% @doc Reload ACL
|
%% @doc Reload ACL
|
||||||
-spec(reload_acl(State :: #state{}) -> ok | {error, Reason :: any()}).
|
-spec(reload_acl(State :: #state{}) -> ok | {error, Reason :: any()}).
|
||||||
|
reload_acl(#state{config = undefined}) ->
|
||||||
|
ok;
|
||||||
reload_acl(State) ->
|
reload_acl(State) ->
|
||||||
case catch load_rules_from_file(State) of
|
case catch load_rules_from_file(State) of
|
||||||
{'EXIT', Error} -> {error, Error};
|
{'EXIT', Error} -> {error, Error};
|
||||||
|
|
|
@ -82,6 +82,8 @@ groups() ->
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
application:start(lager),
|
application:start(lager),
|
||||||
|
DataDir = proplists:get_value(data_dir, Config),
|
||||||
|
application:set_env(emqttd, conf, filename:join([DataDir, "emqttd.conf"])),
|
||||||
application:ensure_all_started(emqttd),
|
application:ensure_all_started(emqttd),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
@ -177,7 +179,7 @@ pubsub_queue(_) ->
|
||||||
Self = self(), Q = <<"$queue/abc">>,
|
Self = self(), Q = <<"$queue/abc">>,
|
||||||
SubFun = fun() ->
|
SubFun = fun() ->
|
||||||
emqttd:subscribe(Q),
|
emqttd:subscribe(Q),
|
||||||
timer:sleep(1),
|
timer:sleep(10),
|
||||||
{ok, Msgs} = loop_recv(Q, 10),
|
{ok, Msgs} = loop_recv(Q, 10),
|
||||||
Self ! {recv, self(), Msgs}
|
Self ! {recv, self(), Msgs}
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -38,9 +38,34 @@ groups() ->
|
||||||
[compile_rule,
|
[compile_rule,
|
||||||
match_rule]}].
|
match_rule]}].
|
||||||
|
|
||||||
|
init_per_group(access_control, Config) ->
|
||||||
|
application:load(emqttd),
|
||||||
|
prepare_config(),
|
||||||
|
gen_conf:init(emqttd),
|
||||||
|
Config;
|
||||||
|
|
||||||
init_per_group(_Group, Config) ->
|
init_per_group(_Group, Config) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
prepare_config() ->
|
||||||
|
Rules = [{allow, {ipaddr, "127.0.0.1"}, subscribe, ["$SYS/#", "#"]},
|
||||||
|
{allow, {user, "testuser"}, subscribe, ["a/b/c", "d/e/f/#"]},
|
||||||
|
{allow, {user, "admin"}, pubsub, ["a/b/c", "d/e/f/#"]},
|
||||||
|
{allow, {client, "testClient"}, subscribe, ["testTopics/testClient"]},
|
||||||
|
{allow, all, subscribe, ["clients/$c"]},
|
||||||
|
{allow, all, pubsub, ["users/$u/#"]},
|
||||||
|
{deny, all, subscribe, ["$SYS/#", "#"]},
|
||||||
|
{deny, all}],
|
||||||
|
write_config("access_SUITE_acl.conf", Rules),
|
||||||
|
Config = [{auth, anonymous, []},
|
||||||
|
{acl, internal, [{config, "access_SUITE_acl.conf"},
|
||||||
|
{nomatch, allow}]}],
|
||||||
|
write_config("access_SUITE_emqttd.conf", Config),
|
||||||
|
application:set_env(emqttd, conf, "access_SUITE_emqttd.conf").
|
||||||
|
|
||||||
|
write_config(Filename, Terms) ->
|
||||||
|
file:write_file(Filename, [io_lib:format("~tp.~n", [Term]) || Term <- Terms]).
|
||||||
|
|
||||||
end_per_group(_Group, Config) ->
|
end_per_group(_Group, Config) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
@ -48,14 +73,7 @@ init_per_testcase(TestCase, Config) when TestCase =:= reload_acl;
|
||||||
TestCase =:= register_mod;
|
TestCase =:= register_mod;
|
||||||
TestCase =:= unregister_mod;
|
TestCase =:= unregister_mod;
|
||||||
TestCase =:= check_acl ->
|
TestCase =:= check_acl ->
|
||||||
DataDir = proplists:get_value(data_dir, Config),
|
{ok, _Pid} = ?AC:start_link(), Config;
|
||||||
AclOpts = [
|
|
||||||
{auth, [{anonymous, []}]},
|
|
||||||
{acl, [{internal, [{file, filename:join([DataDir, "test_acl.config"])},
|
|
||||||
{nomatch, allow}]}]}
|
|
||||||
],
|
|
||||||
{ok, _Pid} = ?AC:start_link(AclOpts),
|
|
||||||
Config;
|
|
||||||
|
|
||||||
init_per_testcase(_TestCase, Config) ->
|
init_per_testcase(_TestCase, Config) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
{allow, {ipaddr, "127.0.0.1"}, subscribe, ["$SYS/#", "#"]}.
|
|
||||||
|
|
||||||
{allow, {user, "testuser"}, subscribe, ["a/b/c", "d/e/f/#"]}.
|
|
||||||
|
|
||||||
{allow, {user, "admin"}, pubsub, ["a/b/c", "d/e/f/#"]}.
|
|
||||||
|
|
||||||
{allow, {client, "testClient"}, subscribe, ["testTopics/testClient"]}.
|
|
||||||
|
|
||||||
{allow, all, subscribe, ["clients/$c"]}.
|
|
||||||
|
|
||||||
{allow, all, pubsub, ["users/$u/#"]}.
|
|
||||||
|
|
||||||
{deny, all, subscribe, ["$SYS/#", "#"]}.
|
|
||||||
|
|
||||||
{deny, all}.
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
|
|
||||||
%% ex: ft=erlang ts=4 sw=4 et
|
|
||||||
[
|
|
||||||
{kernel, [{start_timer, true}, {start_pg2, true}]},
|
|
||||||
{emqttd, [{conf, "test_data/ct_emqttd.conf"}]}
|
|
||||||
].
|
|
|
@ -1,61 +0,0 @@
|
||||||
##-------------------------------------------------------------------------
|
|
||||||
## Name of the emqttd node: Name@Host
|
|
||||||
##
|
|
||||||
## NOTICE: The Host should be IP address or the fully qualified host name.
|
|
||||||
## The short hostname cannot work!
|
|
||||||
##-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-name emqttd_ct@127.0.0.1
|
|
||||||
# or
|
|
||||||
#-name emqttd@localhost.
|
|
||||||
|
|
||||||
## Cookie for distributed erlang
|
|
||||||
-setcookie emqttdsecretcookie
|
|
||||||
|
|
||||||
##-------------------------------------------------------------------------
|
|
||||||
## Flags
|
|
||||||
##-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
|
|
||||||
## (Disabled by default..use with caution!)
|
|
||||||
##-heart
|
|
||||||
-smp true
|
|
||||||
|
|
||||||
## Enable kernel poll and a few async threads
|
|
||||||
+K true
|
|
||||||
|
|
||||||
## 12 threads/core.
|
|
||||||
+A 24
|
|
||||||
|
|
||||||
## max process numbers
|
|
||||||
#+P 8192
|
|
||||||
|
|
||||||
## Sets the maximum number of simultaneously existing ports for this system
|
|
||||||
#+Q 8192
|
|
||||||
|
|
||||||
## max atom number
|
|
||||||
## +t
|
|
||||||
|
|
||||||
## Set the distribution buffer busy limit (dist_buf_busy_limit) in kilobytes.
|
|
||||||
## Valid range is 1-2097151. Default is 1024.
|
|
||||||
## +zdbbl 8192
|
|
||||||
|
|
||||||
## Set scheduler bind type.
|
|
||||||
## +sbt db
|
|
||||||
|
|
||||||
##-------------------------------------------------------------------------
|
|
||||||
## Env
|
|
||||||
##-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
## Increase number of concurrent ports/sockets, deprecated in R17
|
|
||||||
#-env ERL_MAX_PORTS 8192
|
|
||||||
|
|
||||||
#-env ERTS_MAX_PORTS 8192
|
|
||||||
|
|
||||||
## Mnesia and SSL will create temporary ets tables.
|
|
||||||
-env ERL_MAX_ETS_TABLES 1024
|
|
||||||
|
|
||||||
## Tweak GC to run more often
|
|
||||||
-env ERL_FULLSWEEP_AFTER 1000
|
|
||||||
|
|
||||||
-env ERL_CRASH_DUMP log/emqttd_crash.dump
|
|
Loading…
Reference in New Issue