Просмотр исходного кода

test(mgmt): add data im/export tests for EE

wwhai 4 лет назад
Родитель
Сommit
b48c437f97
20 измененных файлов с 1208 добавлено и 57 удалено
  1. 2 2
      apps/emqx_management/src/emqx_mgmt_data_backup.erl
  2. 99 33
      apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE.erl
  3. 1 1
      apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/409.json
  4. 1 1
      apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/415.json
  5. 2 2
      apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/420.json
  6. 2 2
      apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/430.json
  7. 68 0
      apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee4010.json
  8. 70 0
      apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee410.json
  9. 70 0
      apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee411.json
  10. 119 0
      apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee420.json
  11. 123 0
      apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee425.json
  12. 123 0
      apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee430.json
  13. 88 16
      apps/emqx_management/test/emqx_webhook_data_export_import_SUITE.erl
  14. 43 0
      apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee4010.json
  15. 43 0
      apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee410.json
  16. 43 0
      apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee411.json
  17. 92 0
      apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee420.json
  18. 102 0
      apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee425.json
  19. 98 0
      apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee430.json
  20. 19 0
      apps/emqx_management/test/test_utils.erl

+ 2 - 2
apps/emqx_management/src/emqx_mgmt_data_backup.erl

@@ -412,7 +412,7 @@ import_auth_clientid(Lists) ->
             lists:foreach(fun(#{<<"clientid">> := Clientid, <<"password">> := Password}) ->
                                   mnesia:dirty_write({emqx_user, {clientid, Clientid}
                                                                , base64:decode(Password)
-                                                               ,  erlang:system_time(millisecond)})
+                                                               , erlang:system_time(millisecond)})
                           end, Lists)
     end.
 
@@ -633,7 +633,7 @@ import(Filename, OverridesJson) ->
                     end;
                 false ->
                     logger:error("Unsupported version: ~p", [Version]),
-                    {error, unsupported_version}
+                    {error, unsupported_version, Version}
             end;
         Error -> Error
     end.

+ 99 - 33
apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE.erl

@@ -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.

+ 1 - 1
apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/409.json

@@ -45,7 +45,7 @@
                 "mountpoint": "bridge/emqx/${node}/",
                 "disk_cache": "off",
                 "batch_size": 32,
-                "address": "emqx@127.0.0.1"
+                "address": "test@127.0.0.1"
             }
         }
     ],

+ 1 - 1
apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/415.json

@@ -21,7 +21,7 @@
                 "mountpoint": "bridge/emqx/${node}/",
                 "disk_cache": "off",
                 "batch_size": 32,
