commit 53d02c4d927bf1d20d74a9212d9c3dfaa0f2e3c9 from: Georgiy Belyanin via: Alexander Turenko date: Thu Sep 26 09:52:01 2024 UTC test: specify the dir in the cluster helper The cluster helper in `test/config-luatest/cluster.lua` is used to define the clusters in an easy way. Though every time the `cluster.new` is called it creates a new temporary directory, which is not good when you're writing a test setting up the directory before the cluster start. This patch adds an `opts` object as the fourth parameter for `cluster.new` and makes the function use `opts.dir` as a key for specifying the directory to start the cluster. Example: ``` local dir = '/some/long/dir' local cluster_config = cbuilder:new(remote_config) :use_replicaset('r-001') :add_instance('i-001', {}) :config() -- The cluster will be started in a new temp directory. local cluster = cluster.new(g, cluster_config) -- The cluster will be started in '/some/long/dir'. local cluster = cluster.new(g, cluster_config, nil, { dir = dir }) ``` Needed for testing tarantool/tarantool-ee#870. NO_CHANGELOG=internal testing helper change NO_TEST=internal testing helper change NO_DOC=internal testing helper change commit - 38c6b0d38254d5ebde82cd469366955e808798b0 commit + 53d02c4d927bf1d20d74a9212d9c3dfaa0f2e3c9 blob - 156f1bc58737103fef41ec5f351ee038fa8c8aa0 blob + 34ef55fab0b2bb350b0ff9e7e907e6499abcdcba --- test/config-luatest/cluster.lua +++ test/config-luatest/cluster.lua @@ -204,13 +204,13 @@ local cluster_mt = { end } -local function new(g, config, server_opts) +local function new(g, config, server_opts, opts) assert(config._config == nil, "Please provide cbuilder:new():config()") assert(g.cluster == nil) -- Prepare a temporary directory and write a configuration -- file. - local dir = treegen.prepare_directory({}, {}) + local dir = opts and opts.dir or treegen.prepare_directory({}, {}) local config_file_rel = 'config.yaml' local config_file = treegen.write_file(dir, config_file_rel, yaml.encode(config))