|
|
@@ -18,6 +18,9 @@
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
-include_lib("emqx_rule_engine/include/rule_engine.hrl").
|
|
|
-compile([export_all, nowarn_export_all]).
|
|
|
+
|
|
|
+% -define(EMQX_ENTERPRISE, true).
|
|
|
+
|
|
|
%%--------------------------------------------------------------------
|
|
|
%% Setups
|
|
|
%%--------------------------------------------------------------------
|
|
|
@@ -47,14 +50,55 @@ end_per_suite(Cfg) ->
|
|
|
|
|
|
get_data_path() ->
|
|
|
emqx_ct_helpers:deps_path(emqx_management, "test/emqx_bridge_mqtt_data_export_import_SUITE_data/").
|
|
|
+
|
|
|
+remove_resource(Id) ->
|
|
|
+ emqx_rule_registry:remove_resource(Id),
|
|
|
+ emqx_rule_registry:remove_resource_params(Id).
|
|
|
+
|
|
|
+import(FilePath, Version) ->
|
|
|
+ ok = emqx_mgmt_data_backup:import(get_data_path() ++ "/" ++ FilePath, <<"{}">>),
|
|
|
+ lists:foreach(fun(#resource{id = Id, config = Config} = _Resource) ->
|
|
|
+ timer:sleep(1000),
|
|
|
+ case Id of
|
|
|
+ <<"bridge">> ->
|
|
|
+ test_utils:resource_is_alive(Id),
|
|
|
+ handle_config(Config, Version, bridge),
|
|
|
+ remove_resource(Id);
|
|
|
+ <<"rpc">> ->
|
|
|
+ test_utils:resource_is_alive(Id),
|
|
|
+ handle_config(Config, Version, rpc),
|
|
|
+ remove_resource(Id);
|
|
|
+ _ -> ok
|
|
|
+ end
|
|
|
+ end, emqx_rule_registry:get_resources()).
|
|
|
+
|
|
|
%%--------------------------------------------------------------------
|
|
|
%% Cases
|
|
|
%%--------------------------------------------------------------------
|
|
|
|
|
|
-handle_config(Config, 420, brigde) ->
|
|
|
- ?assertEqual(<<"off">>, maps:get(<<"ssl">>, Config));
|
|
|
+-ifndef(EMQX_ENTERPRISE).
|
|
|
+
|
|
|
+t_import420(_) ->
|
|
|
+ import("420.json", 420),
|
|
|
+ {ok, _} = emqx_mgmt_data_backup:export().
|
|
|
+
|
|
|
+t_import430(_) ->
|
|
|
+ import("430.json", 430),
|
|
|
+ {ok, _} = emqx_mgmt_data_backup:export().
|
|
|
+
|
|
|
+t_import409(_) ->
|
|
|
+ import("409.json", 409),
|
|
|
+ {ok, _} = emqx_mgmt_data_backup:export().
|
|
|
+
|
|
|
+t_import415(_) ->
|
|
|
+ import("415.json", 415),
|
|
|
+ {ok, _} = emqx_mgmt_data_backup:export().
|
|
|
+
|
|
|
+
|
|
|
+handle_config(Config, 420, bridge) ->
|
|
|
+ ?assertEqual(false, maps:get(<<"ssl">>, Config));
|
|
|
|
|
|
-handle_config(Config, 430, brigde) ->
|
|
|
+handle_config(Config, 430, bridge) ->
|
|
|
?assertEqual(false, maps:get(<<"ssl">>, Config));
|
|
|
|
|
|
handle_config(Config, 420, rpc) ->
|
|
|
@@ -66,14 +110,14 @@ handle_config(Config, 409, rpc) ->
|
|
|
handle_config(Config, 415, rpc) ->
|
|
|
handle_config(Config, 420, rpc);
|
|
|
|
|
|
-handle_config(Config, 409, brigde) ->
|
|
|
- handle_config(Config, 420, brigde);
|
|
|
+handle_config(Config, 409, bridge) ->
|
|
|
+ handle_config(Config, 420, bridge);
|
|
|
|
|
|
-handle_config(Config, 415, brigde) ->
|
|
|
- handle_config(Config, 420, brigde);
|
|
|
+handle_config(Config, 415, bridge) ->
|
|
|
+ handle_config(Config, 420, bridge);
|
|
|
|
|
|
handle_config(Config, 430, rpc) ->
|
|
|
- ?assertEqual(<<"emqx@127.0.0.1">>, maps:get(<<"address">>, Config)),
|
|
|
+ ?assertEqual(<<"test@127.0.0.1">>, maps:get(<<"address">>, Config)),
|
|
|
?assertEqual(32, maps:get(<<"batch_size">>, Config)),
|
|
|
?assertEqual(<<"off">>, maps:get(<<"disk_cache">>, Config)),
|
|
|
?assertEqual(<<"bridge/emqx/${node}/">>, maps:get(<<"mountpoint">>, Config)),
|
|
|
@@ -82,37 +126,59 @@ handle_config(Config, 430, rpc) ->
|
|
|
|
|
|
handle_config(_, _, _) -> ok.
|
|
|
|
|
|
-remove_resource(Id) ->
|
|
|
- emqx_rule_registry:remove_resource(Id),
|
|
|
- emqx_rule_registry:remove_resource_params(Id).
|
|
|
+-endif.
|
|
|
|
|
|
-import(FilePath, Version) ->
|
|
|
- Overrides = emqx_json:encode(#{<<"auth.mnesia.as">> => atom_to_binary(clientid)}),
|
|
|
- ok = emqx_mgmt_data_backup:import(get_data_path() ++ "/" ++ FilePath, Overrides),
|
|
|
- lists:foreach(fun(#resource{id = Id, config = Config} = _Resource) ->
|
|
|
- case Id of
|
|
|
- <<"brigde">> ->
|
|
|
- handle_config(Config, Version, brigde),
|
|
|
- remove_resource(Id);
|
|
|
- <<"rpc">> ->
|
|
|
- handle_config(Config, Version, rpc),
|
|
|
- remove_resource(Id);
|
|
|
- _ -> ok
|
|
|
- end
|
|
|
- end, emqx_rule_registry:get_resources()).
|
|
|
+-ifdef(EMQX_ENTERPRISE).
|
|
|
|
|
|
-t_import420(_) ->
|
|
|
- import("420.json", 420),
|
|
|
+t_importee4010(_) ->
|
|
|
+ import("ee4010.json", ee4010),
|
|
|
{ok, _} = emqx_mgmt_data_backup:export().
|
|
|
|
|
|
-t_import430(_) ->
|
|
|
- import("430.json", 430),
|
|
|
+t_importee410(_) ->
|
|
|
+ import("ee410.json", ee410),
|
|
|
{ok, _} = emqx_mgmt_data_backup:export().
|
|
|
|
|
|
-t_import409(_) ->
|
|
|
- import("409.json", 409),
|
|
|
+t_importee411(_) ->
|
|
|
+ import("ee411.json", ee411),
|
|
|
{ok, _} = emqx_mgmt_data_backup:export().
|
|
|
|
|
|
-t_import415(_) ->
|
|
|
- import("415.json", 415),
|
|
|
+t_importee420(_) ->
|
|
|
+ import("ee420.json", ee420),
|
|
|
+ {ok, _} = emqx_mgmt_data_backup:export().
|
|
|
+
|
|
|
+t_importee425(_) ->
|
|
|
+ import("ee425.json", ee425),
|
|
|
+ {ok, _} = emqx_mgmt_data_backup:export().
|
|
|
+
|
|
|
+t_importee430(_) ->
|
|
|
+ import("ee430.json", ee430),
|
|
|
{ok, _} = emqx_mgmt_data_backup:export().
|
|
|
+
|
|
|
+%%--------------------------------------------------------------------
|
|
|
+%% handle_config
|
|
|
+%%--------------------------------------------------------------------
|
|
|
+
|
|
|
+handle_config(Config, ee4010, Id) ->
|
|
|
+ handle_config(Config, ee430, Id);
|
|
|
+
|
|
|
+handle_config(Config, ee410, Id) ->
|
|
|
+ handle_config(Config, ee430, Id);
|
|
|
+
|
|
|
+handle_config(Config, ee411, Id) ->
|
|
|
+ handle_config(Config, ee430, Id);
|
|
|
+
|
|
|
+handle_config(Config, ee420, Id) ->
|
|
|
+ handle_config(Config, ee430, Id);
|
|
|
+
|
|
|
+handle_config(Config, ee425, Id) ->
|
|
|
+ handle_config(Config, ee430, Id);
|
|
|
+
|
|
|
+handle_config(Config, ee430, bridge) ->
|
|
|
+ ?assertEqual(false, maps:get(<<"ssl">>, Config));
|
|
|
+
|
|
|
+handle_config(Config, ee430, rpc) ->
|
|
|
+ ?assertEqual(<<"off">>, maps:get(<<"disk_cache">>, Config));
|
|
|
+
|
|
|
+handle_config(Config, ee435, Id) ->
|
|
|
+ handle_config(Config, ee430, Id).
|
|
|
+-endif.
|