-                "address": "emqx@127.0.0.1"
+                "address": "test@127.0.0.1"
             }
         },
         {

+ 2 - 2
apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/420.json

@@ -7,7 +7,7 @@
             "id": "rpc",
             "type": "bridge_rpc",
             "config": {
-                "address": "emqx@127.0.0.1",
+                "address": "test@127.0.0.1",
                 "batch_size": 32,
                 "disk_cache": "off",
                 "mountpoint": "bridge/emqx/${node}/",
@@ -31,7 +31,7 @@
                 "disk_cache": "off",
                 "keepalive": "60s",
                 "keyfile": "etc/certs/client-key.pem",
-                "mountpoint": "bridge/aws/${node}/",
+                "mountpoint": "bridge/emqx/${node}/",
                 "password": "",
                 "pool_size": 8,
                 "proto_ver": "mqttv4",

+ 2 - 2
apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/430.json

@@ -25,7 +25,7 @@
                     "filename": "etc/certs/client-key.pem",
                     "file": ""
                 },
-                "mountpoint": "bridge/aws/${node}/",
+                "mountpoint": "bridge/emqx/${node}/",
                 "password": "",
                 "pool_size": 8,
                 "proto_ver": "mqttv4",
@@ -41,7 +41,7 @@
             "id": "rpc",
             "type": "bridge_rpc",
             "config": {
-                "address": "emqx@127.0.0.1",
+                "address": "test@127.0.0.1",
                 "batch_size": 32,
                 "disk_cache": "off",
                 "mountpoint": "bridge/emqx/${node}/",

+ 68 - 0
apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee4010.json

@@ -0,0 +1,68 @@
+{
+    "version": "4.0",
+    "users": [
+        {
+            "username": "admin",
+            "tags": "administrator",
+            "password": "GCX5nvOMK0hbiMB4AUyc25wI8fU="
+        }
+    ],
+    "schemas": [],
+    "rules": [],
+    "resources": [
+        {
+            "type": "bridge_mqtt",
+            "id": "bridge",
+            "description": "bridge",
+            "created_at": null,
+            "config": {
+                "username": "user",
+                "ssl": "off",
+                "retry_interval": "20s",
+                "reconnect_interval": "30s",
+                "proto_ver": "mqttv4",
+                "password": "passwd",
+                "mountpoint": "bridge/emqx/${node}/",
+                "keyfile": "etc/certs/client-key.pem",
+                "keepalive": "60s",
+                "disk_cache": "off",
+                "clientid": "bridge_aws",
+                "ciphers": "ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384",
+                "certfile": "etc/certs/client-cert.pem",
+                "cacertfile": "etc/certs/cacert.pem",
+                "bridge_mode": true,
+                "address": "127.0.0.1:1883"
+            }
+        },
+        {
+            "type": "bridge_rpc",
+            "id": "rpc",
+            "description": "rpc",
+            "created_at": null,
+            "config": {
+                "reconnect_interval": "30s",
+                "pool_size": 8,
+                "mountpoint": "bridge/emqx/${node}/",
+                "disk_cache": "off",
+                "batch_size": 32,
+                "address": "test@127.0.0.1"
+            }
+        }
+    ],
+    "date": "2021-04-13 13:57:23",
+    "blacklist": [],
+    "auth_username": [],
+    "auth_mnesia": [],
+    "auth_clientid": [],
+    "apps": [
+        {
+            "status": true,
+            "secret": "public",
+            "name": "Default",
+            "id": "admin",
+            "expired": "undefined",
+            "desc": "Application user"
+        }
+    ],
+    "acl_mnesia": []
+}

Разница между файлами не показана из-за своего большого размера
+ 70 - 0
apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee410.json


Разница между файлами не показана из-за своего большого размера
+ 70 - 0
apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee411.json


Разница между файлами не показана из-за своего большого размера
+ 119 - 0
apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee420.json


Разница между файлами не показана из-за своего большого размера
+ 123 - 0
apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee425.json


Разница между файлами не показана из-за своего большого размера
+ 123 - 0
apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee430.json


+ 88 - 16
apps/emqx_management/test/emqx_webhook_data_export_import_SUITE.erl

@@ -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,10 +50,55 @@ end_per_suite(Cfg) ->
 
 get_data_path() ->
     emqx_ct_helpers:deps_path(emqx_management, "test/emqx_webhook_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) ->
+        case Id of
+            <<"webhook">> ->
+                test_utils:resource_is_alive(Id),
+                handle_config(Config, Version),
+                remove_resource(Id);
+            _ -> ok
+        end
+    end, emqx_rule_registry:get_resources()).
+
 %%--------------------------------------------------------------------
 %% Cases
 %%--------------------------------------------------------------------
+-ifdef(EMQX_ENTERPRISE).
 
+t_importee4010(_) ->
+    import("ee4010.json", ee4010),
+    {ok, _} = emqx_mgmt_data_backup:export().
+
+t_importee410(_) ->
+    import("ee410.json", ee410),
+    {ok, _} = emqx_mgmt_data_backup:export().
+
+t_importee411(_) ->
+    import("ee411.json", ee411),
+    {ok, _} = emqx_mgmt_data_backup:export().
+
+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, 409) ->
     handle_config(Config, 422);
 
@@ -87,24 +135,10 @@ handle_config(Config, 430) ->
     ?assertEqual(true, is_map(maps:get(<<"certfile">>, Config))),
     ?assertEqual(true, is_map(maps:get(<<"keyfile">>, Config))),
     ?assertEqual(8, maps:get(<<"pool_size">>, Config));
-
 handle_config(_, _) -> ok.
+-endif.
 
-remove_resource(Id) ->
-    emqx_rule_registry:remove_resource(Id),
-    emqx_rule_registry:remove_resource_params(Id).
-
-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
-            "webhook" ->
-            handle_config(Config, Version),
-            remove_resource(Id);
-            _ -> ok
-        end
-    end, emqx_rule_registry:get_resources()).
+-ifndef(EMQX_ENTERPRISE).
 
 t_import422(_) ->
     import("422.json", 422),
