From 0c9c1577f67ce5f7c387dbc92a2a0c5c6a76f7ec Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Thu, 13 Feb 2014 13:54:49 +0100 Subject: [PATCH] mon: osd crush rule create-simple functional tests Basic tests and a test that create the conditions where an OSDMap is pending with a ruleset that is not yet in the OSDMap. An attempt to create a rule by the same name will return success and not create it again. Signed-off-by: Loic Dachary --- src/test/mon/osd-crush.sh | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/test/mon/osd-crush.sh b/src/test/mon/osd-crush.sh index ec0ec0f33d9..e826f393fcc 100755 --- a/src/test/mon/osd-crush.sh +++ b/src/test/mon/osd-crush.sh @@ -33,11 +33,29 @@ function run() { fi done teardown $dir || return 1 +} +function TEST_crush_rule_create_simple() { + local dir=$1 + ./ceph osd crush rule dump replicated_ruleset xml | \ + grep 'takedefault' | \ + grep 'chooseleaf_firstn0host' || return 1 + local ruleset=ruleset0 + local root=host1 + ./ceph osd crush add-bucket $root host + local failure_domain=osd + ./ceph osd crush rule create-simple $ruleset $root $failure_domain || return 1 + ./ceph osd crush rule create-simple $ruleset $root $failure_domain 2>&1 | \ + grep "$ruleset already exists" || return 1 + ./ceph osd crush rule dump $ruleset xml | \ + grep 'take'$root'' | \ + grep 'choose_firstn0'$failure_domain'' || return 1 + ./ceph osd crush rule rm $ruleset || return 1 +} function TEST_crush_rule_dump() { local dir=$1 - local ruleset=ruleset + local ruleset=ruleset1 ./ceph osd crush rule create-erasure $ruleset || return 1 local expected expected="$ruleset" @@ -67,6 +85,19 @@ function TEST_crush_rule_all() { ! ./ceph osd crush rule ls | grep $crush_ruleset || return 1 } +function TEST_crush_rule_create_simple_exists() { + local dir=$1 + local ruleset=ruleset2 + local root=default + local failure_domain=host + # add to the pending OSD map without triggering a paxos proposal + result=$(echo '{"prefix":"osdmonitor_prepare_command","prepare":"osd crush rule create-simple","name":"'$ruleset'","root":"'$root'","type":"'$failure_domain'"}' | nc -U $dir/a/ceph-mon.a.asok | cut --bytes=5-) + test $result = true || return 1 + ./ceph osd crush rule create-simple $ruleset $root $failure_domain 2>&1 | \ + grep "$ruleset already exists" || return 1 + ./ceph osd crush rule rm $ruleset || return 1 +} + main osd-crush # Local Variables: -- 2.47.3