2013-12-20 19:39:21 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2015-05-16 13:43:33 +00:00
|
|
|
# Copyright (C) 2013, 2014 Cloudwatt <libre.licensing@cloudwatt.com>
|
|
|
|
# Copyright (C) 2014, 2015 Red Hat <contact@redhat.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.
|
|
|
|
#
|
2017-07-21 02:54:48 +00:00
|
|
|
source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
|
2015-01-16 15:54:22 +00:00
|
|
|
|
2014-02-13 09:23:28 +00:00
|
|
|
function run() {
|
|
|
|
local dir=$1
|
2015-05-16 13:43:33 +00:00
|
|
|
shift
|
2013-12-20 19:39:21 +00:00
|
|
|
|
2015-10-27 03:48:23 +00:00
|
|
|
export CEPH_MON="127.0.0.1:7105" # git grep '\<7105\>' : there must be only one
|
2014-02-13 09:23:28 +00:00
|
|
|
export CEPH_ARGS
|
|
|
|
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
|
2014-10-18 20:15:41 +00:00
|
|
|
CEPH_ARGS+="--mon-host=$CEPH_MON "
|
2014-02-13 09:23:28 +00:00
|
|
|
|
2015-05-16 13:43:33 +00:00
|
|
|
local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
|
|
|
|
for func in $funcs ; do
|
2014-02-13 09:23:28 +00:00
|
|
|
setup $dir || return 1
|
2015-05-16 13:43:33 +00:00
|
|
|
$func $dir || return 1
|
2014-02-13 09:23:28 +00:00
|
|
|
teardown $dir || return 1
|
2013-12-25 20:36:13 +00:00
|
|
|
done
|
2014-02-13 09:23:28 +00:00
|
|
|
}
|
|
|
|
|
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
|
2015-05-16 13:43:33 +00:00
|
|
|
run_mon $dir a || return 1
|
2014-06-11 20:44:57 +00:00
|
|
|
local poolname=pool_erasure
|
|
|
|
local notaprofile=not-a-valid-erasure-code-profile
|
2016-01-12 23:22:46 +00:00
|
|
|
! ceph osd pool create $poolname 12 12 erasure $notaprofile || return 1
|
|
|
|
! ceph osd erasure-code-profile ls | grep $notaprofile || return 1
|
2014-06-11 20:44:57 +00:00
|
|
|
}
|
|
|
|
|
2014-02-13 09:23:28 +00:00
|
|
|
function TEST_erasure_crush_rule() {
|
|
|
|
local dir=$1
|
2015-05-16 13:43:33 +00:00
|
|
|
run_mon $dir a || return 1
|
2017-07-21 02:54:48 +00:00
|
|
|
#
|
2014-03-16 16:00:25 +00:00
|
|
|
# choose the crush ruleset used with an erasure coded pool
|
|
|
|
#
|
|
|
|
local crush_ruleset=myruleset
|
2016-01-12 23:22:46 +00:00
|
|
|
! ceph osd crush rule ls | grep $crush_ruleset || return 1
|
|
|
|
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
|
2017-02-28 20:24:54 +00:00
|
|
|
! ceph --format json osd dump | grep '"crush_rule":1' || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create $poolname 12 12 erasure default $crush_ruleset
|
2017-02-28 20:24:54 +00:00
|
|
|
ceph --format json osd dump | grep '"crush_rule":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
|
2016-01-12 23:22:46 +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-09-16 09:32:26 +00:00
|
|
|
#
|
|
|
|
# a non existent crush ruleset given in argument is an error
|
|
|
|
# http://tracker.ceph.com/issues/9304
|
|
|
|
#
|
|
|
|
poolname=pool_erasure3
|
2016-01-12 23:22:46 +00:00
|
|
|
! ceph osd pool create $poolname 12 12 erasure myprofile INVALIDRULESET || return 1
|
2014-02-13 09:23:28 +00:00
|
|
|
}
|
|
|
|
|
2014-06-18 22:49:13 +00:00
|
|
|
function TEST_erasure_code_profile_default() {
|
|
|
|
local dir=$1
|
2015-05-16 13:43:33 +00:00
|
|
|
run_mon $dir a || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
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
|
2014-06-18 22:49:13 +00:00
|
|
|
}
|
|
|
|
|
2017-02-14 01:42:33 +00:00
|
|
|
function TEST_erasure_crush_stripe_unit() {
|
2014-02-13 09:23:28 +00:00
|
|
|
local dir=$1
|
2017-02-14 01:42:33 +00:00
|
|
|
# the default stripe unit is used to initialize the pool
|
2014-10-18 20:15:41 +00:00
|
|
|
run_mon $dir a --public-addr $CEPH_MON
|
2017-02-14 01:42:33 +00:00
|
|
|
stripe_unit=$(ceph-conf --show-config-value osd_pool_erasure_code_stripe_unit)
|
|
|
|
eval local $(ceph osd erasure-code-profile get myprofile | grep k=)
|
|
|
|
stripe_width = $((stripe_unit * k))
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create pool_erasure 12 12 erasure
|
|
|
|
ceph --format json osd dump | tee $dir/osd.json
|
2014-02-13 09:23:28 +00:00
|
|
|
grep '"stripe_width":'$stripe_width $dir/osd.json > /dev/null || return 1
|
|
|
|
}
|
|
|
|
|
2017-02-14 01:42:33 +00:00
|
|
|
function TEST_erasure_crush_stripe_unit_padded() {
|
2014-02-13 09:23:28 +00:00
|
|
|
local dir=$1
|
2017-02-14 01:42:33 +00:00
|
|
|
# setting osd_pool_erasure_code_stripe_unit modifies the stripe_width
|
2014-02-13 09:23:28 +00:00
|
|
|
# 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"
|
2017-02-14 01:42:33 +00:00
|
|
|
actual_stripe_unit=2048
|
|
|
|
desired_stripe_unit=$((actual_stripe_unit - 1))
|
|
|
|
actual_stripe_width=$((actual_stripe_unit * k))
|
2015-05-16 13:43:33 +00:00
|
|
|
run_mon $dir a \
|
2017-02-14 01:42:33 +00:00
|
|
|
--osd_pool_erasure_code_stripe_unit $desired_stripe_unit \
|
2015-05-16 13:43:33 +00:00
|
|
|
--osd_pool_default_erasure_code_profile "$profile" || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create pool_erasure 12 12 erasure
|
|
|
|
ceph osd dump | tee $dir/osd.json
|
2014-02-13 09:23:28 +00:00
|
|
|
grep "stripe_width $actual_stripe_width" $dir/osd.json > /dev/null || return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function TEST_erasure_code_pool() {
|
|
|
|
local dir=$1
|
2015-05-16 13:43:33 +00:00
|
|
|
run_mon $dir a || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
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
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create erasurecodes 12 12 erasure
|
|
|
|
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
|
|
|
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create erasurecodes 12 12 erasure 2>&1 | \
|
2014-02-13 09:23:28 +00:00
|
|
|
grep 'already exists' || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create erasurecodes 12 12 2>&1 | \
|
2014-02-13 09:23:28 +00:00
|
|
|
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
|
2015-05-16 13:43:33 +00:00
|
|
|
run_mon $dir a
|
2014-08-05 08:12:22 +00:00
|
|
|
local ruleset=ruleset0
|
|
|
|
local root=host1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd crush add-bucket $root host
|
2014-08-05 08:12:22 +00:00
|
|
|
local failure_domain=osd
|
|
|
|
local poolname=mypool
|
2016-01-12 23:22:46 +00:00
|
|
|
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 | \
|
2014-08-05 08:12:22 +00:00
|
|
|
grep "pool 'mypool' created" || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
rule_id=`ceph osd crush rule dump $ruleset | grep "rule_id" | awk -F[' ':,] '{print $4}'`
|
2017-02-28 20:24:54 +00:00
|
|
|
ceph osd pool get $poolname crush_rule 2>&1 | \
|
|
|
|
grep "crush_rule: $rule_id" || return 1
|
2014-08-05 08:12:22 +00:00
|
|
|
#non-existent crush ruleset
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create newpool 12 12 replicated non-existent 2>&1 | \
|
2014-08-05 08:12:22 +00:00
|
|
|
grep "doesn't exist" || return 1
|
|
|
|
}
|
|
|
|
|
2014-08-29 21:58:34 +00:00
|
|
|
function TEST_erasure_code_pool_lrc() {
|
2014-06-08 15:25:41 +00:00
|
|
|
local dir=$1
|
2015-05-16 13:43:33 +00:00
|
|
|
run_mon $dir a || return 1
|
2014-06-08 15:25:41 +00:00
|
|
|
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile set LRCprofile \
|
2014-08-29 21:58:34 +00:00
|
|
|
plugin=lrc \
|
2014-06-08 15:25:41 +00:00
|
|
|
mapping=DD_ \
|
|
|
|
layers='[ [ "DDc", "" ] ]' || return 1
|
|
|
|
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph --format json osd dump > $dir/osd.json
|
2014-06-08 15:25:41 +00:00
|
|
|
local expected='"erasure_code_profile":"LRCprofile"'
|
|
|
|
local poolname=erasurecodes
|
|
|
|
! grep "$expected" $dir/osd.json || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create $poolname 12 12 erasure LRCprofile
|
|
|
|
ceph --format json osd dump | tee $dir/osd.json
|
2014-06-08 15:25:41 +00:00
|
|
|
grep "$expected" $dir/osd.json > /dev/null || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd crush rule ls | grep $poolname || return 1
|
2014-06-08 15:25:41 +00:00
|
|
|
}
|
|
|
|
|
2014-02-13 09:23:28 +00:00
|
|
|
function TEST_replicated_pool() {
|
|
|
|
local dir=$1
|
2015-05-16 13:43:33 +00:00
|
|
|
run_mon $dir a || return 1
|
2017-06-20 21:45:59 +00:00
|
|
|
ceph osd pool create replicated 12 12 replicated replicated_rule 2>&1 | \
|
2014-08-05 08:12:22 +00:00
|
|
|
grep "pool 'replicated' created" || return 1
|
2017-06-20 21:45:59 +00:00
|
|
|
ceph osd pool create replicated 12 12 replicated replicated_rule 2>&1 | \
|
2014-02-13 09:23:28 +00:00
|
|
|
grep 'already exists' || return 1
|
2014-08-05 08:12:22 +00:00
|
|
|
# default is replicated
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create replicated1 12 12 2>&1 | \
|
2014-08-05 08:12:22 +00:00
|
|
|
grep "pool 'replicated1' created" || return 1
|
|
|
|
# default is replicated, pgp_num = pg_num
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create replicated2 12 2>&1 | \
|
2014-08-05 08:12:22 +00:00
|
|
|
grep "pool 'replicated2' created" || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create replicated 12 12 erasure 2>&1 | \
|
2014-02-13 09:23:28 +00:00
|
|
|
grep 'cannot change to type erasure' || return 1
|
2013-12-20 19:39:21 +00:00
|
|
|
}
|
|
|
|
|
2015-01-16 15:54:22 +00:00
|
|
|
function TEST_no_pool_delete() {
|
|
|
|
local dir=$1
|
2015-05-16 13:43:33 +00:00
|
|
|
run_mon $dir a || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create foo 1 || return 1
|
|
|
|
ceph tell mon.a injectargs -- --no-mon-allow-pool-delete || return 1
|
|
|
|
! ceph osd pool delete foo foo --yes-i-really-really-mean-it || return 1
|
|
|
|
ceph tell mon.a injectargs -- --mon-allow-pool-delete || return 1
|
|
|
|
ceph osd pool delete foo foo --yes-i-really-really-mean-it || return 1
|
2015-01-16 15:54:22 +00:00
|
|
|
}
|
|
|
|
|
json_spirit: use utf8 intenally when parsing \uHHHH
When the python CLI is given non-ASCII characters, it converts them to
\uHHHH escapes in JSON. json_spirit parses these internally into 16 bit
characters, which could only work if json_spirit were built to use
std::wstring, which it isn't; it's using std::string, so the high byte
ends up being zero'd, leaving the low byte which is effectively garbage.
This hack^H^H^H^H change makes json_spirit convert to utf8 internally
instead, which can be stored just fine inside a std::string.
Note that this implementation still assumes \uHHHH escapes are four hex
digits, so it'll only cope with characters in the Basic Multilingual
Plane. Still, that's rather a lot more characters than it could cope
with before ;)
(For characters outside the BMP, Python seems to generate escapes in the
form \uHHHHHHHH, i.e. 8 hex digits, which the current implementation
doesn't expect to see)
Fixes: #7387
Signed-off-by: Tim Serong <tserong@suse.com>
2015-05-01 15:59:53 +00:00
|
|
|
function TEST_utf8_cli() {
|
|
|
|
local dir=$1
|
2015-05-16 13:43:33 +00:00
|
|
|
run_mon $dir a || return 1
|
json_spirit: use utf8 intenally when parsing \uHHHH
When the python CLI is given non-ASCII characters, it converts them to
\uHHHH escapes in JSON. json_spirit parses these internally into 16 bit
characters, which could only work if json_spirit were built to use
std::wstring, which it isn't; it's using std::string, so the high byte
ends up being zero'd, leaving the low byte which is effectively garbage.
This hack^H^H^H^H change makes json_spirit convert to utf8 internally
instead, which can be stored just fine inside a std::string.
Note that this implementation still assumes \uHHHH escapes are four hex
digits, so it'll only cope with characters in the Basic Multilingual
Plane. Still, that's rather a lot more characters than it could cope
with before ;)
(For characters outside the BMP, Python seems to generate escapes in the
form \uHHHHHHHH, i.e. 8 hex digits, which the current implementation
doesn't expect to see)
Fixes: #7387
Signed-off-by: Tim Serong <tserong@suse.com>
2015-05-01 15:59:53 +00:00
|
|
|
# Hopefully it's safe to include literal UTF-8 characters to test
|
|
|
|
# the fix for http://tracker.ceph.com/issues/7387. If it turns out
|
|
|
|
# to not be OK (when is the default encoding *not* UTF-8?), maybe
|
|
|
|
# the character '黄' can be replaced with the escape $'\xe9\xbb\x84'
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool create 黄 1024 2>&1 | \
|
json_spirit: use utf8 intenally when parsing \uHHHH
When the python CLI is given non-ASCII characters, it converts them to
\uHHHH escapes in JSON. json_spirit parses these internally into 16 bit
characters, which could only work if json_spirit were built to use
std::wstring, which it isn't; it's using std::string, so the high byte
ends up being zero'd, leaving the low byte which is effectively garbage.
This hack^H^H^H^H change makes json_spirit convert to utf8 internally
instead, which can be stored just fine inside a std::string.
Note that this implementation still assumes \uHHHH escapes are four hex
digits, so it'll only cope with characters in the Basic Multilingual
Plane. Still, that's rather a lot more characters than it could cope
with before ;)
(For characters outside the BMP, Python seems to generate escapes in the
form \uHHHHHHHH, i.e. 8 hex digits, which the current implementation
doesn't expect to see)
Fixes: #7387
Signed-off-by: Tim Serong <tserong@suse.com>
2015-05-01 15:59:53 +00:00
|
|
|
grep "pool '黄' created" || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd lspools 2>&1 | \
|
json_spirit: use utf8 intenally when parsing \uHHHH
When the python CLI is given non-ASCII characters, it converts them to
\uHHHH escapes in JSON. json_spirit parses these internally into 16 bit
characters, which could only work if json_spirit were built to use
std::wstring, which it isn't; it's using std::string, so the high byte
ends up being zero'd, leaving the low byte which is effectively garbage.
This hack^H^H^H^H change makes json_spirit convert to utf8 internally
instead, which can be stored just fine inside a std::string.
Note that this implementation still assumes \uHHHH escapes are four hex
digits, so it'll only cope with characters in the Basic Multilingual
Plane. Still, that's rather a lot more characters than it could cope
with before ;)
(For characters outside the BMP, Python seems to generate escapes in the
form \uHHHHHHHH, i.e. 8 hex digits, which the current implementation
doesn't expect to see)
Fixes: #7387
Signed-off-by: Tim Serong <tserong@suse.com>
2015-05-01 15:59:53 +00:00
|
|
|
grep "黄" || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph -f json-pretty osd dump | \
|
json_spirit: use utf8 intenally when parsing \uHHHH
When the python CLI is given non-ASCII characters, it converts them to
\uHHHH escapes in JSON. json_spirit parses these internally into 16 bit
characters, which could only work if json_spirit were built to use
std::wstring, which it isn't; it's using std::string, so the high byte
ends up being zero'd, leaving the low byte which is effectively garbage.
This hack^H^H^H^H change makes json_spirit convert to utf8 internally
instead, which can be stored just fine inside a std::string.
Note that this implementation still assumes \uHHHH escapes are four hex
digits, so it'll only cope with characters in the Basic Multilingual
Plane. Still, that's rather a lot more characters than it could cope
with before ;)
(For characters outside the BMP, Python seems to generate escapes in the
form \uHHHHHHHH, i.e. 8 hex digits, which the current implementation
doesn't expect to see)
Fixes: #7387
Signed-off-by: Tim Serong <tserong@suse.com>
2015-05-01 15:59:53 +00:00
|
|
|
python -c "import json; import sys; json.load(sys.stdin)" || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool delete 黄 黄 --yes-i-really-really-mean-it
|
json_spirit: use utf8 intenally when parsing \uHHHH
When the python CLI is given non-ASCII characters, it converts them to
\uHHHH escapes in JSON. json_spirit parses these internally into 16 bit
characters, which could only work if json_spirit were built to use
std::wstring, which it isn't; it's using std::string, so the high byte
ends up being zero'd, leaving the low byte which is effectively garbage.
This hack^H^H^H^H change makes json_spirit convert to utf8 internally
instead, which can be stored just fine inside a std::string.
Note that this implementation still assumes \uHHHH escapes are four hex
digits, so it'll only cope with characters in the Basic Multilingual
Plane. Still, that's rather a lot more characters than it could cope
with before ;)
(For characters outside the BMP, Python seems to generate escapes in the
form \uHHHHHHHH, i.e. 8 hex digits, which the current implementation
doesn't expect to see)
Fixes: #7387
Signed-off-by: Tim Serong <tserong@suse.com>
2015-05-01 15:59:53 +00:00
|
|
|
}
|
2014-08-05 08:12:22 +00:00
|
|
|
|
2015-05-16 13:43:33 +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:
|