-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CLI tests for osdmaptool and friends.
Uses a python package "cram" as test runner. Requires PIP (python-pip.deb) installed on the build machine, to actually run these tests. The cram application itself is included as a tarball that gets installed in a virtualenv when the tests are run. cram is GPL.
- Loading branch information
Tommi Virtanen
committed
Jan 12, 2011
1 parent
9a5a7fe
commit f4a0c2f
Showing
38 changed files
with
636 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/virtualenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$ cauthtool kring --create-keyring | ||
creating kring | ||
|
||
# TODO fix me | ||
$ cauthtool kring --add-key 'FAKEBASE64 foo' | ||
*** Caught signal (Segmentation fault) *** | ||
in thread [0-9a-f]{12} (re) | ||
ceph version .* (re) | ||
1: .* (re) | ||
2: .* (re) | ||
3: .* (re) | ||
4: .* (re) | ||
5: .* (re) | ||
6: .* (re) | ||
7: .* (re) | ||
8: .* (re) | ||
Segmentation fault | ||
[139] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
$ cauthtool kring --create-keyring | ||
creating kring | ||
|
||
$ cauthtool kring --add-key 'AQAK7yxNeF+nHBAA0SgSdbs8IkJrxroDeJ6SwQ== 18446744073709551615' | ||
added entity client.admin auth auth(auid = 18446744073709551615 key=AQAK7yxNeF+nHBAA0SgSdbs8IkJrxroDeJ6SwQ== with 0 caps) | ||
|
||
# cram makes matching escape-containing lines with regexps a bit ugly | ||
$ cauthtool kring --list | ||
client.admin | ||
\\t key: AQAK7yxNeF\+nHBAA0SgSdbs8IkJrxroDeJ6SwQ== \(esc\) (re) | ||
\\tauid: 18446744073709551615 \(esc\) (re) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
$ cauthtool kring --create-keyring --gen-key | ||
creating kring | ||
|
||
# TODO is this nice? | ||
$ cauthtool --cap osd 'broken' kring | ||
$ cauthtool kring --list|grep caps: | ||
\tcaps: [osd] broken (esc) | ||
|
||
# TODO is this nice? | ||
$ cauthtool --cap xyzzy 'broken' kring | ||
$ cauthtool kring --list|grep caps: | ||
\tcaps: [xyzzy] broken (esc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
$ cauthtool kring --create-keyring --gen-key | ||
creating kring | ||
|
||
$ cauthtool --cap osd 'allow rx pool=swimming' kring | ||
$ cauthtool kring --list|grep caps: | ||
\tcaps: [osd] allow rx pool=swimming (esc) | ||
|
||
# TODO it seems --cap overwrites all previous caps; is this wanted? | ||
$ cauthtool --cap mds 'allow' kring | ||
$ cauthtool kring --list|grep caps: | ||
\tcaps: [mds] allow (esc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$ cauthtool kring --create-keyring --gen-key | ||
creating kring | ||
|
||
$ cauthtool --cap osd 'allow rx pool=swimming' kring | ||
$ cauthtool kring --list|grep caps: | ||
\tcaps: [osd] allow rx pool=swimming (esc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$ cauthtool kring --create-keyring | ||
creating kring | ||
|
||
$ cauthtool kring --list | ||
|
||
$ cauthtool kring --gen-key | ||
|
||
# cram makes matching escape-containing lines with regexps a bit ugly | ||
$ cauthtool kring --list | ||
client.admin | ||
\\t key: [a-zA-Z0-9+/]+=* \(esc\) (re) | ||
\\tauid: [0-9]{20} \(esc\) (re) | ||
|
||
# synonym | ||
$ cauthtool kring -l | ||
client.admin | ||
\\t key: [a-zA-Z0-9+/]+=* \(esc\) (re) | ||
\\tauid: [0-9]{20} \(esc\) (re) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# TODO synchronize with man page | ||
$ cauthtool --help | ||
no command specified | ||
usage: [--create-keyring] [--gen-key] [--name=<name>] [--set-uid=uid] [--caps=<filename>] [--list] [--print-key] <filename> | ||
[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$ touch empty | ||
|
||
$ cauthtool --list empty | ||
error reading file empty | ||
[1] | ||
|
||
$ cauthtool -l empty | ||
error reading file empty | ||
[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$ cauthtool --list nonexistent | ||
can't open nonexistent: No such file or directory | ||
[1] | ||
|
||
$ cauthtool -l nonexistent | ||
can't open nonexistent: No such file or directory | ||
[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# demonstrate that manpage examples fail without config | ||
# TODO fix the manpage | ||
$ cauthtool -c -n client.foo --gen-key keyring.bin | ||
error reading config file(s) /etc/ceph/ceph.conf, ~/.ceph/config, ceph.conf | ||
[1] | ||
|
||
# work around the above | ||
$ touch ceph.conf | ||
|
||
To create a new keyring containing a key for client.foo: | ||
|
||
#TODO apparently -c is not enough for --create-keyring; fix manpage | ||
$ cauthtool -c -n client.foo --gen-key keyring.bin | ||
can't open keyring.bin: No such file or directory | ||
[1] | ||
|
||
$ cauthtool --create-keyring -n client.foo --gen-key keyring.bin | ||
creating keyring.bin | ||
|
||
To associate some capabilities with the key (namely, the ability to mount a Ceph filesystem): | ||
|
||
$ cauthtool -n client.foo --cap mds 'allow' --cap osd 'allow rw pool=data' --cap mon 'allow r' keyring.bin | ||
|
||
To display the contents of the keyring: | ||
|
||
$ cauthtool -l keyring.bin | ||
client.foo | ||
\\t key: [a-zA-Z0-9+/]+=* \(esc\) (re) | ||
\\tauid: [0-9]{20} \(esc\) (re) | ||
\tcaps: [mds] allow (esc) | ||
\tcaps: [mon] allow r (esc) | ||
\tcaps: [osd] allow rw pool=data (esc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$ cauthtool | ||
cauthtool: must specify filename | ||
usage: [--create-keyring] [--gen-key] [--name=<name>] [--set-uid=uid] [--caps=<filename>] [--list] [--print-key] <filename> | ||
[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#TODO | ||
$ cconf --help | ||
Parse error at argument: --help | ||
Ceph configuration query tool | ||
|
||
USAGE | ||
cconf <flags> <action> | ||
|
||
ACTIONS | ||
-l|--list-sections <prefix> List sections in prefix | ||
|
||
--lookup <key> [defval] Print a configuration setting to stdout. | ||
\t\t\t\t If the setting is not defined, and the (esc) | ||
\t\t\t\t optional argument defval is provide, it will (esc) | ||
\t\t\t\t be printed instead. variables in defval are (esc) | ||
\t\t\t\t interpolated. (esc) | ||
|
||
FLAGS | ||
-i id Set id | ||
[-s <section>] Add to list of sections to search | ||
|
||
If there is no action given, the action will default to --lookup. | ||
|
||
EXAMPLES | ||
[$] cconf -i cconf -c /etc/ceph/ceph\.conf -t mon -i 0 'mon addr' (re) | ||
Find out if there is a 'mon addr' defined in /etc/ceph/ceph.conf | ||
|
||
[$] cconf -l mon (re) | ||
List sections beginning with 'mon'. | ||
|
||
RETURN CODE | ||
Return code will be 0 on success; error code otherwise. | ||
[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
$ cat >test.conf <<EOF | ||
> [bar] | ||
> bar = green | ||
> EOF | ||
|
||
# TODO output an error | ||
$ cconf -c test.conf broken | ||
[1] | ||
|
||
# TODO output an error (missing key) | ||
$ cconf -c test.conf -s bar | ||
*** Caught signal (Segmentation fault) *** | ||
in thread [0-9a-f]{12} (re) | ||
ceph version .* (re) | ||
1: .* (re) | ||
2: .* (re) | ||
3: .* (re) | ||
4: .* (re) | ||
5: .* (re) | ||
6: .* (re) | ||
Segmentation fault | ||
[139] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 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 | ||
> [osd3] | ||
> host = cosd3 | ||
> EOF | ||
|
||
To extract the value of the "osd data" option for the osd0 daemon, | ||
|
||
# TODO shouldn't this say /mnt/osd0? is this the fault of cram? | ||
|
||
$ cconf -c foo.conf "osd data" -i 0 -t osd | ||
/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 | ||
|
||
$ cconf -c foo.conf "osd data" -s osd0 -s osd.0 -s osd -s global | ||
/mnt/osdadmin | ||
|
||
To list all sections that begin with osd: | ||
|
||
$ cconf -c foo.conf -l osd | ||
osd | ||
osd3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
$ cat >test.conf <<EOF | ||
> [bar] | ||
> bar = green | ||
> [foo] | ||
> bar = blue | ||
> [baz] | ||
> bar = yellow | ||
> [thud] | ||
> bar = red | ||
> [nobar] | ||
> other = 42 | ||
> EOF | ||
|
||
$ cconf -c test.conf bar -s foo | ||
blue | ||
|
||
# TODO man page stops in the middle of a sentence | ||
|
||
$ cconf -c test.conf bar -s xyzzy | ||
[1] | ||
|
||
$ cconf -c test.conf bar notfound -s xyzzy | ||
notfound | ||
|
||
$ cconf -c test.conf bar notfound -s xyzzy -s thud | ||
red | ||
|
||
$ cconf -c test.conf bar notfound -s nobar -s thud | ||
red | ||
|
||
$ cconf -c test.conf bar notfound -s thud -s baz | ||
red | ||
|
||
$ cconf -c test.conf bar notfound -s baz -s thud | ||
yellow | ||
|
||
$ cconf -c test.conf bar notfound -s xyzzy -s nobar -s thud -s baz | ||
red |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$ cat >test.conf <<EOF | ||
> [bar] | ||
> bar = green | ||
> [foo] | ||
> bar = blue | ||
> [baz] | ||
> bar = yellow | ||
> [thud] | ||
> bar = yellow | ||
> EOF | ||
|
||
$ cconf -c test.conf -l bar | ||
bar | ||
|
||
$ cconf -c test.conf -l b | ||
bar | ||
baz | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#TODO | ||
$ cconf | ||
*** Caught signal (Segmentation fault) *** | ||
in thread [0-9a-f]{12} (re) | ||
ceph version .* (re) | ||
1: .* (re) | ||
2: .* (re) | ||
3: .* (re) | ||
4: .* (re) | ||
5: .* (re) | ||
6: .* (re) | ||
Segmentation fault | ||
[139] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
$ monmaptool --create mymonmap | ||
monmaptool: monmap file mymonmap | ||
failed to open log file '/var/log/ceph/': error 21: Is a directory | ||
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]{12} can't open mymonmap: error 2: No such file or directory (re) | ||
monmaptool: generated fsid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (re) | ||
monmaptool: writing epoch 1 to mymonmap (0 monitors) | ||
|
||
$ ORIG_FSID="$(monmaptool --print mymonmap|grep ^fsid)" | ||
|
||
$ monmaptool --add foo 2.3.4.5:6789 mymonmap | ||
monmaptool: monmap file mymonmap | ||
monmaptool: writing epoch 2 to mymonmap (1 monitors) | ||
$ monmaptool --add foo 3.4.5.6:7890 mymonmap | ||
monmaptool: monmap file mymonmap | ||
monmaptool: map already contains mon.foo | ||
usage: [--print] [--create [--clobber]] [--add name 1.2.3.4:567] [--rm name] <mapfilename> | ||
[1] | ||
|
||
$ monmaptool --print mymonmap | ||
monmaptool: monmap file mymonmap | ||
epoch 2 | ||
fsid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (re) | ||
last_changed \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re) | ||
created \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re) | ||
0: 2.3.4.5:6789/0 mon.foo | ||
|
||
$ NEW_FSID="$(monmaptool --print mymonmap|grep ^fsid)" | ||
$ [ "$ORIG_FSID" = "$NEW_FSID" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
$ monmaptool --create mymonmap | ||
monmaptool: monmap file mymonmap | ||
failed to open log file '/var/log/ceph/': error 21: Is a directory | ||
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]{12} can't open mymonmap: error 2: No such file or directory (re) | ||
monmaptool: generated fsid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (re) | ||
monmaptool: writing epoch 1 to mymonmap (0 monitors) | ||
|
||
$ ORIG_FSID="$(monmaptool --print mymonmap|grep ^fsid)" | ||
|
||
$ monmaptool --add foo 2.3.4.5:6789 mymonmap | ||
monmaptool: monmap file mymonmap | ||
monmaptool: writing epoch 2 to mymonmap (1 monitors) | ||
$ monmaptool --add bar 3.4.5.6:7890 mymonmap | ||
monmaptool: monmap file mymonmap | ||
monmaptool: writing epoch 3 to mymonmap (2 monitors) | ||
$ monmaptool --add baz 4.5.6.7:8901 mymonmap | ||
monmaptool: monmap file mymonmap | ||
monmaptool: writing epoch 4 to mymonmap (3 monitors) | ||
|
||
$ monmaptool --print mymonmap | ||
monmaptool: monmap file mymonmap | ||
epoch 4 | ||
fsid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (re) | ||
last_changed \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re) | ||
created \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re) | ||
0: 3.4.5.6:7890/0 mon.bar | ||
1: 4.5.6.7:8901/0 mon.baz | ||
2: 2.3.4.5:6789/0 mon.foo | ||
|
||
$ NEW_FSID="$(monmaptool --print mymonmap|grep ^fsid)" | ||
$ [ "$ORIG_FSID" = "$NEW_FSID" ] |
Oops, something went wrong.