]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: osd crush rule functional tests
authorLoic Dachary <loic@dachary.org>
Sun, 9 Feb 2014 21:44:25 +0000 (22:44 +0100)
committerLoic Dachary <loic@dachary.org>
Thu, 13 Feb 2014 13:54:52 +0000 (14:54 +0100)
* A set of test for the simplest operations
* A test covering all cases of osd crush rule

Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/Makefile.am
src/test/mon/osd-crush.sh [new file with mode: 0755]

index 771e605e3cd5681fd45c55fb3255a433a0cf5b97..d6d41a9a1338f652264c03214f8942a7d0f661ec 100644 (file)
@@ -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 (executable)
index 0000000..ec0ec0f
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/bash
+#
+# Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
+#
+# Author: Loic Dachary <loic@dachary.org>
+#
+# 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="<rule_name>$ruleset</rule_name>"
+    ./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: