Skip to content

Commit

Permalink
qa/workunits/mon/crush_ops: use expect_false
Browse files Browse the repository at this point in the history
Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
Sage Weil committed Mar 5, 2014
1 parent 561869d commit ca12e0d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions qa/workunits/mon/crush_ops.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ca12e0d

Please sign in to comment.