ctdb-tools: Add event daemon config options to config tool
authorAmitay Isaacs <amitay@gmail.com>
Tue, 17 Apr 2018 02:38:30 +0000 (12:38 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 17 May 2018 02:04:30 +0000 (04:04 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/common/conf_tool.c
ctdb/tests/cunit/config_test_001.sh
ctdb/tests/cunit/config_test_003.sh [new file with mode: 0755]
ctdb/wscript

index 1ee4b027de7ec363b0f053852a1c8970637c7994..d37f973637697a56de96127b606d766b09933cc3 100644 (file)
@@ -29,6 +29,7 @@
 #include "common/path.h"
 
 #include "common/logging_conf.h"
+#include "event/event_conf.h"
 
 #include "common/conf_tool.h"
 
@@ -236,6 +237,7 @@ int conf_tool_run(struct conf_tool_context *ctx, int *result)
 
        /* Call functions to initialize config sections/variables */
        logging_conf_init(ctx->conf, NULL);
+       event_conf_init(ctx->conf);
 
        if (! conf_valid(ctx->conf)) {
                D_ERR("Failed to define configuration options\n");
index 084f1a3b29d391984a6191425b296624f17aeb54..8387f7df5cc92bfd62d664a3000a6d8c6d253bba 100755 (executable)
@@ -22,6 +22,8 @@ ok <<EOF
 [logging]
        # location = ${logging_location}
        # log level = ERROR
+[event]
+       # debug script = 
 EOF
 unit_test ctdb-config dump
 
diff --git a/ctdb/tests/cunit/config_test_003.sh b/ctdb/tests/cunit/config_test_003.sh
new file mode 100755 (executable)
index 0000000..28b0622
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+PATH="$PATH:$CTDB_SCRIPTS_TOOLS_HELPER_DIR"
+
+setup_ctdb_base "${TEST_VAR_DIR}" "cunit"
+
+conffile="${CTDB_BASE}/ctdb.conf"
+scriptfile="${CTDB_BASE}/debug-hung-script.sh"
+
+remove_files ()
+{
+       rm -f "$conffile"
+}
+
+test_cleanup remove_files
+
+cat > "$conffile" <<EOF
+EOF
+
+ok <<EOF
+EOF
+unit_test ctdb-config get "event" "debug script"
+
+cat > "$conffile" <<EOF
+[event]
+    debug script = debug-hung-script.sh
+EOF
+
+touch "$scriptfile"
+
+required_result 22 <<EOF
+debug script $scriptfile is not executable
+conf: validation for option "debug script" failed
+Failed to load config file $conffile
+EOF
+unit_test ctdb-config validate
+
+chmod +x "$scriptfile"
+
+ok_null
+unit_test ctdb-config validate
+
+rm -f "$scriptfile"
+
+required_result 22 <<EOF
+debug script $scriptfile does not exist
+conf: validation for option "debug script" failed
+Failed to load config file $conffile
+EOF
+unit_test ctdb-config validate
index 8c4c97b19ccbc127b94e4dd39c1b0e2a07e11b95..430926c3924bc4efba934562f9e65b9324701e14 100644 (file)
@@ -472,6 +472,7 @@ def build(bld):
                      source='common/conf_tool.c',
                      cflags='-DCTDB_CONF_TOOL',
                      deps='''ctdb-logging-conf
+                             ctdb-event-conf
                              ctdb-util samba-util talloc replace popt''',
                      install_path='${CTDB_HELPER_BINDIR}')