1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

ctdb-tools: Add database config options to config tool

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2018-05-11 22:42:42 +10:00 committed by Amitay Isaacs
parent 52d2701279
commit 65d9d1e743
4 changed files with 108 additions and 0 deletions

View File

@ -30,6 +30,7 @@
#include "common/logging_conf.h"
#include "cluster/cluster_conf.h"
#include "database/database_conf.h"
#include "event/event_conf.h"
#include "common/conf_tool.h"
@ -239,6 +240,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);
cluster_conf_init(ctx->conf);
database_conf_init(ctx->conf);
event_conf_init(ctx->conf);
if (! conf_valid(ctx->conf)) {

View File

@ -17,6 +17,15 @@ test_cleanup remove_files
# Get the default values that are dependent on install prefix
logging_location=$(ctdb-config get "logging" "location")
database_volatile_dbdir=$(ctdb-config get \
"database" \
"volatile database directory")
database_persistent_dbdir=$(ctdb-config get \
"database" \
"persistent database directory")
database_state_dbdir=$(ctdb-config get \
"database" \
"state database directory")
ok <<EOF
[logging]
@ -26,6 +35,11 @@ ok <<EOF
# transport = tcp
# node address =
# recovery lock =
[database]
# volatile database directory = ${database_volatile_dbdir}
# persistent database directory = ${database_persistent_dbdir}
# state database directory = ${database_state_dbdir}
# lock debug script =
[event]
# debug script =
EOF

View File

@ -0,0 +1,91 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
PATH="$PATH:$CTDB_SCRIPTS_HELPER_BINDIR"
setup_ctdb_base "${TEST_VAR_DIR}" "cunit"
conffile="${CTDB_BASE}/ctdb.conf"
scriptfile="${CTDB_BASE}/debug_locks.sh"
dbdir="${CTDB_BASE}/dbdir"
dbdir_volatile="${dbdir}/volatile"
dbdir_persistent="${dbdir}/persistent"
dbdir_state="${dbdir}/state"
remove_files ()
{
rm -f "$conffile" "$scriptfile"
}
test_cleanup remove_files
cat > "$conffile" <<EOF
[database]
volatile database directory = ${dbdir_volatile}
persistent database directory = ${dbdir_persistent}
state database directory = ${dbdir_state}
EOF
required_result 22 <<EOF
volatile database directory "${dbdir_volatile}" does not exist
conf: validation for option "volatile database directory" failed
Failed to load config file $conffile
EOF
unit_test ctdb-config validate
mkdir -p "$dbdir_volatile"
required_result 22 <<EOF
persistent database directory "${dbdir_persistent}" does not exist
conf: validation for option "persistent database directory" failed
Failed to load config file $conffile
EOF
unit_test ctdb-config validate
mkdir -p "$dbdir_persistent"
required_result 22 <<EOF
state database directory "${dbdir_state}" does not exist
conf: validation for option "state database directory" failed
Failed to load config file $conffile
EOF
unit_test ctdb-config validate
mkdir -p "$dbdir_state"
required_result 0 <<EOF
EOF
unit_test ctdb-config validate
ok <<EOF
EOF
unit_test ctdb-config get "database" "lock debug script"
cat > "$conffile" <<EOF
[database]
lock debug script = $scriptfile
EOF
touch "$scriptfile"
required_result 22 <<EOF
lock debug script $scriptfile is not executable
conf: validation for option "lock 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
lock debug script $scriptfile does not exist
conf: validation for option "lock debug script" failed
Failed to load config file $conffile
EOF
unit_test ctdb-config validate

View File

@ -482,6 +482,7 @@ def build(bld):
deps='''ctdb-logging-conf
ctdb-event-conf
ctdb-cluster-conf
ctdb-database-conf
ctdb-util samba-util talloc replace popt''',
install_path='${CTDB_HELPER_BINDIR}')