From 8aa27488b6b97257789830c4ec05fc0236bc02d0 Mon Sep 17 00:00:00 2001 From: ieQu1 <99872536+ieQu1@users.noreply.github.com> Date: Tue, 18 Jun 2024 05:31:44 +0200 Subject: [PATCH] test: Disable certain DS-related suites in CE --- .../emqx_persistent_session_ds_SUITE.erl | 18 +++-- .../test/emqx_persistent_messages_SUITE.erl | 16 ++--- .../test/emqx_dashboard_monitor_SUITE.erl | 72 +++++++++---------- .../test/emqx_ds_backends_SUITE.erl | 33 ++++----- apps/emqx_ds_builtin_raft/rebar.config | 3 +- .../test/emqx_ds_test_helpers.erl | 11 +++ apps/emqx_management/test/emqx_mgmt_SUITE.erl | 37 +++++----- 7 files changed, 98 insertions(+), 92 deletions(-) diff --git a/apps/emqx/integration_test/emqx_persistent_session_ds_SUITE.erl b/apps/emqx/integration_test/emqx_persistent_session_ds_SUITE.erl index 63c89c595..920e2528f 100644 --- a/apps/emqx/integration_test/emqx_persistent_session_ds_SUITE.erl +++ b/apps/emqx/integration_test/emqx_persistent_session_ds_SUITE.erl @@ -25,11 +25,16 @@ all() -> emqx_common_test_helpers:all(?MODULE). init_per_suite(Config) -> - TCApps = emqx_cth_suite:start( - app_specs(), - #{work_dir => emqx_cth_suite:work_dir(Config)} - ), - [{tc_apps, TCApps} | Config]. + case emqx_ds_test_helpers:skip_if_norepl() of + false -> + TCApps = emqx_cth_suite:start( + app_specs(), + #{work_dir => emqx_cth_suite:work_dir(Config)} + ), + [{tc_apps, TCApps} | Config]; + Yes -> + Yes + end. end_per_suite(Config) -> TCApps = ?config(tc_apps, Config), @@ -60,8 +65,7 @@ init_per_testcase(t_session_gc = TestCase, Config) -> "\n heartbeat_interval = 500ms " "\n session_gc_interval = 1s " "\n session_gc_batch_size = 2 " - "\n }\n" - "durable_storage.messages.backend = builtin_local\n" + "\n }" }, Cluster = cluster(Opts), ClusterOpts = #{work_dir => emqx_cth_suite:work_dir(TestCase, Config)}, diff --git a/apps/emqx/test/emqx_persistent_messages_SUITE.erl b/apps/emqx/test/emqx_persistent_messages_SUITE.erl index d17c08bce..d9c0a61f3 100644 --- a/apps/emqx/test/emqx_persistent_messages_SUITE.erl +++ b/apps/emqx/test/emqx_persistent_messages_SUITE.erl @@ -33,11 +33,11 @@ all() -> emqx_common_test_helpers:all(?MODULE). init_per_suite(Config) -> - case is_standalone() of - true -> - {skip, standalone_not_supported}; + case emqx_ds_test_helpers:skip_if_norepl() of false -> - Config + Config; + Yes -> + Yes end. end_per_suite(_Config) -> @@ -595,11 +595,3 @@ on_message_dropped(Msg, Context, Res, TestPid) -> ErrCtx = #{msg => Msg, ctx => Context, res => Res}, ct:pal("this hook should not be called.\n ~p", [ErrCtx]), exit(TestPid, {hookpoint_called, ErrCtx}). - -is_standalone() -> - try - emqx_conf:module_info(), - false - catch - error:undef -> true - end. diff --git a/apps/emqx_dashboard/test/emqx_dashboard_monitor_SUITE.erl b/apps/emqx_dashboard/test/emqx_dashboard_monitor_SUITE.erl index 2760576a3..8f18aa685 100644 --- a/apps/emqx_dashboard/test/emqx_dashboard_monitor_SUITE.erl +++ b/apps/emqx_dashboard/test/emqx_dashboard_monitor_SUITE.erl @@ -56,18 +56,11 @@ %% CT boilerplate %%-------------------------------------------------------------------- --if(?EMQX_RELEASE_EDITION == ee). all() -> [ {group, common}, {group, persistent_sessions} ]. --else. -all() -> - [ - {group, common} - ]. --endif. groups() -> AllTCs = emqx_common_test_helpers:all(?MODULE), @@ -89,37 +82,42 @@ end_per_suite(_Config) -> ok. init_per_group(persistent_sessions = Group, Config) -> - AppSpecsFn = fun(Enable) -> - Port = - case Enable of - true -> "18083"; - false -> "0" + case emqx_ds_test_helpers:skip_if_norepl() of + false -> + AppSpecsFn = fun(Enable) -> + Port = + case Enable of + true -> "18083"; + false -> "0" + end, + [ + emqx_conf, + {emqx, "durable_sessions {enable = true}"}, + {emqx_retainer, ?BASE_RETAINER_CONF}, + emqx_management, + emqx_mgmt_api_test_util:emqx_dashboard( + lists:concat([ + "dashboard.listeners.http { bind = " ++ Port ++ " }\n", + "dashboard.sample_interval = 1s\n", + "dashboard.listeners.http.enable = " ++ atom_to_list(Enable) + ]) + ) + ] end, - [ - emqx_conf, - {emqx, "durable_sessions {enable = true}"}, - {emqx_retainer, ?BASE_RETAINER_CONF}, - emqx_management, - emqx_mgmt_api_test_util:emqx_dashboard( - lists:concat([ - "dashboard.listeners.http { bind = " ++ Port ++ " }\n", - "dashboard.sample_interval = 1s\n", - "dashboard.listeners.http.enable = " ++ atom_to_list(Enable) - ]) - ) - ] - end, - NodeSpecs = [ - {dashboard_monitor1, #{apps => AppSpecsFn(true)}}, - {dashboard_monitor2, #{apps => AppSpecsFn(false)}} - ], - Nodes = - [N1 | _] = emqx_cth_cluster:start( - NodeSpecs, - #{work_dir => emqx_cth_suite:work_dir(Group, Config)} - ), - ?ON(N1, {ok, _} = emqx_common_test_http:create_default_app()), - [{cluster, Nodes} | Config]; + NodeSpecs = [ + {dashboard_monitor1, #{apps => AppSpecsFn(true)}}, + {dashboard_monitor2, #{apps => AppSpecsFn(false)}} + ], + Nodes = + [N1 | _] = emqx_cth_cluster:start( + NodeSpecs, + #{work_dir => emqx_cth_suite:work_dir(Group, Config)} + ), + ?ON(N1, {ok, _} = emqx_common_test_http:create_default_app()), + [{cluster, Nodes} | Config]; + Yes -> + Yes + end; init_per_group(common = Group, Config) -> Apps = emqx_cth_suite:start( [ diff --git a/apps/emqx_ds_backends/test/emqx_ds_backends_SUITE.erl b/apps/emqx_ds_backends/test/emqx_ds_backends_SUITE.erl index 6b27c307d..c6d2db224 100644 --- a/apps/emqx_ds_backends/test/emqx_ds_backends_SUITE.erl +++ b/apps/emqx_ds_backends/test/emqx_ds_backends_SUITE.erl @@ -550,19 +550,9 @@ delete(DB, It0, Selector, BatchSize, Acc) -> %% CT callbacks --if(?EMQX_RELEASE_EDITION == ee). all() -> [{group, builtin_local}, {group, builtin_raft}]. -%% kernel-10 OTP application (OTP 27) introduces -%% `optional_applications` application spec flag. Once we migrate to -%% OTP27, this won't be needed, as application controller will -%% automatically load raft backend when available: --else. -all() -> - [{group, builtin_local}]. --endif. - groups() -> TCs = emqx_common_test_helpers:all(?MODULE), [ @@ -578,15 +568,20 @@ init_per_group(builtin_local, Config) -> }, [{ds_conf, Conf} | Config]; init_per_group(builtin_raft, Config) -> - Conf = #{ - backend => builtin_raft, - storage => {emqx_ds_storage_reference, #{}}, - n_shards => ?N_SHARDS, - n_sites => 1, - replication_factor => 3, - replication_options => #{} - }, - [{ds_conf, Conf} | Config]. + case emqx_ds_test_helpers:skip_if_norepl() of + false -> + Conf = #{ + backend => builtin_raft, + storage => {emqx_ds_storage_reference, #{}}, + n_shards => ?N_SHARDS, + n_sites => 1, + replication_factor => 3, + replication_options => #{} + }, + [{ds_conf, Conf} | Config]; + Yes -> + Yes + end. end_per_group(_Group, Config) -> Config. diff --git a/apps/emqx_ds_builtin_raft/rebar.config b/apps/emqx_ds_builtin_raft/rebar.config index d70aa75e0..2d2671571 100644 --- a/apps/emqx_ds_builtin_raft/rebar.config +++ b/apps/emqx_ds_builtin_raft/rebar.config @@ -1,5 +1,6 @@ %% -*- mode:erlang -*- {deps, [ - {emqx_durable_storage, {path, "../emqx_durable_storage"}} + {emqx_durable_storage, {path, "../emqx_durable_storage"}}, + {ra, "2.7.3"} ]}. diff --git a/apps/emqx_durable_storage/test/emqx_ds_test_helpers.erl b/apps/emqx_durable_storage/test/emqx_ds_test_helpers.erl index 7130041ec..ba9589e97 100644 --- a/apps/emqx_durable_storage/test/emqx_ds_test_helpers.erl +++ b/apps/emqx_durable_storage/test/emqx_ds_test_helpers.erl @@ -26,6 +26,17 @@ emqx_ds_test_helpers:on(NODE, fun() -> BODY end) ). +skip_if_norepl() -> + try emqx_release:edition() of + ee -> + false; + _ -> + {skip, no_ds_replication} + catch + error:undef -> + {skip, standalone_not_supported} + end. + -spec on([node()] | node(), fun(() -> A)) -> A | [A]. on(Node, Fun) when is_atom(Node) -> [Ret] = on([Node], Fun), diff --git a/apps/emqx_management/test/emqx_mgmt_SUITE.erl b/apps/emqx_management/test/emqx_mgmt_SUITE.erl index e5de64b5a..0cde87465 100644 --- a/apps/emqx_management/test/emqx_mgmt_SUITE.erl +++ b/apps/emqx_management/test/emqx_mgmt_SUITE.erl @@ -56,22 +56,27 @@ init_per_group(persistence_disabled, Config) -> | Config ]; init_per_group(persistence_enabled, Config) -> - Apps = emqx_cth_suite:start( - [ - {emqx, - "durable_sessions {\n" - " enable = true\n" - " heartbeat_interval = 100ms\n" - " renew_streams_interval = 100ms\n" - "}"}, - emqx_management - ], - #{work_dir => emqx_cth_suite:work_dir(Config)} - ), - [ - {apps, Apps} - | Config - ]; + case emqx_ds_test_helpers:skip_if_norepl() of + false -> + Apps = emqx_cth_suite:start( + [ + {emqx, + "durable_sessions {\n" + " enable = true\n" + " heartbeat_interval = 100ms\n" + " renew_streams_interval = 100ms\n" + "}"}, + emqx_management + ], + #{work_dir => emqx_cth_suite:work_dir(Config)} + ), + [ + {apps, Apps} + | Config + ]; + Yes -> + Yes + end; init_per_group(cm_registry_enabled, Config) -> [{emqx_config, "broker.enable_session_registry = true"} | Config]; init_per_group(cm_registry_disabled, Config) ->