2017-07-20 22:26:42 +00:00
|
|
|
#!/usr/bin/env bash
|
2014-03-16 12:00:50 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
|
2015-02-12 14:50:21 +00:00
|
|
|
# Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
|
2014-03-16 12:00:50 +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
|
2014-03-16 12:00:50 +00:00
|
|
|
|
|
|
|
function run() {
|
|
|
|
local dir=$1
|
2015-05-16 09:19:09 +00:00
|
|
|
shift
|
2014-03-16 12:00:50 +00:00
|
|
|
|
2016-01-08 18:04:57 +00:00
|
|
|
export CEPH_MON="127.0.0.1:7220" # git grep '\<7220\>' : there must be only one
|
2014-03-16 12:00:50 +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-03-16 12:00:50 +00:00
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
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
|
2014-03-16 12:00:50 +00:00
|
|
|
}
|
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
function TEST_set() {
|
2014-03-16 12:00:50 +00:00
|
|
|
local dir=$1
|
|
|
|
local id=$2
|
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
run_mon $dir a || return 1
|
|
|
|
|
2014-03-16 12:00:50 +00:00
|
|
|
local profile=myprofile
|
|
|
|
#
|
|
|
|
# no key=value pairs : use the default configuration
|
|
|
|
#
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile set $profile 2>&1 || return 1
|
|
|
|
ceph osd erasure-code-profile get $profile | \
|
2014-03-16 12:00:50 +00:00
|
|
|
grep plugin=jerasure || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile rm $profile
|
2014-03-16 12:00:50 +00:00
|
|
|
#
|
|
|
|
# key=value pairs override the default
|
|
|
|
#
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile set $profile \
|
2017-07-21 02:54:48 +00:00
|
|
|
key=value plugin=isa || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile get $profile | \
|
2017-07-21 02:54:48 +00:00
|
|
|
grep -e key=value -e plugin=isa || return 1
|
2014-03-16 12:00:50 +00:00
|
|
|
#
|
|
|
|
# --force is required to override an existing profile
|
|
|
|
#
|
2016-01-12 23:22:46 +00:00
|
|
|
! ceph osd erasure-code-profile set $profile > $dir/out 2>&1 || return 1
|
2014-03-16 12:00:50 +00:00
|
|
|
grep 'will not override' $dir/out || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile set $profile key=other --force || return 1
|
|
|
|
ceph osd erasure-code-profile get $profile | \
|
2014-03-16 12:00:50 +00:00
|
|
|
grep key=other || return 1
|
|
|
|
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile rm $profile # cleanup
|
2014-03-16 12:00:50 +00:00
|
|
|
}
|
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
function TEST_ls() {
|
2014-03-16 12:00:50 +00:00
|
|
|
local dir=$1
|
|
|
|
local id=$2
|
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
run_mon $dir a || return 1
|
|
|
|
|
2014-03-16 12:00:50 +00:00
|
|
|
local profile=myprofile
|
2016-01-12 23:22:46 +00:00
|
|
|
! ceph osd erasure-code-profile ls | grep $profile || return 1
|
|
|
|
ceph osd erasure-code-profile set $profile 2>&1 || return 1
|
|
|
|
ceph osd erasure-code-profile ls | grep $profile || return 1
|
|
|
|
ceph --format xml osd erasure-code-profile ls | \
|
2014-03-16 12:00:50 +00:00
|
|
|
grep "<profile>$profile</profile>" || return 1
|
|
|
|
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile rm $profile # cleanup
|
2014-03-16 12:00:50 +00:00
|
|
|
}
|
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
function TEST_rm() {
|
2014-03-16 12:00:50 +00:00
|
|
|
local dir=$1
|
|
|
|
local id=$2
|
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
run_mon $dir a || return 1
|
|
|
|
|
2014-03-16 12:00:50 +00:00
|
|
|
local profile=myprofile
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile set $profile 2>&1 || return 1
|
|
|
|
ceph osd erasure-code-profile ls | grep $profile || return 1
|
|
|
|
ceph osd erasure-code-profile rm $profile || return 1
|
|
|
|
! ceph osd erasure-code-profile ls | grep $profile || return 1
|
|
|
|
ceph osd erasure-code-profile rm WRONG 2>&1 | \
|
2014-03-16 12:00:50 +00:00
|
|
|
grep "WRONG does not exist" || return 1
|
|
|
|
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile set $profile || return 1
|
|
|
|
ceph osd pool create poolname 12 12 erasure $profile || return 1
|
|
|
|
! ceph osd erasure-code-profile rm $profile > $dir/out 2>&1 || return 1
|
2014-03-16 12:00:50 +00:00
|
|
|
grep "poolname.*using.*$profile" $dir/out || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd pool delete poolname poolname --yes-i-really-really-mean-it || return 1
|
|
|
|
ceph osd erasure-code-profile rm $profile || return 1
|
2014-03-16 12:00:50 +00:00
|
|
|
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile rm $profile # cleanup
|
2014-03-16 12:00:50 +00:00
|
|
|
}
|
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
function TEST_get() {
|
2014-03-16 12:00:50 +00:00
|
|
|
local dir=$1
|
|
|
|
local id=$2
|
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
run_mon $dir a || return 1
|
|
|
|
|
2014-03-16 12:00:50 +00:00
|
|
|
local default_profile=default
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile get $default_profile | \
|
2014-03-16 12:00:50 +00:00
|
|
|
grep plugin=jerasure || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph --format xml osd erasure-code-profile get $default_profile | \
|
2014-03-16 12:00:50 +00:00
|
|
|
grep '<plugin>jerasure</plugin>' || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
! ceph osd erasure-code-profile get WRONG > $dir/out 2>&1 || return 1
|
2014-03-16 12:00:50 +00:00
|
|
|
grep -q "unknown erasure code profile 'WRONG'" $dir/out || return 1
|
|
|
|
}
|
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
function TEST_set_idempotent() {
|
mon: informative message when erasure-code-profile set fails
When erasure-code-profile set refuses to override an existing profile,
it may be non trivial to figure out why. For instance:
ceph osd set default ruleset-failure-domain=host
fails with:
Error EPERM: will not override erasure code profile default
although ruleset-failure-domain=host is documented to be the
default. The error message now includes the two profiles that have been
compared to not be equal so that the user can verify the difference.
Error EPERM: will not override erasure code profile default
because the existing profile
{directory=.libs,k=2,m=1,plugin=jerasure,technique=reed_sol_van}
is different from the proposed profile
{directory=.libs,k=2,m=1,plugin=jerasure,ruleset-failure-domain=host,technique=reed_sol_van}
http://tracker.ceph.com/issues/10488 Fixes: #10488
Signed-off-by: Loic Dachary <ldachary@redhat.com>
2015-03-18 10:40:36 +00:00
|
|
|
local dir=$1
|
|
|
|
local id=$2
|
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
run_mon $dir a || return 1
|
mon: informative message when erasure-code-profile set fails
When erasure-code-profile set refuses to override an existing profile,
it may be non trivial to figure out why. For instance:
ceph osd set default ruleset-failure-domain=host
fails with:
Error EPERM: will not override erasure code profile default
although ruleset-failure-domain=host is documented to be the
default. The error message now includes the two profiles that have been
compared to not be equal so that the user can verify the difference.
Error EPERM: will not override erasure code profile default
because the existing profile
{directory=.libs,k=2,m=1,plugin=jerasure,technique=reed_sol_van}
is different from the proposed profile
{directory=.libs,k=2,m=1,plugin=jerasure,ruleset-failure-domain=host,technique=reed_sol_van}
http://tracker.ceph.com/issues/10488 Fixes: #10488
Signed-off-by: Loic Dachary <ldachary@redhat.com>
2015-03-18 10:40:36 +00:00
|
|
|
#
|
2017-07-21 02:54:48 +00:00
|
|
|
# The default profile is set using a code path different from
|
mon: informative message when erasure-code-profile set fails
When erasure-code-profile set refuses to override an existing profile,
it may be non trivial to figure out why. For instance:
ceph osd set default ruleset-failure-domain=host
fails with:
Error EPERM: will not override erasure code profile default
although ruleset-failure-domain=host is documented to be the
default. The error message now includes the two profiles that have been
compared to not be equal so that the user can verify the difference.
Error EPERM: will not override erasure code profile default
because the existing profile
{directory=.libs,k=2,m=1,plugin=jerasure,technique=reed_sol_van}
is different from the proposed profile
{directory=.libs,k=2,m=1,plugin=jerasure,ruleset-failure-domain=host,technique=reed_sol_van}
http://tracker.ceph.com/issues/10488 Fixes: #10488
Signed-off-by: Loic Dachary <ldachary@redhat.com>
2015-03-18 10:40:36 +00:00
|
|
|
# ceph osd erasure-code-profile set: verify that it is idempotent,
|
|
|
|
# as if it was using the same code path.
|
|
|
|
#
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile set default k=2 m=1 2>&1 || return 1
|
mon: informative message when erasure-code-profile set fails
When erasure-code-profile set refuses to override an existing profile,
it may be non trivial to figure out why. For instance:
ceph osd set default ruleset-failure-domain=host
fails with:
Error EPERM: will not override erasure code profile default
although ruleset-failure-domain=host is documented to be the
default. The error message now includes the two profiles that have been
compared to not be equal so that the user can verify the difference.
Error EPERM: will not override erasure code profile default
because the existing profile
{directory=.libs,k=2,m=1,plugin=jerasure,technique=reed_sol_van}
is different from the proposed profile
{directory=.libs,k=2,m=1,plugin=jerasure,ruleset-failure-domain=host,technique=reed_sol_van}
http://tracker.ceph.com/issues/10488 Fixes: #10488
Signed-off-by: Loic Dachary <ldachary@redhat.com>
2015-03-18 10:40:36 +00:00
|
|
|
local profile
|
|
|
|
#
|
|
|
|
# Because plugin=jerasure is the default, it uses a slightly
|
|
|
|
# different code path where defaults (m=1 for instance) are added
|
|
|
|
# implicitly.
|
|
|
|
#
|
|
|
|
profile=profileidempotent1
|
2016-01-12 23:22:46 +00:00
|
|
|
! ceph osd erasure-code-profile ls | grep $profile || return 1
|
2017-06-30 18:59:39 +00:00
|
|
|
ceph osd erasure-code-profile set $profile k=2 crush-failure-domain=osd 2>&1 || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile ls | grep $profile || return 1
|
2017-06-30 18:59:39 +00:00
|
|
|
ceph osd erasure-code-profile set $profile k=2 crush-failure-domain=osd 2>&1 || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile rm $profile # cleanup
|
mon: informative message when erasure-code-profile set fails
When erasure-code-profile set refuses to override an existing profile,
it may be non trivial to figure out why. For instance:
ceph osd set default ruleset-failure-domain=host
fails with:
Error EPERM: will not override erasure code profile default
although ruleset-failure-domain=host is documented to be the
default. The error message now includes the two profiles that have been
compared to not be equal so that the user can verify the difference.
Error EPERM: will not override erasure code profile default
because the existing profile
{directory=.libs,k=2,m=1,plugin=jerasure,technique=reed_sol_van}
is different from the proposed profile
{directory=.libs,k=2,m=1,plugin=jerasure,ruleset-failure-domain=host,technique=reed_sol_van}
http://tracker.ceph.com/issues/10488 Fixes: #10488
Signed-off-by: Loic Dachary <ldachary@redhat.com>
2015-03-18 10:40:36 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# In the general case the profile is exactly what is on
|
|
|
|
#
|
|
|
|
profile=profileidempotent2
|
2016-01-12 23:22:46 +00:00
|
|
|
! ceph osd erasure-code-profile ls | grep $profile || return 1
|
2017-06-30 18:59:39 +00:00
|
|
|
ceph osd erasure-code-profile set $profile plugin=lrc k=4 m=2 l=3 crush-failure-domain=osd 2>&1 || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile ls | grep $profile || return 1
|
2017-06-30 18:59:39 +00:00
|
|
|
ceph osd erasure-code-profile set $profile plugin=lrc k=4 m=2 l=3 crush-failure-domain=osd 2>&1 || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile rm $profile # cleanup
|
mon: informative message when erasure-code-profile set fails
When erasure-code-profile set refuses to override an existing profile,
it may be non trivial to figure out why. For instance:
ceph osd set default ruleset-failure-domain=host
fails with:
Error EPERM: will not override erasure code profile default
although ruleset-failure-domain=host is documented to be the
default. The error message now includes the two profiles that have been
compared to not be equal so that the user can verify the difference.
Error EPERM: will not override erasure code profile default
because the existing profile
{directory=.libs,k=2,m=1,plugin=jerasure,technique=reed_sol_van}
is different from the proposed profile
{directory=.libs,k=2,m=1,plugin=jerasure,ruleset-failure-domain=host,technique=reed_sol_van}
http://tracker.ceph.com/issues/10488 Fixes: #10488
Signed-off-by: Loic Dachary <ldachary@redhat.com>
2015-03-18 10:40:36 +00:00
|
|
|
}
|
|
|
|
|
2014-03-16 12:00:50 +00:00
|
|
|
function TEST_format_invalid() {
|
|
|
|
local dir=$1
|
|
|
|
|
|
|
|
local profile=profile
|
|
|
|
# osd_pool_default_erasure-code-profile is
|
|
|
|
# valid JSON but not of the expected type
|
2015-05-16 09:19:09 +00:00
|
|
|
run_mon $dir a \
|
|
|
|
--osd_pool_default_erasure-code-profile 1 || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
! ceph osd erasure-code-profile set $profile > $dir/out 2>&1 || return 1
|
2014-03-16 12:00:50 +00:00
|
|
|
cat $dir/out
|
|
|
|
grep 'must be a JSON object' $dir/out || return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function TEST_format_json() {
|
|
|
|
local dir=$1
|
|
|
|
|
|
|
|
# osd_pool_default_erasure-code-profile is JSON
|
2017-07-21 02:54:48 +00:00
|
|
|
expected='"plugin":"isa"'
|
2015-05-16 09:19:09 +00:00
|
|
|
run_mon $dir a \
|
|
|
|
--osd_pool_default_erasure-code-profile "{$expected}" || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph --format json osd erasure-code-profile get default | \
|
2014-03-16 12:00:50 +00:00
|
|
|
grep "$expected" || return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function TEST_format_plain() {
|
|
|
|
local dir=$1
|
|
|
|
|
|
|
|
# osd_pool_default_erasure-code-profile is plain text
|
2017-07-21 02:54:48 +00:00
|
|
|
expected='"plugin":"isa"'
|
2015-05-16 09:19:09 +00:00
|
|
|
run_mon $dir a \
|
2017-07-21 02:54:48 +00:00
|
|
|
--osd_pool_default_erasure-code-profile "plugin=isa" || return 1
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph --format json osd erasure-code-profile get default | \
|
2014-03-16 12:00:50 +00:00
|
|
|
grep "$expected" || return 1
|
|
|
|
}
|
|
|
|
|
2015-05-17 22:29:31 +00:00
|
|
|
function TEST_profile_k_sanity() {
|
|
|
|
local dir=$1
|
|
|
|
local profile=profile-sanity
|
|
|
|
|
|
|
|
run_mon $dir a || return 1
|
|
|
|
|
|
|
|
expect_failure $dir 'k must be a multiple of (k + m) / l' \
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile set $profile \
|
2015-05-17 22:29:31 +00:00
|
|
|
plugin=lrc \
|
|
|
|
l=1 \
|
|
|
|
k=1 \
|
|
|
|
m=1 || return 1
|
|
|
|
|
2015-06-07 08:53:49 +00:00
|
|
|
if erasure_code_plugin_exists isa ; then
|
|
|
|
expect_failure $dir 'k=1 must be >= 2' \
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile set $profile \
|
2015-06-07 08:53:49 +00:00
|
|
|
plugin=isa \
|
|
|
|
k=1 \
|
|
|
|
m=1 || return 1
|
|
|
|
else
|
|
|
|
echo "SKIP because plugin isa has not been built"
|
|
|
|
fi
|
2015-05-17 22:29:31 +00:00
|
|
|
|
|
|
|
expect_failure $dir 'k=1 must be >= 2' \
|
2016-01-12 23:22:46 +00:00
|
|
|
ceph osd erasure-code-profile set $profile \
|
2015-05-17 22:29:31 +00:00
|
|
|
plugin=jerasure \
|
|
|
|
k=1 \
|
|
|
|
m=1 || return 1
|
|
|
|
}
|
|
|
|
|
2015-05-16 09:19:09 +00:00
|
|
|
main osd-erasure-code-profile "$@"
|
2014-03-16 12:00:50 +00:00
|
|
|
|
|
|
|
# Local Variables:
|
|
|
|
# compile-command: "cd ../.. ; make -j4 && test/mon/osd-erasure-code-profile.sh"
|
|
|
|
# End:
|