Skip to content
Snippets Groups Projects
Commit e0e9eb0a authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

A fix and a test case for Bug#726778

A fix and a test case for Bug#726778 "Gopt broke wal_dir and
snap_dir: they are no longer relative to work_dir".

Ensure that snap_dir and xlog_dir can be relative to
work_dir.
Ensure that chdir happens before we handle --init-storage.
Do not mix declarations and definitions for recovery_state.
Add a test case to args.test.
parent a6c1f381
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,7 @@ char *cfg_filename_fullpath = NULL;
struct tbuf *cfg_out = NULL;
char *binary_filename;
struct tarantool_cfg cfg;
struct recovery_state *recovery_state;
bool init_storage, booting = true;
......@@ -416,27 +417,6 @@ main(int argc, char **argv)
panic("can't load config:"
"%.*s", cfg_out->len, (char *)cfg_out->data);
#ifdef STORAGE
if (gopt_arg(opt, 'C', &cat_filename)) {
initialize_minimal();
if (access(cat_filename, R_OK) == -1) {
say_syserror("access(\"%s\")", cat_filename);
exit(EX_OSFILE);
}
return mod_cat(cat_filename);
}
if (gopt(opt, 'I')) {
init_storage = true;
initialize_minimal();
mod_init();
next_lsn(recovery_state, 1);
confirm_lsn(recovery_state, 1);
snapshot_save(recovery_state, mod_snapshot);
exit(EXIT_SUCCESS);
}
#endif
if (gopt_arg(opt, 'g', &cfg_paramname)) {
tarantool_cfg_iterator_t *i;
char *key, *value;
......@@ -494,6 +474,27 @@ main(int argc, char **argv)
#endif
}
#ifdef STORAGE
if (gopt_arg(opt, 'C', &cat_filename)) {
initialize_minimal();
if (access(cat_filename, R_OK) == -1) {
say_syserror("access(\"%s\")", cat_filename);
exit(EX_OSFILE);
}
return mod_cat(cat_filename);
}
if (gopt(opt, 'I')) {
init_storage = true;
initialize_minimal();
mod_init();
next_lsn(recovery_state, 1);
confirm_lsn(recovery_state, 1);
snapshot_save(recovery_state, mod_snapshot);
exit(EXIT_SUCCESS);
}
#endif
if (gopt(opt, 'D'))
daemonize(1, 1);
......
......@@ -96,7 +96,7 @@ struct recovery_state {
bool finalize;
/* pointer to user supplied custom data */
/* Points to module-specific state */
void *data;
};
......
......@@ -31,7 +31,7 @@
#include <util.h>
#include <log_io.h>
struct recovery_state *recovery_state;
extern struct recovery_state *recovery_state;
void mod_init(void);
struct tarantool_cfg;
i32 mod_check_config(struct tarantool_cfg *conf);
......
......@@ -65,3 +65,18 @@ tarantool_silverbox --version
tarantool_silverbox -V
1.minor.patch-<rev>-<commit>
#
# A test case for Bug#726778 "Gopt broke wal_dir and snap_dir: they are no
# longer relative to work_dir".
# https://bugs.launchpad.net/tarantool/+bug/726778
# After addition of gopt(), we started to chdir() to the working
# directory after option parsing.
# Verify that this is not the case, and snap_dir and xlog_dir
# can be relative to work_dir.
tarantool_silverbox --config=bug726778.cfg --init-storage
tarantool_silverbox: namespace 0 successfully configured
tarantool_silverbox: creating `snapshots/00000000000000000001.snap.inprogress'
tarantool_silverbox: saving snapshot `snapshots/00000000000000000001.snap'
tarantool_silverbox: done
......@@ -13,3 +13,31 @@ sys.stdout.push_filter("(\d)\.\d\.\d(-\d+-\w+)?", "\\1.minor.patch-<rev>-<commit
server.test_option("--version")
server.test_option("-V ")
sys.stdout.pop_filter()
print """#
# A test case for Bug#726778 "Gopt broke wal_dir and snap_dir: they are no
# longer relative to work_dir".
# https://bugs.launchpad.net/tarantool/+bug/726778
# After addition of gopt(), we started to chdir() to the working
# directory after option parsing.
# Verify that this is not the case, and snap_dir and xlog_dir
# can be relative to work_dir.
"""
import shutil
shutil.rmtree(os.path.join(vardir, "bug726778"), True)
cfg = os.path.join(vardir, "bug726778.cfg")
os.mkdir(os.path.join(vardir, "bug726778"))
os.mkdir(os.path.join(vardir, "bug726778/snapshots"))
os.mkdir(os.path.join(vardir, "bug726778/xlogs"))
os.symlink(os.path.abspath("box/bug726778.cfg"), cfg)
sys.stdout.push_filter("(/\S+)+/tarantool", "tarantool")
server.test_option("--config=bug726778.cfg --init-storage")
sys.stdout.pop_filter()
os.unlink(cfg)
shutil.rmtree(os.path.join(vardir, "bug726778"))
# Args filter cleanup
# vim: syntax=python
#
# Used in args.test
#
slab_alloc_arena = 0.1
pid_file = "box.pid"
work_dir = "bug726778"
snap_dir = "snapshots"
wal_dir = "xlogs"
# Use -a not -a to work correctly on FreeBSD
#
logger="tee -a tarantool.log"
primary_port = 33013
secondary_port = 33014
admin_port = 33015
rows_per_wal = 50
namespace[0].enabled = 1
namespace[0].index[0].type = "HASH"
namespace[0].index[0].unique = 1
namespace[0].index[0].key_field[0].fieldno = 0
namespace[0].index[0].key_field[0].type = "NUM"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment