Skip to content

Commit 05ddf8c

Browse files
committed
don't share the data directory by default
fix issues during test when the data directory was shared by 2 vm instances
1 parent f93be34 commit 05ddf8c

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

config/sys.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
]},
88

99
{barrel, [
10-
{data_dir, "data"},
10+
%%{data_dir, "data"},
1111
{in_memory, false}
1212
]},
1313

src/core/barrel_store.erl

+5-2
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,13 @@ db_properties(DbId) ->
132132

133133
get_conf() -> gen_server:call(?MODULE, get_conf).
134134

135+
default_dir() ->
136+
filename:join([?DATA_DIR, node()]).
137+
135138
-spec data_dir() -> string().
136139
data_dir() ->
137-
Dir = application:get_env(barrel, data_dir, ?DATA_DIR),
138-
_ = filelib:ensure_dir(filename:join([".",Dir, "dummy"])),
140+
Dir = application:get_env(barrel, data_dir, default_dir()),
141+
_ = filelib:ensure_dir(filename:join([".", Dir, "dummy"])),
139142
Dir.
140143

141144

test/replicate/barrel_replicate_SUITE.erl

+7-3
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ persistent_replication(_Config) ->
162162
ok = barrel_replicate:stop_replication(RepId),
163163
[{RepId, {true, nil, nil}}] = ets:lookup(replication_ids, RepId),
164164
[] = ets:lookup(replication_ids, Pid),
165-
{ok, [AllConfig2]} = file:consult("data/replication.config"),
165+
{ok, [AllConfig2]} = file:consult(config_file()),
166166
RepConfig2 = maps:get(<<"a">>, AllConfig2),
167167
#{ <<"source">> := <<"source">>, <<"target">> := <<"testdb">>, options := Options} = RepConfig2,
168168
ok = barrel_replicate:delete_replication(RepId),
169-
{ok, [AllConfig3]} = file:consult("data/replication.config"),
169+
{ok, [AllConfig3]} = file:consult(config_file()),
170170
undefined = maps:get(RepId, AllConfig3, undefined),
171171
[] = ets:lookup(replication_ids, RepId),
172172
ok.
@@ -195,7 +195,7 @@ restart_persistent_replication(_Config) ->
195195
{'EXIT', {badarg, _}} = (catch ets:lookup(replication_ids, RepId)),
196196
timer:sleep(200),
197197
ok = barrel_replicate:delete_replication(RepId),
198-
{ok, [AllConfig3]} = file:consult("data/replication.config"),
198+
{ok, [AllConfig3]} = file:consult(config_file()),
199199
undefined = maps:get(RepId, AllConfig3, undefined),
200200
[] = ets:lookup(replication_ids, RepId),
201201
ok.
@@ -390,3 +390,7 @@ read_checkpoint_doc(Db, RepId) ->
390390

391391
checkpoint_docid(RepId) ->
392392
<<"replication-checkpoint-", RepId/binary>>.
393+
394+
395+
config_file() ->
396+
filename:join([barrel_store:data_dir(), "replication.config"]).

0 commit comments

Comments
 (0)