qa/workunits/mon/crush_ops: use expect_false

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2014-03-05 12:52:08 -08:00
parent 561869d9c1
commit ca12e0d92e

View File

@ -1,7 +1,13 @@
#!/bin/sh -x
#!/bin/bash -x
set -e
function expect_false()
{
set -x
if "$@"; then return 1; else return 0; fi
}
ceph osd crush dump
# rules
@ -20,7 +26,7 @@ ceph osd crush rule rm foo # idempotent
ceph osd crush rule rm bar
# can't delete in-use rules, tho:
ceph osd crush rule rm replicated_ruleset && exit 1 || true
expect_false ceph osd crush rule rm replicated_ruleset
# build a simple map
ceph osd crush add-bucket foo root
@ -41,20 +47,20 @@ ceph osd tree | grep -c osd.$o1 | grep -q 2
ceph osd tree | grep -c host1 | grep -q 2
ceph osd tree | grep -c osd.$o2 | grep -q 2
ceph osd tree | grep -c host2 | grep -q 2
ceph osd crush rm host1 foo && exit 1 || true # not empty
expect_false ceph osd crush rm host1 foo # not empty
ceph osd crush unlink host1 foo
ceph osd crush unlink host1 foo
ceph osd tree | grep -c host1 | grep -q 1
ceph osd crush rm foo && exit 1 || true # not empty
ceph osd crush rm bar && exit 1 || true # not empty
expect_false ceph osd crush rm foo # not empty
expect_false ceph osd crush rm bar # not empty
ceph osd crush unlink host1 bar
ceph osd tree | grep -c host1 | grep -q 1 # now an orphan
ceph osd crush rm osd.$o1 host1
ceph osd crush rm host1
ceph osd tree | grep -c host1 | grep -q 0
ceph osd crush rm bar && exit 1 || true # not empty
expect_false ceph osd crush rm bar # not empty
ceph osd crush unlink host2
ceph osd crush rm bar
ceph osd crush rm foo