summaryrefslogtreecommitdiffstats
path: root/src/test/cli/ceph-conf
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/cli/ceph-conf')
-rw-r--r--src/test/cli/ceph-conf/env-vs-args.t14
-rw-r--r--src/test/cli/ceph-conf/help.t44
-rw-r--r--src/test/cli/ceph-conf/invalid-args.t17
-rw-r--r--src/test/cli/ceph-conf/manpage.t33
-rw-r--r--src/test/cli/ceph-conf/option.t64
-rw-r--r--src/test/cli/ceph-conf/sections.t18
-rw-r--r--src/test/cli/ceph-conf/show-config-value.t39
-rw-r--r--src/test/cli/ceph-conf/show-config.t7
-rw-r--r--src/test/cli/ceph-conf/simple.t4
9 files changed, 240 insertions, 0 deletions
diff --git a/src/test/cli/ceph-conf/env-vs-args.t b/src/test/cli/ceph-conf/env-vs-args.t
new file mode 100644
index 000000000..edb42ad6d
--- /dev/null
+++ b/src/test/cli/ceph-conf/env-vs-args.t
@@ -0,0 +1,14 @@
+# we can use CEPH_CONF to override the normal configuration file location.
+ $ env CEPH_CONF=from-env ceph-conf -s foo bar
+ did not load config file, using default settings.
+ .* \-1 Errors while parsing config file! (re)
+ .* \-1 can't open from-env: \(2\) (No such file or directory)? (re)
+ .* \-1 Errors while parsing config file! (re)
+ .* \-1 can't open from-env: \(2\) (No such file or directory)? (re)
+ [1]
+
+# command-line arguments should override environment
+ $ env -u CEPH_CONF ceph-conf -c from-args
+ global_init: unable to open config file from search list from-args
+ [1]
+
diff --git a/src/test/cli/ceph-conf/help.t b/src/test/cli/ceph-conf/help.t
new file mode 100644
index 000000000..751b3a54a
--- /dev/null
+++ b/src/test/cli/ceph-conf/help.t
@@ -0,0 +1,44 @@
+ $ ceph-conf --help
+ Ceph configuration query tool
+
+ USAGE
+ ceph-conf <flags> <action>
+
+ ACTIONS
+ -L|--list-all-sections List all sections
+ -l|--list-sections <prefix> List sections with the given prefix
+ --filter-key <key> Filter section list to only include sections
+ with given key defined.
+ --filter-key-value <key>=<val> Filter section list to only include sections
+ with given key/value pair.
+ --lookup <key> Print a configuration setting to stdout.
+ Returns 0 (success) if the configuration setting is
+ found; 1 otherwise.
+ -r|--resolve-search search for the first file that exists and
+ can be opened in the resulted comma
+ delimited search list.
+ -D|--dump-all dump all variables.
+ --show-config-value <key> Print the corresponding ceph.conf value
+ that matches the specified key. Also searches
+ global defaults.
+
+ FLAGS
+ --name name Set type.id
+ [-s <section>] Add to list of sections to search
+ [--format plain|json|json-pretty]
+ dump variables in plain text, json or pretty
+ json
+ [--pid <pid>] Override the $pid when expanding options
+
+ If there is no action given, the action will default to --lookup.
+
+ EXAMPLES
+ [$] ceph-conf --name mon.0 -c /etc/ceph/ceph.conf 'mon addr' (re)
+ Find out what the value of 'mon addr' is for monitor 0.
+
+ [$] ceph-conf -l mon (re)
+ List sections beginning with 'mon'.
+
+ RETURN CODE
+ Return code will be 0 on success; error code otherwise.
+
diff --git a/src/test/cli/ceph-conf/invalid-args.t b/src/test/cli/ceph-conf/invalid-args.t
new file mode 100644
index 000000000..43cedf2da
--- /dev/null
+++ b/src/test/cli/ceph-conf/invalid-args.t
@@ -0,0 +1,17 @@
+ $ cat >test.conf <<EOF
+ > [bar]
+ > bar = green
+ > EOF
+
+# TODO output an error
+ $ ceph-conf -c test.conf broken
+ [1]
+
+ $ ceph-conf -c test.conf --name total.garbage
+ error parsing 'total.garbage': expected string of the form TYPE.ID, valid types are: auth, mon, osd, mds, mgr, client
+ [1]
+
+ $ ceph-conf -c test.conf -s bar
+ You must give an action, such as --lookup or --list-all-sections.
+ Pass --help for more help.
+ [1]
diff --git a/src/test/cli/ceph-conf/manpage.t b/src/test/cli/ceph-conf/manpage.t
new file mode 100644
index 000000000..425f27189
--- /dev/null
+++ b/src/test/cli/ceph-conf/manpage.t
@@ -0,0 +1,33 @@
+# setup
+ $ cat >foo.conf <<'EOF'
+ > ; ---------------------
+ > [group cephnet]
+ > addr = 10.3.14.0/24
+ >
+ > [global]
+ > pid file = /home/sage/ceph/src/out/$name.pid
+ >
+ > [osd]
+ > osd data = /mnt/osd$id
+ > [osd.3]
+ > host = cosd3
+ > EOF
+
+To extract the value of the "osd data" option for the osd0 daemon,
+
+ $ ceph-conf -c foo.conf "osd data" --name osd.0
+ /mnt/osd0
+
+This is equivalent to doing specifying sections [osd0], [osd.0],
+[osd], or [global], in that order of preference:
+
+# TODO the "admin" here seems like an actual bug
+
+ $ ceph-conf -c foo.conf "osd data" -s osd0 -s osd.0 -s osd -s global
+ /mnt/osdadmin
+
+To list all sections that begin with osd:
+
+ $ ceph-conf -c foo.conf -l osd
+ osd
+ osd.3
diff --git a/src/test/cli/ceph-conf/option.t b/src/test/cli/ceph-conf/option.t
new file mode 100644
index 000000000..194488438
--- /dev/null
+++ b/src/test/cli/ceph-conf/option.t
@@ -0,0 +1,64 @@
+ $ cat >test.conf <<EOF
+ > [bar]
+ > bar = green
+ > [foo]
+ > bar = blue
+ > [baz]
+ > bar = yellow
+ > [thud]
+ > bar = red
+ > [nobar]
+ > other = 42
+ > EOF
+
+ $ ceph-conf -c test.conf bar -s foo
+ blue
+
+# test the funny "equals sign" argument passing convention
+ $ ceph-conf --conf=test.conf bar -s foo
+ blue
+
+ $ ceph-conf --conf=test.conf -L
+ bar
+ baz
+ foo
+ nobar
+ thud
+
+ $ ceph-conf --conf=test.conf --list-all-sections
+ bar
+ baz
+ foo
+ nobar
+ thud
+
+ $ ceph-conf --conf=test.conf --list_all_sections
+ bar
+ baz
+ foo
+ nobar
+ thud
+
+# TODO man page stops in the middle of a sentence
+
+ $ ceph-conf -c test.conf bar -s xyzzy
+ [1]
+
+ $ ceph-conf -c test.conf bar -s xyzzy
+ [1]
+
+ $ ceph-conf -c test.conf bar -s xyzzy -s thud
+ red
+
+ $ ceph-conf -c test.conf bar -s nobar -s thud
+ red
+
+ $ ceph-conf -c test.conf bar -s thud -s baz
+ red
+
+ $ ceph-conf -c test.conf bar -s baz -s thud
+ yellow
+
+ $ ceph-conf -c test.conf bar -s xyzzy -s nobar -s thud -s baz
+ red
+
diff --git a/src/test/cli/ceph-conf/sections.t b/src/test/cli/ceph-conf/sections.t
new file mode 100644
index 000000000..63063cc9e
--- /dev/null
+++ b/src/test/cli/ceph-conf/sections.t
@@ -0,0 +1,18 @@
+ $ cat >test.conf <<EOF
+ > [bar]
+ > bar = green
+ > [foo]
+ > bar = blue
+ > [baz]
+ > bar = yellow
+ > [thud]
+ > bar = yellow
+ > EOF
+
+ $ ceph-conf -c test.conf -l bar
+ bar
+
+ $ ceph-conf -c test.conf -l b
+ bar
+ baz
+
diff --git a/src/test/cli/ceph-conf/show-config-value.t b/src/test/cli/ceph-conf/show-config-value.t
new file mode 100644
index 000000000..2e0528e93
--- /dev/null
+++ b/src/test/cli/ceph-conf/show-config-value.t
@@ -0,0 +1,39 @@
+
+# should reflect daemon defaults
+
+ $ ceph-conf -n osd.0 --show-config-value log_file -c /dev/null
+ /var/log/ceph/ceph-osd.0.log
+ $ CEPH_ARGS="--fsid 96a3abe6-7552-4635-a79b-f3c096ff8b95" ceph-conf -n osd.0 --show-config-value fsid -c /dev/null
+ 96a3abe6-7552-4635-a79b-f3c096ff8b95
+ $ ceph-conf -n osd.0 --show-config-value INVALID -c /dev/null
+ failed to get config option 'INVALID': option not found
+ [1]
+
+ $ cat > $TESTDIR/ceph.conf <<EOF
+ > [global]
+ > mon_host = \$public_network
+ > public_network = \$mon_host
+ > EOF
+ $ ceph-conf --show-config-value mon_host -c $TESTDIR/ceph.conf
+ variable expansion loop at mon_host=$public_network
+ expansion stack:
+ public_network=$mon_host
+ mon_host=$public_network
+ $mon_host
+ $ rm $TESTDIR/ceph.conf
+
+Name option test to strip the PID
+=================================
+ $ cat > $TESTDIR/ceph.conf <<EOF
+ > [client]
+ > admin socket = \$name.\$pid.asok
+ > [global]
+ > admin socket = \$name.asok
+ > EOF
+ $ ceph-conf --name client.admin --pid 133423 --show-config-value admin_socket -c $TESTDIR/ceph.conf
+ client.admin.133423.asok
+ $ ceph-conf --name mds.a --show-config-value admin_socket -c $TESTDIR/ceph.conf
+ mds.a.asok
+ $ ceph-conf --name osd.0 --show-config-value admin_socket -c $TESTDIR/ceph.conf
+ osd.0.asok
+ $ rm $TESTDIR/ceph.conf
diff --git a/src/test/cli/ceph-conf/show-config.t b/src/test/cli/ceph-conf/show-config.t
new file mode 100644
index 000000000..45405e4b7
--- /dev/null
+++ b/src/test/cli/ceph-conf/show-config.t
@@ -0,0 +1,7 @@
+ $ ceph-conf -n osd.0 --show-config -c /dev/null | grep ceph-osd
+ admin_socket = /var/run/ceph/ceph-osd.0.asok
+ log_file = /var/log/ceph/ceph-osd.0.log
+ mon_debug_dump_location = /var/log/ceph/ceph-osd.0.tdump
+ rgw_ops_log_file_path = /var/log/ceph/ops-log-ceph-osd.0.log
+ $ CEPH_ARGS="--fsid 96a3abe6-7552-4635-a79b-f3c096ff8b95" ceph-conf -n osd.0 --show-config -c /dev/null | grep fsid
+ fsid = 96a3abe6-7552-4635-a79b-f3c096ff8b95
diff --git a/src/test/cli/ceph-conf/simple.t b/src/test/cli/ceph-conf/simple.t
new file mode 100644
index 000000000..043ca2035
--- /dev/null
+++ b/src/test/cli/ceph-conf/simple.t
@@ -0,0 +1,4 @@
+ $ ceph-conf
+ You must give an action, such as --lookup or --list-all-sections.
+ Pass --help for more help.
+ [1]