blob: 70bf77f7939e089c664fe305cd8e2e2aa55af81c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
PATH="$PATH:$CTDB_SCRIPTS_TOOLS_HELPER_DIR"
setup_ctdb_base "${CTDB_TEST_TMP_DIR}" "ctdb-etc"
conffile="${CTDB_BASE}/ctdb.conf"
remove_files ()
{
rm -f "$conffile"
}
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]
# location = ${logging_location}
# log level = NOTICE
[cluster]
# transport = tcp
# node address =
# cluster lock =
# recovery lock =
# leader timeout = 5
# leader capability = true
[database]
# volatile database directory = ${database_volatile_dbdir}
# persistent database directory = ${database_persistent_dbdir}
# state database directory = ${database_state_dbdir}
# lock debug script =
# tdb mutexes = true
[event]
# debug script =
[failover]
# disabled = false
[legacy]
# realtime scheduling = true
# lmaster capability = true
# start as stopped = false
# start as disabled = false
# script log level = ERROR
EOF
unit_test ctdb-config dump
required_result 2 <<EOF
Failed to load config file $conffile
EOF
unit_test ctdb-config validate
cat > "$conffile" <<EOF
EOF
ok_null
unit_test ctdb-config validate
cat > "$conffile" <<EOF
[foobar]
EOF
required_result 22 <<EOF
conf: unknown section [foobar]
Failed to load config file $conffile
EOF
unit_test ctdb-config validate
cat > "$conffile" <<EOF
foobar = cat
EOF
required_result 22 <<EOF
conf: unknown section for option "foobar"
Failed to load config file $conffile
EOF
unit_test ctdb-config validate
required_result 2 <<EOF
Configuration option [section] -> "key" not defined
EOF
unit_test ctdb-config get section key
# Confirm that an unknown key doesn't stop the rest of the file from
# loading
cat > "$conffile" <<EOF
[database]
unknown key = 123
[logging]
log level = debug
EOF
required_error EINVAL <<EOF
conf: unknown option [database] -> "unknown key"
Failed to load config file $conffile
EOF
unit_test ctdb-config validate
ok <<EOF
debug
EOF
unit_test ctdb-config get "logging" "log level"
|