@@ -129,3 +163,41 @@ t_import409(_) ->
 t_import415(_) ->
     import("415.json", 415),
     {ok, _} = emqx_mgmt_data_backup:export().
+
+%%--------------------------------------------------------------------
+%% handle_config
+%%--------------------------------------------------------------------
+
+handle_config(Config, ee4010) ->
+    ?assertEqual(<<"http://www.emqx.io">>, maps:get(<<"url">>, Config));
+
+handle_config(Config, ee410) ->
+    ?assertEqual(<<"http://www.emqx.io">>, maps:get(<<"url">>, Config));
+
+handle_config(Config, ee411) ->
+    ?assertEqual(<<"http://www.emqx.io">>, maps:get(<<"url">>, Config));
+
+handle_config(Config, ee420) ->
+    ?assertEqual(<<"http://www.emqx.io">>, maps:get(<<"url">>, Config));
+
+handle_config(Config, ee425) ->
+    ?assertEqual(<<"http://www.emqx.io">>, maps:get(<<"url">>, Config)),
+    ?assertEqual(<<"5s">>, maps:get(<<"connect_timeout">>, Config)),
+    ?assertEqual(<<"5s">>, maps:get(<<"request_timeout">>, Config)),
+    ?assertEqual(false, maps:get(<<"verify">>, Config)),
+    ?assertEqual(8, maps:get(<<"pool_size">>, Config));
+
+handle_config(Config, ee435) ->
+    handle_config(Config, ee430);
+
+handle_config(Config, ee430) ->
+    ?assertEqual(<<"http://www.emqx.io">>, maps:get(<<"url">>, Config)),
+    ?assertEqual(<<"5s">>, maps:get(<<"connect_timeout">>, Config)),
+    ?assertEqual(<<"5s">>, maps:get(<<"request_timeout">>, Config)),
+    ?assertEqual(false, maps:get(<<"verify">>, Config)),
+    ?assertEqual(8, maps:get(<<"pool_size">>, Config));
+
+handle_config(Config, _) ->
+    io:format("|>=> :~p~n", [Config]).
+
+-endif.

+ 43 - 0
apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee4010.json

@@ -0,0 +1,43 @@
+{
+    "version": "4.0",
+    "users": [
+        {
+            "username": "admin",
+            "tags": "administrator",
+            "password": "GCX5nvOMK0hbiMB4AUyc25wI8fU="
+        }
+    ],
+    "schemas": [],
+    "rules": [],
+    "resources": [
+        {
+            "type": "web_hook",
+            "id": "web_hook",
+            "description": "webhook",
+            "created_at": null,
+            "config": {
+                "url": "http://www.emqx.io",
+                "method": "POST",
+                "headers": {
+                    "k": "v"
+                }
+            }
+        }
+    ],
+    "date": "2021-04-13 13:57:23",
+    "blacklist": [],
+    "auth_username": [],
+    "auth_mnesia": [],
+    "auth_clientid": [],
+    "apps": [
+        {
+            "status": true,
+            "secret": "public",
+            "name": "Default",
+            "id": "admin",
+            "expired": "undefined",
+            "desc": "Application user"
+        }
+    ],
+    "acl_mnesia": []
+}

+ 43 - 0
apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee410.json

@@ -0,0 +1,43 @@
+{
+    "version": "4.1",
+    "users": [
+        {
+            "username": "admin",
+            "tags": "administrator",
+            "password": "atdwlByxL9/9P3CoFJ60drhodkY="
+        }
+    ],
+    "schemas": [],
+    "rules": [],
+    "resources": [
+        {
+            "type": "web_hook",
+            "id": "webhook",
+            "description": "webhook",
+            "created_at": null,
+            "config": {
+                "url": "http://www.emqx.io",
+                "method": "POST",
+                "headers": {
+                    "k": "v"
+                }
+            }
+        }
+    ],
+    "date": "2021-04-13 11:30:21",
+    "blacklist": [],
+    "auth_username": [],
+    "auth_mnesia": [],
+    "auth_clientid": [],
+    "apps": [
+        {
+            "status": true,
+            "secret": "public",
+            "name": "Default",
+            "id": "admin",
+            "expired": "undefined",
+            "desc": "Application user"
+        }
+    ],
+    "acl_mnesia": []
+}

+ 43 - 0
apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee411.json

@@ -0,0 +1,43 @@
+{
+    "version": "4.1",
+    "users": [
+        {
+            "username": "admin",
+            "tags": "administrator",
+            "password": "tsYtP3TylchkM7J7YTc46Di0kPk="
+        }
+    ],
+    "schemas": [],
+    "rules": [],
+    "resources": [
+        {
+            "type": "web_hook",
+            "id": "web_hook",
+            "description": "webhook",
+            "created_at": null,
+            "config": {
+                "url": "http://www.emqx.io",
+                "method": "POST",
+                "headers": {
+                    "k": "v"
+                }
+            }
+        }
+    ],
+    "date": "2021-04-13 16:37:18",
+    "blacklist": [],
+    "auth_username": [],
+    "auth_mnesia": [],
+    "auth_clientid": [],
+    "apps": [
+        {
+            "status": true,
+            "secret": "public",
+            "name": "Default",
+            "id": "admin",
+            "expired": "undefined",
+            "desc": "Application user"
+        }
+    ],
+    "acl_mnesia": []
+}

+ 92 - 0
apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee420.json

@@ -0,0 +1,92 @@
+{
+    "version": "4.2",
+    "date": "2021-04-13 11:35:13",
+    "modules": [
+        {
+            "id": "module:b9294d70",
+            "type": "recon",
+            "config": {},
+            "enabled": true,
+            "created_at": "undefined",
+            "description": ""
+        },
+        {
+            "id": "module:c7c7b692",
+            "type": "presence",
+            "config": {
+                "qos": 0
+            },
+            "enabled": true,
+            "created_at": "undefined",
+            "description": ""
+        },
+        {
+            "id": "module:486adc4b",
+            "type": "internal_acl",
+            "config": {
+                "acl_rule_file": "etc/acl.conf"
+            },
+            "enabled": true,
+            "created_at": "undefined",
+            "description": ""
+        },
+        {
+            "id": "module:411cf85d",
+            "type": "retainer",
+            "config": {
+                "storage_type": "ram",
+                "max_retained_messages": 0,
+                "max_payload_size": "1MB",
+                "expiry_interval": 0
+            },
+            "enabled": true,
+            "created_at": "undefined",
+            "description": ""
+        },
+        {
+            "id": "module:127b92c3",
+            "type": "hot_confs",
+            "config": {},
+            "enabled": true,
+            "created_at": "undefined",
+            "description": ""
+        }
+    ],
+    "rules": [],
+    "resources": [
+        {
+            "id": "webhook",
+            "type": "web_hook",
+            "config": {
+                "headers": {
+                    "k": "v"
+                },
+                "method": "POST",
+                "url": "http://www.emqx.io"
+            },
+            "created_at": null,
+            "description": "webhook"
+        }
+    ],
+    "blacklist": [],
+    "apps": [
+        {
+            "id": "admin",
+            "secret": "public",
+            "name": "Default",
+            "desc": "Application user",
+            "status": true,
+            "expired": "undefined"
+        }
+    ],
+    "users": [
+        {
+            "username": "admin",
+            "password": "bx1P63qGDhKvZYdltxX4NVY2kS4=",
+            "tags": "administrator"
+        }
+    ],
+    "auth_mnesia": [],
+    "acl_mnesia": [],
+    "schemas": []
+}

+ 102 - 0
apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee425.json

@@ -0,0 +1,102 @@
+{
+    "version": "4.2",
+    "date": "2021-04-13 16:42:34",
+    "modules": [
+        {
+            "id": "module:3dc04a9c",
+            "type": "retainer",
+            "config": {
+                "storage_type": "ram",
+                "max_retained_messages": 0,
+                "max_payload_size": "1MB",
+                "expiry_interval": 0
+            },
+            "enabled": true,
+            "created_at": "undefined",
+            "description": ""
+        },
+        {
+            "id": "module:5128901f",
+            "type": "recon",
+            "config": {},
+            "enabled": true,
+            "created_at": "undefined",
+            "description": ""
+        },
+        {
+            "id": "module:9d1596c8",
+            "type": "presence",
+            "config": {
+                "qos": 0
+            },
+            "enabled": true,
+            "created_at": "undefined",
+            "description": ""
+        },
+        {
+            "id": "module:43d43410",
+            "type": "internal_acl",
+            "config": {
+                "acl_rule_file": "etc/acl.conf"
+            },
+            "enabled": true,
+            "created_at": "undefined",
+            "description": ""
+        }
+    ],
+    "rules": [],
+    "resources": [
+        {
+            "id": "webhook",
+            "type": "web_hook",
+            "config": {
+                "cacertfile": {
+                    "filename": "",
+                    "file": ""
+                },
+                "certfile": {
+                    "filename": "",
+                    "file": ""
+                },
+                "connect_timeout": "5s",
+                "headers": {
+                    "k": "v"
+                },
+                "keyfile": {
+                    "filename": "",
+                    "file": ""
+                },
+                "method": "POST",
+                "pool_size": 8,
+                "request_timeout": "5s",
+                "url": "http://www.emqx.io",
+                "verify": false
+            },
+            "created_at": null,
+            "description": "webhook"
+        }
+    ],
+    "blacklist": [],
+    "apps": [
+        {
+            "id": "admin",
+            "secret": "public",
+            "name": "Default",
+            "desc": "Application user",
+            "status": true,
+            "expired": "undefined"
+        }
+    ],
+    "users": [
+        {
+            "username": "admin",
+            "password": "Hd8AMmbFs+LsqQXQxaV/WqLoGEk=",
+            "tags": "administrator"
+        }
+    ],
+    "auth_mnesia": [],
+    "acl_mnesia": [],
+    "schemas": [],
+    "configs": [],
+    "listeners_state": []
+}

+ 98 - 0
apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee430.json

@@ -0,0 +1,98 @@
+{
+    "version": "4.3",
+    "rules": [],
+    "resources": [
+        {
+            "id": "webhook",
+            "type": "web_hook",
+            "config": {
+                "cacertfile": {
+                    "filename": "",
+                    "file": ""
+                },
+                "certfile": {
+                    "filename": "",
+                    "file": ""
+                },
+                "connect_timeout": "5s",
+                "keyfile": {
+                    "filename": "",
+                    "file": ""
+                },
+                "pool_size": 8,
+                "request_timeout": "5s",
+                "url": "http://www.emqx.io",
+                "verify": false
+            },
+            "created_at": 1618304340172,
+            "description": "webhook"
+        }
+    ],
+    "blacklist": [],
+    "apps": [
+        {
+            "id": "admin",
+            "secret": "public",
+            "name": "Default",
+            "desc": "Application user",
+            "status": true,
+            "expired": "undefined"
+        }
+    ],
+    "users": [
+        {
+            "username": "admin",
+            "password": "qq8hg9pOkmYiHqzi3+bcUaK2CGA=",
+            "tags": "administrator"
+        }
+    ],
+    "auth_mnesia": [],
+    "acl_mnesia": [],
+    "modules": [
+        {
+            "id": "module:aabeddbf",
+            "type": "recon",
+            "config": {},
+            "enabled": true,
+            "created_at": 1618304311061,
+            "description": ""
+        },
+        {
+            "id": "module:cbe6d976",
+            "type": "internal_acl",
+            "config": {
+                "acl_rule_file": "etc/acl.conf"
+            },
+            "enabled": true,
+            "created_at": 1618304311061,
+            "description": ""
+        },
+        {
+            "id": "module:46375e06",
+            "type": "retainer",
+            "config": {
+                "storage_type": "ram",
+                "max_retained_messages": 0,
+                "max_payload_size": "1MB",
+                "expiry_interval": 0
+            },
+            "enabled": true,
+            "created_at": 1618304311061,
+            "description": ""
+        },
+        {
+            "id": "module:091eb7c3",
+            "type": "presence",
+            "config": {
+                "qos": 0
+            },
+            "enabled": true,
+            "created_at": 1618304311061,
+            "description": ""
+        }
+    ],
+    "schemas": [],
+    "configs": [],
+    "listeners_state": [],
+    "date": "2021-04-13 17:59:52"
+}

+ 19 - 0
apps/emqx_management/test/test_utils.erl

@@ -0,0 +1,19 @@
+%% @author: 
+%% @description: 
+-module(test_utils).
+%% ====================================================================
+%% API functions
+%% ====================================================================
+-include_lib("eunit/include/eunit.hrl").
+-include_lib("emqx_rule_engine/include/rule_engine.hrl").
+
+-compile([export_all, nowarn_export_all]).
+
+%% ====================================================================
+%% Internal functions
+%% ====================================================================
+resource_is_alive(Id) ->
+    {ok, #resource_params{status = #{is_alive := Alive}} = Params} = emqx_rule_registry:find_resource_params(Id),
+    ct:print("Id: ~p, Alive: ~p, Resource ===> :~p~n", [Id, Alive, Params]),
+    ?assertEqual(true, Alive),
+    Alive.