2013-12-20 19:39:21 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2014-02-02 09:40:37 +00:00
|
|
|
# Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
|
2013-12-20 19:39:21 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2014-02-13 09:23:28 +00:00
|
|
|
source test/mon/mon-test-helpers.sh
|
|
|
|
|
|
|
|
function run() {
|
|
|
|
local dir=$1
|
2013-12-20 19:39:21 +00:00
|
|
|
|
2014-02-13 09:23:28 +00:00
|
|
|
export CEPH_ARGS
|
|
|
|
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
|
|
|
|
CEPH_ARGS+="--mon-host=127.0.0.1 "
|
|
|
|
|
2014-03-16 16:00:25 +00:00
|
|
|
FUNCTIONS=${FUNCTIONS:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
|
|
|
|
for TEST_function in $FUNCTIONS ; do
|
2014-02-13 09:23:28 +00:00
|
|
|
setup $dir || return 1
|
|
|
|
$TEST_function $dir || return 1
|
|
|
|
teardown $dir || return 1
|
2013-12-25 20:36:13 +00:00
|
|
|
done
|
2014-02-13 09:23:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function TEST_default_deprectated_0() {
|
|
|
|
local dir=$1
|
|
|
|
# explicitly set the default crush rule
|
|
|
|
expected=66
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1 \
|
|
|
|
--osd_pool_default_crush_replicated_ruleset $expected
|
|
|
|
./ceph --format json osd dump | grep '"crush_ruleset":'$expected
|
|
|
|
! grep "osd_pool_default_crush_rule is deprecated " $dir/a/log || return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function TEST_default_deprectated_1() {
|
|
|
|
local dir=$1
|
|
|
|
# explicitly set the default crush rule using deprecated option
|
|
|
|
expected=55
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1 \
|
|
|
|
--osd_pool_default_crush_rule $expected
|
|
|
|
./ceph --format json osd dump | grep '"crush_ruleset":'$expected
|
|
|
|
grep "osd_pool_default_crush_rule is deprecated " $dir/a/log || return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function TEST_default_deprectated_2() {
|
|
|
|
local dir=$1
|
|
|
|
expected=77
|
|
|
|
unexpected=33
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1 \
|
|
|
|
--osd_pool_default_crush_rule $expected \
|
|
|
|
--osd_pool_default_crush_replicated_ruleset $unexpected
|
|
|
|
./ceph --format json osd dump | grep '"crush_ruleset":'$expected
|
|
|
|
! ./ceph --format json osd dump | grep '"crush_ruleset":'$unexpected || return 1
|
|
|
|
grep "osd_pool_default_crush_rule is deprecated " $dir/a/log || return 1
|
|
|
|
}
|
|
|
|
|
2014-06-11 20:44:57 +00:00
|
|
|
# Before http://tracker.ceph.com/issues/8307 the invalid profile was created
|
|
|
|
function TEST_erasure_invalid_profile() {
|
|
|
|
local dir=$1
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1
|
|
|
|
local poolname=pool_erasure
|
|
|
|
local notaprofile=not-a-valid-erasure-code-profile
|
|
|
|
! ./ceph osd pool create $poolname 12 12 erasure $notaprofile || return 1
|
|
|
|
! ./ceph osd erasure-code-profile ls | grep $notaprofile || return 1
|
|
|
|
}
|
|
|
|
|
2014-02-13 09:23:28 +00:00
|
|
|
function TEST_erasure_crush_rule() {
|
|
|
|
local dir=$1
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1
|
2014-03-16 16:00:25 +00:00
|
|
|
#
|
|
|
|
# choose the crush ruleset used with an erasure coded pool
|
|
|
|
#
|
|
|
|
local crush_ruleset=myruleset
|
|
|
|
! ./ceph osd crush rule ls | grep $crush_ruleset || return 1
|
2014-02-13 09:23:28 +00:00
|
|
|
./ceph osd crush rule create-erasure $crush_ruleset
|
|
|
|
./ceph osd crush rule ls | grep $crush_ruleset
|
2014-03-03 14:40:13 +00:00
|
|
|
local poolname
|
|
|
|
poolname=pool_erasure1
|
2014-03-26 00:35:01 +00:00
|
|
|
! ./ceph --format json osd dump | grep '"crush_ruleset":1' || return 1
|
2014-03-16 16:00:25 +00:00
|
|
|
./ceph osd pool create $poolname 12 12 erasure default $crush_ruleset
|
2014-03-26 00:35:01 +00:00
|
|
|
./ceph --format json osd dump | grep '"crush_ruleset":1' || return 1
|
2014-03-16 16:00:25 +00:00
|
|
|
#
|
|
|
|
# a crush ruleset by the name of the pool is implicitly created
|
|
|
|
#
|
2014-03-03 14:40:13 +00:00
|
|
|
poolname=pool_erasure2
|
2014-03-16 16:00:25 +00:00
|
|
|
./ceph osd erasure-code-profile set myprofile
|
|
|
|
./ceph osd pool create $poolname 12 12 erasure myprofile
|
|
|
|
./ceph osd crush rule ls | grep $poolname || return 1
|
2014-02-13 09:23:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function TEST_erasure_crush_rule_pending() {
|
|
|
|
local dir=$1
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1
|
2014-08-28 17:59:18 +00:00
|
|
|
./ceph osd erasure-code-profile ls
|
2014-02-13 09:23:28 +00:00
|
|
|
# try again if the ruleset creation is pending
|
|
|
|
crush_ruleset=erasure_ruleset
|
|
|
|
# add to the pending OSD map without triggering a paxos proposal
|
|
|
|
result=$(echo '{"prefix":"osdmonitor_prepare_command","prepare":"osd crush rule create-erasure","name":"'$crush_ruleset'"}' | nc -U $dir/a/ceph-mon.a.asok | cut --bytes=5-)
|
|
|
|
test $result = true || return 1
|
2014-03-16 16:00:25 +00:00
|
|
|
./ceph osd pool create pool_erasure 12 12 erasure default $crush_ruleset || return 1
|
2014-02-13 09:23:28 +00:00
|
|
|
grep "$crush_ruleset try again" $dir/a/log || return 1
|
|
|
|
}
|
|
|
|
|
2014-08-05 08:12:22 +00:00
|
|
|
function TEST_simple_crush_rule_pending() {
|
|
|
|
local dir=$1
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1
|
2014-08-28 17:59:18 +00:00
|
|
|
./ceph osd erasure-code-profile ls
|
2014-08-05 08:12:22 +00:00
|
|
|
# try again if the ruleset creation is pending
|
|
|
|
crush_ruleset=simple_ruleset
|
|
|
|
./ceph osd crush add-bucket host1 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":"'$crush_ruleset'","root":"host1","type":"host"}' | nc -U $dir/a/ceph-mon.a.asok | cut --bytes=5-)
|
|
|
|
test $result = true || return 1
|
|
|
|
./ceph osd pool create pool_simple 12 12 replicated $crush_ruleset || return 1
|
|
|
|
CEPH_ARGS='' ./ceph --admin-daemon $dir/a/ceph-mon.a.asok log flush || return 1
|
|
|
|
grep "$crush_ruleset is pending, try again" $dir/a/log || return 1
|
|
|
|
}
|
|
|
|
|
2014-06-18 22:49:13 +00:00
|
|
|
function TEST_erasure_code_profile_default() {
|
|
|
|
local dir=$1
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1
|
|
|
|
./ceph osd erasure-code-profile rm default || return 1
|
|
|
|
! ./ceph osd erasure-code-profile ls | grep default || return 1
|
|
|
|
./ceph osd pool create $poolname 12 12 erasure default
|
|
|
|
./ceph osd erasure-code-profile ls | grep default || return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function TEST_erasure_code_profile_default_pending() {
|
|
|
|
local dir=$1
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1
|
2014-08-28 17:59:18 +00:00
|
|
|
./ceph osd erasure-code-profile ls
|
2014-06-18 22:49:13 +00:00
|
|
|
./ceph osd erasure-code-profile rm default || return 1
|
|
|
|
! ./ceph osd erasure-code-profile ls | grep default || return 1
|
|
|
|
# add to the pending OSD map without triggering a paxos proposal
|
|
|
|
result=$(echo '{"prefix":"osdmonitor_prepare_command","prepare":"osd erasure-code-profile set","name":"default"}' | nc -U $dir/a/ceph-mon.a.asok | cut --bytes=5-)
|
|
|
|
test $result = true || return 1
|
|
|
|
./ceph osd pool create pool_erasure 12 12 erasure default || return 1
|
|
|
|
CEPH_ARGS='' ./ceph --admin-daemon $dir/a/ceph-mon.a.asok log flush || return 1
|
|
|
|
grep 'profile default already pending' $dir/a/log || return 1
|
|
|
|
}
|
|
|
|
|
2014-02-13 09:23:28 +00:00
|
|
|
function TEST_erasure_crush_stripe_width() {
|
|
|
|
local dir=$1
|
|
|
|
# the default stripe width is used to initialize the pool
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1
|
|
|
|
stripe_width=$(./ceph-conf --show-config-value osd_pool_erasure_code_stripe_width)
|
2014-03-16 16:00:25 +00:00
|
|
|
./ceph osd pool create pool_erasure 12 12 erasure
|
2014-02-13 09:23:28 +00:00
|
|
|
./ceph --format json osd dump | tee $dir/osd.json
|
|
|
|
grep '"stripe_width":'$stripe_width $dir/osd.json > /dev/null || return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function TEST_erasure_crush_stripe_width_padded() {
|
|
|
|
local dir=$1
|
|
|
|
# setting osd_pool_erasure_code_stripe_width modifies the stripe_width
|
|
|
|
# and it is padded as required by the default plugin
|
2014-03-16 11:09:51 +00:00
|
|
|
profile+=" plugin=jerasure"
|
|
|
|
profile+=" technique=reed_sol_van"
|
2014-02-13 09:23:28 +00:00
|
|
|
k=4
|
2014-03-16 11:09:51 +00:00
|
|
|
profile+=" k=$k"
|
|
|
|
profile+=" m=2"
|
2014-02-13 09:23:28 +00:00
|
|
|
expected_chunk_size=2048
|
|
|
|
actual_stripe_width=$(($expected_chunk_size * $k))
|
|
|
|
desired_stripe_width=$(($actual_stripe_width - 1))
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1 \
|
|
|
|
--osd_pool_erasure_code_stripe_width $desired_stripe_width \
|
2014-03-16 16:00:25 +00:00
|
|
|
--osd_pool_default_erasure_code_profile "$profile"
|
|
|
|
./ceph osd pool create pool_erasure 12 12 erasure
|
2014-02-13 09:23:28 +00:00
|
|
|
./ceph osd dump | tee $dir/osd.json
|
|
|
|
grep "stripe_width $actual_stripe_width" $dir/osd.json > /dev/null || return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function TEST_erasure_code_pool() {
|
|
|
|
local dir=$1
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1
|
|
|
|
./ceph --format json osd dump > $dir/osd.json
|
2014-03-16 16:00:25 +00:00
|
|
|
local expected='"erasure_code_profile":"default"'
|
|
|
|
! grep "$expected" $dir/osd.json || return 1
|
|
|
|
./ceph osd pool create erasurecodes 12 12 erasure
|
2014-02-13 09:23:28 +00:00
|
|
|
./ceph --format json osd dump | tee $dir/osd.json
|
2014-03-16 16:00:25 +00:00
|
|
|
grep "$expected" $dir/osd.json > /dev/null || return 1
|
2014-02-13 09:23:28 +00:00
|
|
|
|
|
|
|
./ceph osd pool create erasurecodes 12 12 erasure 2>&1 | \
|
|
|
|
grep 'already exists' || return 1
|
|
|
|
./ceph osd pool create erasurecodes 12 12 2>&1 | \
|
|
|
|
grep 'cannot change to type replicated' || return 1
|
|
|
|
}
|
2013-12-25 20:36:13 +00:00
|
|
|
|
2014-08-05 08:12:22 +00:00
|
|
|
function TEST_replicated_pool_with_ruleset() {
|
|
|
|
local dir=$1
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1
|
|
|
|
local ruleset=ruleset0
|
|
|
|
local root=host1
|
|
|
|
./ceph osd crush add-bucket $root host
|
|
|
|
local failure_domain=osd
|
|
|
|
local poolname=mypool
|
|
|
|
./ceph osd crush rule create-simple $ruleset $root $failure_domain || return 1
|
|
|
|
./ceph osd crush rule ls | grep $ruleset
|
|
|
|
./ceph osd pool create $poolname 12 12 replicated $ruleset 2>&1 | \
|
|
|
|
grep "pool 'mypool' created" || return 1
|
|
|
|
rule_id=`./ceph osd crush rule dump $ruleset | grep "rule_id" | awk -F[' ':,] '{print $4}'`
|
|
|
|
./ceph osd pool get $poolname crush_ruleset 2>&1 | \
|
|
|
|
grep "crush_ruleset: $rule_id" || return 1
|
|
|
|
#non-existent crush ruleset
|
|
|
|
./ceph osd pool create newpool 12 12 replicated non-existent 2>&1 | \
|
|
|
|
grep "doesn't exist" || return 1
|
|
|
|
}
|
|
|
|
|
2014-06-08 15:25:41 +00:00
|
|
|
function TEST_erasure_code_pool_LRC() {
|
|
|
|
local dir=$1
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1
|
|
|
|
|
|
|
|
./ceph osd erasure-code-profile set LRCprofile \
|
|
|
|
plugin=LRC \
|
|
|
|
mapping=DD_ \
|
|
|
|
layers='[ [ "DDc", "" ] ]' || return 1
|
|
|
|
|
|
|
|
./ceph --format json osd dump > $dir/osd.json
|
|
|
|
local expected='"erasure_code_profile":"LRCprofile"'
|
|
|
|
local poolname=erasurecodes
|
|
|
|
! grep "$expected" $dir/osd.json || return 1
|
|
|
|
./ceph osd pool create $poolname 12 12 erasure LRCprofile
|
|
|
|
./ceph --format json osd dump | tee $dir/osd.json
|
|
|
|
grep "$expected" $dir/osd.json > /dev/null || return 1
|
|
|
|
./ceph osd crush rule ls | grep $poolname || return 1
|
|
|
|
}
|
|
|
|
|
2014-02-13 09:23:28 +00:00
|
|
|
function TEST_replicated_pool() {
|
|
|
|
local dir=$1
|
|
|
|
run_mon $dir a --public-addr 127.0.0.1
|
2014-08-05 08:12:22 +00:00
|
|
|
./ceph osd pool create replicated 12 12 replicated 2>&1 | \
|
|
|
|
grep "pool 'replicated' created" || return 1
|
2014-02-13 09:23:28 +00:00
|
|
|
./ceph osd pool create replicated 12 12 replicated 2>&1 | \
|
|
|
|
grep 'already exists' || return 1
|
2014-08-05 08:12:22 +00:00
|
|
|
# default is replicated
|
|
|
|
./ceph osd pool create replicated1 12 12 2>&1 | \
|
|
|
|
grep "pool 'replicated1' created" || return 1
|
|
|
|
# default is replicated, pgp_num = pg_num
|
|
|
|
./ceph osd pool create replicated2 12 2>&1 | \
|
|
|
|
grep "pool 'replicated2' created" || return 1
|
2014-02-13 09:23:28 +00:00
|
|
|
./ceph osd pool create replicated 12 12 erasure 2>&1 | \
|
|
|
|
grep 'cannot change to type erasure' || return 1
|
2013-12-20 19:39:21 +00:00
|
|
|
}
|
|
|
|
|
2014-08-05 08:12:22 +00:00
|
|
|
|
2014-02-13 09:23:28 +00:00
|
|
|
main osd-pool-create
|
2013-12-20 19:39:21 +00:00
|
|
|
|
|
|
|
# Local Variables:
|
2014-02-12 15:58:23 +00:00
|
|
|
# compile-command: "cd ../.. ; make -j4 && test/mon/osd-pool-create.sh"
|
2013-12-20 19:39:21 +00:00
|
|
|
# End:
|