فهرست منبع

chore(auth): update emqx_gcp_device tests

Ilya Averyanov 2 سال پیش
والد
کامیت
d17bcc94f6

+ 9 - 5
apps/emqx_gcp_device/test/emqx_gcp_device_SUITE.erl

@@ -17,15 +17,19 @@ all() ->
     emqx_common_test_helpers:all(?MODULE).
 
 init_per_suite(Config) ->
-    ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_authn, emqx_retainer, emqx_gcp_device]),
-    Config.
+    Apps = emqx_cth_suite:start(
+        [emqx, emqx_conf, emqx_authn, emqx_gcp_device, {emqx_retainer, "retainer {enable = true}"}],
+        #{
+            work_dir => ?config(priv_dir, Config)
+        }
+    ),
+    [{apps, Apps} | Config].
 
 end_per_suite(Config) ->
-    _ = emqx_common_test_helpers:stop_apps([emqx_authn, emqx_retainer, emqx_gcp_device]),
-    Config.
+    ok = emqx_cth_suite:stop(?config(apps, Config)),
+    ok.
 
 init_per_testcase(_TestCase, Config) ->
-    {ok, _} = emqx_cluster_rpc:start_link(node(), emqx_cluster_rpc, 1000),
     emqx_authn_test_lib:delete_authenticators(
         [authentication],
         ?GLOBAL

+ 18 - 16
apps/emqx_gcp_device/test/emqx_gcp_device_api_SUITE.erl

@@ -14,32 +14,34 @@
 -include_lib("emqx/include/emqx.hrl").
 
 -define(PATH, [authentication]).
--define(BASE_CONF, <<
-    ""
-    "\n"
-    "retainer {\n"
-    "    enable = true\n"
-    "}"
-    ""
->>).
 
 all() ->
     emqx_common_test_helpers:all(?MODULE).
 
 init_per_suite(Config) ->
-    ok = emqx_config:init_load(emqx_retainer_schema, ?BASE_CONF),
-    ok = emqx_common_test_helpers:start_apps([emqx_gcp_device, emqx_authn, emqx_conf, emqx_retainer]),
-    emqx_dashboard_api_test_helpers:set_default_config(),
-    emqx_mgmt_api_test_util:init_suite(),
-    Config.
+    Apps = emqx_cth_suite:start(
+        [
+            emqx,
+            emqx_conf,
+            emqx_authn,
+            {emqx_retainer, "retainer {enable = true}"},
+            emqx_management,
+            {emqx_dashboard, "dashboard.listeners.http { enable = true, bind = 18083 }"},
+            emqx_gcp_device
+        ],
+        #{
+            work_dir => ?config(priv_dir, Config)
+        }
+    ),
+    _ = emqx_common_test_http:create_default_app(),
+    [{apps, Apps} | Config].
 
 end_per_suite(Config) ->
-    emqx_mgmt_api_test_util:end_suite(),
-    _ = emqx_common_test_helpers:stop_apps([emqx_authn, emqx_retainer, emqx_gcp_device]),
+    _ = emqx_common_test_http:delete_default_app(),
+    ok = emqx_cth_suite:stop(?config(apps, Config)),
     Config.
 
 init_per_testcase(_TestCase, Config) ->
-    {ok, _} = emqx_cluster_rpc:start_link(node(), emqx_cluster_rpc, 1000),
     emqx_authn_test_lib:delete_authenticators(
         [authentication],
         ?GLOBAL

+ 7 - 5
apps/emqx_gcp_device/test/emqx_gcp_device_authn_SUITE.erl

@@ -23,7 +23,9 @@ all() ->
 
 init_per_suite(Config0) ->
     ok = snabbkaffe:start_trace(),
-    emqx_common_test_helpers:start_apps([emqx_conf, emqx_authn, emqx_gcp_device]),
+    Apps = emqx_cth_suite:start([emqx, emqx_conf, emqx_authn, emqx_gcp_device], #{
+        work_dir => ?config(priv_dir, Config0)
+    }),
     ValidExpirationTime = erlang:system_time(second) + 3600,
     ValidJWT = generate_jws(ValidExpirationTime),
     ExpiredJWT = generate_jws(0),
@@ -35,16 +37,16 @@ init_per_suite(Config0) ->
         {valid_jwt, ValidJWT},
         {expired_jwt, ExpiredJWT},
         {valid_client, ValidClient},
-        {expired_client, ExpiredClient}
+        {expired_client, ExpiredClient},
+        {apps, Apps}
         | Config0
     ].
 
-end_per_suite(_) ->
-    _ = emqx_common_test_helpers:stop_apps([emqx_authn, emqx_gcp_device]),
+end_per_suite(Config) ->
+    ok = emqx_cth_suite:stop(?config(apps, Config)),
     ok.
 
 init_per_testcase(_, Config) ->
-    {ok, _} = emqx_cluster_rpc:start_link(node(), emqx_cluster_rpc, 1000),
     Config.
 
 end_per_testcase(_Case, Config) ->