#!/bin/bash
#
# Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
-# Copyright (C) 2014 Red Hat <contact@redhat.com>
+# Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
#
# Author: Loic Dachary <loic@dachary.org>
#
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library Public License for more details.
#
-source test/mon/mon-test-helpers.sh
+source test/ceph-helpers.sh
function run() {
local dir=$1
+ shift
export CEPH_MON="127.0.0.1:7104"
export CEPH_ARGS
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
CEPH_ARGS+="--mon-host=$CEPH_MON "
- FUNCTIONS=${FUNCTIONS:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
- for TEST_function in $FUNCTIONS ; do
- setup $dir || return 1
- run_mon $dir a --public-addr $CEPH_MON
- if ! $TEST_function $dir ; then
- cat $dir/a/log
- return 1
- fi
- teardown $dir || return 1
+ local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
+ for func in $funcs ; do
+ setup $dir || return 1
+ $func $dir || return 1
+ teardown $dir || return 1
done
}
function TEST_crush_rule_create_simple() {
local dir=$1
+
+ run_mon $dir a || return 1
+
./ceph --format xml osd crush rule dump replicated_ruleset | \
egrep '<op>take</op><item>[^<]+</item><item_name>default</item_name>' | \
grep '<op>choose_firstn</op><num>0</num><type>osd</type>' || return 1
function TEST_crush_rule_dump() {
local dir=$1
+
+ run_mon $dir a || return 1
+
local ruleset=ruleset1
./ceph osd crush rule create-erasure $ruleset || return 1
local expected
function TEST_crush_rule_rm() {
local ruleset=erasure2
+
+ run_mon $dir a || return 1
+
./ceph osd crush rule create-erasure $ruleset default || return 1
./ceph osd crush rule ls | grep $ruleset || return 1
./ceph osd crush rule rm $ruleset || return 1
function TEST_crush_rule_create_erasure() {
local dir=$1
+
+ run_mon $dir a || return 1
+
local ruleset=ruleset3
#
# create a new ruleset with the default profile, implicitly
./ceph osd erasure-code-profile rm default || return 1
! ./ceph osd erasure-code-profile ls | grep default || return 1
./ceph osd crush rule create-erasure $ruleset || return 1
- CEPH_ARGS='' ./ceph --admin-daemon $dir/a/ceph-mon.a.asok log flush || return 1
- grep 'profile default set' $dir/a/log || return 1
+ CEPH_ARGS='' ./ceph --admin-daemon $dir/ceph-mon.a.asok log flush || return 1
+ grep 'profile default set' $dir/mon.a.log || return 1
./ceph osd erasure-code-profile ls | grep default || return 1
./ceph osd crush rule rm $ruleset || return 1
! ./ceph osd crush rule ls | grep $ruleset || return 1
function TEST_crush_ruleset_match_rule_when_creating() {
local dir=$1
+
+ run_mon $dir a || return 1
+
local root=host1
generate_manipulated_rules $dir
function TEST_add_ruleset_failed() {
local dir=$1
+
+ run_mon $dir a || return 1
+
local root=host1
./ceph osd crush add-bucket $root host
function TEST_crush_rename_bucket() {
local dir=$1
+ run_mon $dir a || return 1
+
./ceph osd crush add-bucket host1 host
! ./ceph osd tree | grep host2 || return 1
./ceph osd crush rename-bucket host1 host2 || return 1
./ceph osd crush rename-bucket nonexistent something 2>&1 | grep "Error ENOENT" || return 1
}
-main osd-crush
+main osd-crush "$@"
# Local Variables:
# compile-command: "cd ../.. ; make -j4 && test/mon/osd-crush.sh"