big-r81 commented on code in PR #5831:
URL: https://github.com/apache/couchdb/pull/5831#discussion_r2638989263
##########
src/couch/src/test_util.erl:
##########
@@ -81,61 +81,22 @@ start_couch() ->
start_couch(ExtraApps) ->
start_couch(?CONFIG_CHAIN, ExtraApps).
-% This function starts CouchDB with optional extra apps in a dedicated
-% directory under tmp/couchdb-tests/<uuid>/ — That is, all instances
-% run isolated so that if more than one runs at a time, it does not
-% interfere with any of the others.
-% The sub-directories here are etc/ log/ and data/ for configuration
-% logs and databases and view indexes respectively.
-% The function copies the initial bespoke test-ini files to the new
-% random directory and configures CouchDB to use those.
-% The two pieces of state created here are the random dir in the file system
and
-% the process env var {config, ini_files} that is read by couch_config on
-% startup. These need to be reset at the right points in time.
-% the random dir is deleted and the env var reset when CouchDB is stopped.
-% Note: there is currently a case where stop_couch/0 could be called and
-% the file system cleanup can’t be run because we don’t get passed the test
-% context with the random directory value. At the moment stop_couch/0 is not
-% used anywhere, tho. Maybe we should remove it?
start_couch(IniFiles, ExtraApps) ->
- RandomDir = filename:join([builddir(), "tmp", "couchdb-tests",
couch_uuids:random()]),
- RandomEtcDir = filename:join([RandomDir, "etc"]),
- RandomDataDir = ?b2l(filename:join([RandomDir, "data"])),
- RandomLogFile = ?b2l(filename:join([RandomDir, "log", "couch.log"])),
-
- ok = filelib:ensure_path(RandomDir),
- ok = filelib:ensure_path(RandomEtcDir),
- ok = filelib:ensure_path(RandomDataDir),
- ok = filelib:ensure_dir(RandomLogFile),
-
- RandomIniFiles = lists:map(
- fun(SourceFile) ->
- TargetFileName = lists:last(filename:split(SourceFile)),
- TargetFile = filename:join([RandomEtcDir, TargetFileName]),
- {ok, _} = file:copy(SourceFile, TargetFile),
- ?b2l(TargetFile)
- end,
- IniFiles
- ),
load_applications_with_stats(),
- ok = application:set_env(config, ini_files, RandomIniFiles),
+ ok = application:set_env(config, ini_files, IniFiles),
Apps = start_applications(?DEFAULT_APPS ++ ExtraApps),
-
- ok = config:set("couchdb", "database_dir", RandomDataDir, false),
- ok = config:set("couchdb", "view_index_dir", RandomDataDir, false),
- ok = config:set("log", "file", RandomLogFile, false),
ok = config:delete("compactions", "_default", false),
- #test_context{started = Apps, dir = RandomDir}.
+ #test_context{started = Apps}.
stop_couch() ->
ok = stop_applications(?DEFAULT_APPS).
-stop_couch(#test_context{started = Apps, dir = RandomDir}) ->
- % deletion now happens in Makefile
+stop_couch(#test_context{started = Apps}) ->
% file:del_dir_r(RandomDir),
Review Comment:
small nit: comment is now obsolet too (RandomDir)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]