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.
---
core/tarantool.c | 43 ++++++++++++++++++++++---------------------
include/log_io.h | 2 +-
include/tarantool.h | 2 +-
test/box/args.result | 15 +++++++++++++++
test/box/args.test | 28 ++++++++++++++++++++++++++++
test/box/bug726778.cfg | 27 +++++++++++++++++++++++++++
6 files changed, 94 insertions(+), 23 deletions(-)
create mode 100644 test/box/bug726778.cfg
diff --git a/core/tarantool.c b/core/tarantool.c
index 67c74a2..0e6e4ca 100644
--- a/core/tarantool.c
+++ b/core/tarantool.c
@@ -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);
diff --git a/include/log_io.h b/include/log_io.h
index 64fe367..1280967 100644
--- a/include/log_io.h
+++ b/include/log_io.h
@@ -96,7 +96,7 @@ struct recovery_state {
bool finalize;
- /* pointer to user supplied custom data */
+ /* Points to module-specific state */
void *data;
};
diff --git a/include/tarantool.h b/include/tarantool.h
index 78b80b8..2e8d409 100644
--- a/include/tarantool.h
+++ b/include/tarantool.h
@@ -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);
diff --git a/test/box/args.result b/test/box/args.result
index 68b984b..70ecd41 100644
--- a/test/box/args.result
+++ b/test/box/args.result
@@ -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
+
diff --git a/test/box/args.test b/test/box/args.test
index fa25958..5648a87 100644
--- a/test/box/args.test
+++ b/test/box/args.test
@@ -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
diff --git a/test/box/bug726778.cfg b/test/box/bug726778.cfg
new file mode 100644
index 0000000..449c398
--- /dev/null
+++ b/test/box/bug726778.cfg
@@ -0,0 +1,27 @@
+#
+# 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"
+
--
1.7.0.4
_______________________________________________
Mailing list: https://launchpad.net/~tarantool-developers
Post to : [email protected]
Unsubscribe : https://launchpad.net/~tarantool-developers
More help : https://help.launchpad.net/ListHelp