chore(ft): fix gen_rpc flakyness
This commit is contained in:
parent
228bf1a0ce
commit
c073914f75
|
@ -63,7 +63,6 @@
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export([
|
-export([
|
||||||
set_gen_rpc_stateless/0,
|
|
||||||
emqx_cluster/1,
|
emqx_cluster/1,
|
||||||
emqx_cluster/2,
|
emqx_cluster/2,
|
||||||
start_epmd/0,
|
start_epmd/0,
|
||||||
|
@ -293,12 +292,7 @@ read_schema_configs(no_schema, _ConfigFile) ->
|
||||||
ok;
|
ok;
|
||||||
read_schema_configs(Schema, ConfigFile) ->
|
read_schema_configs(Schema, ConfigFile) ->
|
||||||
NewConfig = generate_config(Schema, ConfigFile),
|
NewConfig = generate_config(Schema, ConfigFile),
|
||||||
lists:foreach(
|
application:set_env(NewConfig).
|
||||||
fun({App, Configs}) ->
|
|
||||||
[application:set_env(App, Par, Value) || {Par, Value} <- Configs]
|
|
||||||
end,
|
|
||||||
NewConfig
|
|
||||||
).
|
|
||||||
|
|
||||||
generate_config(SchemaModule, ConfigFile) when is_atom(SchemaModule) ->
|
generate_config(SchemaModule, ConfigFile) when is_atom(SchemaModule) ->
|
||||||
{ok, Conf0} = hocon:load(ConfigFile, #{format => richmap}),
|
{ok, Conf0} = hocon:load(ConfigFile, #{format => richmap}),
|
||||||
|
@ -617,16 +611,6 @@ ensure_quic_listener(Name, UdpPort, ExtraSettings) ->
|
||||||
listener_ports => [{Type :: tcp | ssl | ws | wss, inet:port_number()}]
|
listener_ports => [{Type :: tcp | ssl | ws | wss, inet:port_number()}]
|
||||||
}.
|
}.
|
||||||
|
|
||||||
-spec set_gen_rpc_stateless() -> ok.
|
|
||||||
set_gen_rpc_stateless() ->
|
|
||||||
%% When many tests run in an obscure order, it may occur that
|
|
||||||
%% `gen_rpc` started with its default settings before `emqx_conf`.
|
|
||||||
%% `gen_rpc` and `emqx_conf` have different default `port_discovery` modes,
|
|
||||||
%% so we reinitialize `gen_rpc` explicitly.
|
|
||||||
ok = application:stop(gen_rpc),
|
|
||||||
ok = application:set_env(gen_rpc, port_discovery, stateless),
|
|
||||||
ok = application:start(gen_rpc).
|
|
||||||
|
|
||||||
-spec emqx_cluster(cluster_spec()) -> [{shortname(), node_opts()}].
|
-spec emqx_cluster(cluster_spec()) -> [{shortname(), node_opts()}].
|
||||||
emqx_cluster(Specs) ->
|
emqx_cluster(Specs) ->
|
||||||
emqx_cluster(Specs, #{}).
|
emqx_cluster(Specs, #{}).
|
||||||
|
|
|
@ -42,12 +42,11 @@ groups() ->
|
||||||
].
|
].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_ft], set_special_configs(Config)),
|
ok = emqx_common_test_helpers:start_apps([emqx_ft], set_special_configs(Config)),
|
||||||
ok = emqx_common_test_helpers:set_gen_rpc_stateless(),
|
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
ok = emqx_common_test_helpers:stop_apps([emqx_ft, emqx_conf]),
|
ok = emqx_common_test_helpers:stop_apps([emqx_ft]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
set_special_configs(Config) ->
|
set_special_configs(Config) ->
|
||||||
|
|
|
@ -32,7 +32,7 @@ init_per_suite(Config) ->
|
||||||
ok = emqx_mgmt_api_test_util:init_suite(
|
ok = emqx_mgmt_api_test_util:init_suite(
|
||||||
[emqx_conf, emqx_ft], set_special_configs(Config)
|
[emqx_conf, emqx_ft], set_special_configs(Config)
|
||||||
),
|
),
|
||||||
ok = emqx_common_test_helpers:set_gen_rpc_stateless(),
|
{ok, _} = emqx:update_config([rpc, port_discovery], manual),
|
||||||
Config.
|
Config.
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
ok = emqx_mgmt_api_test_util:end_suite([emqx_ft, emqx_conf]),
|
ok = emqx_mgmt_api_test_util:end_suite([emqx_ft, emqx_conf]),
|
||||||
|
|
|
@ -26,6 +26,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_ft]),
|
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_ft]),
|
||||||
|
{ok, _} = emqx:update_config([rpc, port_discovery], manual),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
|
|
|
@ -39,11 +39,10 @@ groups() ->
|
||||||
].
|
].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_ft], set_special_configs(Config)),
|
ok = emqx_common_test_helpers:start_apps([emqx_ft], set_special_configs(Config)),
|
||||||
ok = emqx_common_test_helpers:set_gen_rpc_stateless(),
|
|
||||||
Config.
|
Config.
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
ok = emqx_common_test_helpers:stop_apps([emqx_ft, emqx_conf]),
|
ok = emqx_common_test_helpers:stop_apps([emqx_ft]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
set_special_configs(Config) ->
|
set_special_configs(Config) ->
|
||||||
|
|
|
@ -25,12 +25,11 @@
|
||||||
all() -> emqx_common_test_helpers:all(?MODULE).
|
all() -> emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_ft]),
|
ok = emqx_common_test_helpers:start_apps([emqx_ft]),
|
||||||
ok = emqx_common_test_helpers:set_gen_rpc_stateless(),
|
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
ok = emqx_common_test_helpers:stop_apps([emqx_ft, emqx_conf]),
|
ok = emqx_common_test_helpers:stop_apps([emqx_ft]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
init_per_testcase(_Case, Config) ->
|
init_per_testcase(_Case, Config) ->
|
||||||
|
|
|
@ -28,7 +28,7 @@ start_additional_node(Config, Node) ->
|
||||||
[
|
[
|
||||||
{apps, [emqx_ft]},
|
{apps, [emqx_ft]},
|
||||||
{join_to, SelfNode},
|
{join_to, SelfNode},
|
||||||
{configure_gen_rpc, false},
|
{configure_gen_rpc, true},
|
||||||
{env_handler, fun
|
{env_handler, fun
|
||||||
(emqx_ft) ->
|
(emqx_ft) ->
|
||||||
ok = emqx_config:put([file_transfer, storage], #{
|
ok = emqx_config:put([file_transfer, storage], #{
|
||||||
|
|
Loading…
Reference in New Issue