From: Loic Dachary Date: Sun, 9 Feb 2014 21:44:25 +0000 (+0100) Subject: mon: osd crush rule functional tests X-Git-Tag: v0.78~184^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c248e7cf6c5f88d1010bf3bbb1a200ad6bbf31aa;p=ceph.git mon: osd crush rule functional tests * A set of test for the simplest operations * A test covering all cases of osd crush rule Signed-off-by: Loic Dachary --- diff --git a/src/test/Makefile.am b/src/test/Makefile.am index 771e605e3cd5..d6d41a9a1338 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -237,6 +237,7 @@ check_SCRIPTS += \ unittest_bufferlist.sh \ test/encoding/check-generated.sh \ test/mon/osd-pool-create.sh \ + test/mon/osd-crush.sh \ test/mon/mkfs.sh \ test/ceph-disk.sh \ test/mon/mon-handle-forward.sh \ diff --git a/src/test/mon/osd-crush.sh b/src/test/mon/osd-crush.sh new file mode 100755 index 000000000000..ec0ec0f33d9f --- /dev/null +++ b/src/test/mon/osd-crush.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# +# Copyright (C) 2014 Cloudwatt +# +# Author: Loic Dachary +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library Public License for more details. +# +source test/mon/mon-test-helpers.sh + +function run() { + local dir=$1 + + export CEPH_ARGS + CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none " + CEPH_ARGS+="--mon-host=127.0.0.1 " + + setup $dir || return 1 + run_mon $dir a --public-addr 127.0.0.1 + FUNCTIONS=${FUNCTIONS:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')} + for TEST_function in $FUNCTIONS ; do + if ! $TEST_function $dir ; then + cat $dir/a/log + return 1 + fi + done + teardown $dir || return 1 + + +function TEST_crush_rule_dump() { + local dir=$1 + local ruleset=ruleset + ./ceph osd crush rule create-erasure $ruleset || return 1 + local expected + expected="$ruleset" + ./ceph osd crush rule dump $ruleset xml | grep $expected || return 1 + ./ceph osd crush rule dump $ruleset xml-pretty | grep $expected || return 1 + expected='"rule_name":"'$ruleset'"' + ./ceph osd crush rule dump $ruleset json | grep "$expected" || return 1 + expected='"rule_name": "'$ruleset'"' + ./ceph osd crush rule dump $ruleset json-pretty | grep "$expected" || return 1 + ./ceph osd crush rule dump | grep "$expected" || return 1 + ! ./ceph osd crush rule dump non_existent_ruleset || return 1 + ./ceph osd crush rule rm $ruleset || return 1 +} + +function TEST_crush_rule_all() { + local dir=$1 + local crush_ruleset=erasure2 + ! ./ceph osd crush rule ls | grep $crush_ruleset || return 1 + ./ceph osd crush rule create-erasure $crush_ruleset || return 1 + ./ceph osd crush rule ls | grep $crush_ruleset || return 1 + + ./ceph osd crush rule create-erasure $crush_ruleset || return 1 + + ./ceph osd crush dump | grep $crush_ruleset || return 1 + + ./ceph osd crush rule rm $crush_ruleset || return 1 + ! ./ceph osd crush rule ls | grep $crush_ruleset || return 1 +} + +main osd-crush + +# Local Variables: +# compile-command: "cd ../.. ; make -j4 && test/mon/osd-crush.sh" +# End: