Merge pull request #12440 from thalesmg/ds-fix-egress-startup-m-20240131
fix(ds): reduce egress start flakiness
This commit is contained in:
commit
06f9d762cd
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
%% Management API:
|
%% Management API:
|
||||||
-export([
|
-export([
|
||||||
|
base_dir/0,
|
||||||
open_db/2,
|
open_db/2,
|
||||||
update_db_config/2,
|
update_db_config/2,
|
||||||
add_generation/1,
|
add_generation/1,
|
||||||
|
@ -71,6 +72,8 @@
|
||||||
%% Type declarations
|
%% Type declarations
|
||||||
%%================================================================================
|
%%================================================================================
|
||||||
|
|
||||||
|
-define(APP, emqx_durable_storage).
|
||||||
|
|
||||||
-type db() :: atom().
|
-type db() :: atom().
|
||||||
|
|
||||||
%% Parsed topic.
|
%% Parsed topic.
|
||||||
|
@ -189,6 +192,10 @@
|
||||||
%% API funcions
|
%% API funcions
|
||||||
%%================================================================================
|
%%================================================================================
|
||||||
|
|
||||||
|
-spec base_dir() -> file:filename().
|
||||||
|
base_dir() ->
|
||||||
|
application:get_env(?APP, db_data_dir, emqx:data_dir()).
|
||||||
|
|
||||||
%% @doc Different DBs are completely independent from each other. They
|
%% @doc Different DBs are completely independent from each other. They
|
||||||
%% could represent something like different tenants.
|
%% could represent something like different tenants.
|
||||||
-spec open_db(db(), create_db_opts()) -> ok.
|
-spec open_db(db(), create_db_opts()) -> ok.
|
||||||
|
|
|
@ -417,7 +417,7 @@ ensure_tables() ->
|
||||||
ok = mria:wait_for_tables([?META_TAB, ?NODE_TAB, ?SHARD_TAB]).
|
ok = mria:wait_for_tables([?META_TAB, ?NODE_TAB, ?SHARD_TAB]).
|
||||||
|
|
||||||
ensure_site() ->
|
ensure_site() ->
|
||||||
Filename = filename:join(emqx:data_dir(), "emqx_ds_builtin_site.eterm"),
|
Filename = filename:join(emqx_ds:base_dir(), "emqx_ds_builtin_site.eterm"),
|
||||||
case file:consult(Filename) of
|
case file:consult(Filename) of
|
||||||
{ok, [Site]} ->
|
{ok, [Site]} ->
|
||||||
ok;
|
ok;
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
|
|
||||||
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
||||||
|
|
||||||
-define(APP, emqx_durable_storage).
|
|
||||||
-define(REF(ShardId), {via, gproc, {n, l, {?MODULE, ShardId}}}).
|
-define(REF(ShardId), {via, gproc, {n, l, {?MODULE, ShardId}}}).
|
||||||
|
|
||||||
%%================================================================================
|
%%================================================================================
|
||||||
|
@ -608,11 +607,7 @@ rocksdb_open(Shard, Options) ->
|
||||||
|
|
||||||
-spec db_dir(shard_id()) -> file:filename().
|
-spec db_dir(shard_id()) -> file:filename().
|
||||||
db_dir({DB, ShardId}) ->
|
db_dir({DB, ShardId}) ->
|
||||||
filename:join([base_dir(), atom_to_list(DB), binary_to_list(ShardId)]).
|
filename:join([emqx_ds:base_dir(), atom_to_list(DB), binary_to_list(ShardId)]).
|
||||||
|
|
||||||
-spec base_dir() -> file:filename().
|
|
||||||
base_dir() ->
|
|
||||||
application:get_env(?APP, db_data_dir, emqx:data_dir()).
|
|
||||||
|
|
||||||
-spec update_last_until(Schema, emqx_ds:time()) -> Schema when Schema :: shard_schema() | shard().
|
-spec update_last_until(Schema, emqx_ds:time()) -> Schema when Schema :: shard_schema() | shard().
|
||||||
update_last_until(Schema, Until) ->
|
update_last_until(Schema, Until) ->
|
||||||
|
|
|
@ -406,11 +406,16 @@ all() -> emqx_common_test_helpers:all(?MODULE).
|
||||||
suite() -> [{timetrap, {seconds, 20}}].
|
suite() -> [{timetrap, {seconds, 20}}].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
{ok, _} = application:ensure_all_started(emqx_durable_storage),
|
Apps = emqx_cth_suite:start(
|
||||||
Config.
|
[emqx_durable_storage],
|
||||||
|
#{work_dir => emqx_cth_suite:work_dir(Config)}
|
||||||
|
),
|
||||||
|
[{apps, Apps} | Config].
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(Config) ->
|
||||||
ok = application:stop(emqx_durable_storage).
|
Apps = ?config(apps, Config),
|
||||||
|
ok = emqx_cth_suite:stop(Apps),
|
||||||
|
ok.
|
||||||
|
|
||||||
init_per_testcase(TC, Config) ->
|
init_per_testcase(TC, Config) ->
|
||||||
ok = emqx_ds:open_db(TC, ?DEFAULT_CONFIG),
|
ok = emqx_ds:open_db(TC, ?DEFAULT_CONFIG),
|
||||||
|
|
Loading…
Reference in New Issue