]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: s/ENOSYS/ENOTSUP/ 1181/head
authorLoic Dachary <loic@dachary.org>
Tue, 4 Feb 2014 11:55:19 +0000 (12:55 +0100)
committerLoic Dachary <loic@dachary.org>
Fri, 7 Feb 2014 11:41:42 +0000 (12:41 +0100)
On Linux ENOTSUP is remapped
/usr/include/x86_64-linux-gnu/bits/errno.h

    /* Linux has no ENOTSUP error code.  */
    # define ENOTSUP EOPNOTSUPP

and should have different values on other operating systems. On Ubuntu
precise the string returned when translating the error value of ENOTSUP
or EOPNOTSUPP is always EOPNOTSUPP but on Ubuntu saucy it is always
ENOTSUP.

Replace ENOSYS with ENOTSUP because the expected semantic is very
similar and modify the test to not check on the string translation of
the error.

Rework the check_response shell function to optionaly check the return
code. The erasure coded pool size change test verifies the error message
only but not the error code.

Signed-off-by: Loic Dachary <loic@dachary.org>
qa/workunits/cephtool/test.sh
src/mon/OSDMonitor.cc

index 58d0e94a5214ab42e201c20fd912bff75f45c0cc..0e87c811bc20ae08a202cf56afeb6e2741194040 100755 (executable)
@@ -4,7 +4,7 @@ set -e
 set -o functrace
 PS4=' ${FUNCNAME[0]}: $LINENO: '
 
-get_pg()
+function get_pg()
 {
        local pool obj map_output pg
        pool=$1
@@ -21,7 +21,7 @@ get_pg()
        echo $pg
 }
 
-expect_false()
+function expect_false()
 {
        set -x
        if "$@"; then return 1; else return 0; fi
@@ -35,16 +35,16 @@ TMPFILE=$TMPDIR/test_invalid.$$
 
 function check_response()
 {
-       retcode=$1
-       expected_retcode=$2
-       expected_stderr_string=$3
-       if [ $1 != $2 ] ; then
-               echo "return code invalid: got $1, expected $2" >&2
+       expected_stderr_string=$1
+       retcode=$2
+       expected_retcode=$3
+       if [ "$expected_retcode" -a $retcode != $expected_retcode ] ; then
+               echo "return code invalid: got $retcode, expected $expected_retcode" >&2
                exit 1
        fi
 
-       if ! grep "$3" $TMPFILE >/dev/null 2>&1 ; then 
-               echo "Didn't find $3 in stderr output" >&2
+       if ! grep "$expected_stderr_string" $TMPFILE >/dev/null 2>&1 ; then 
+               echo "Didn't find $expected_stderr_string in stderr output" >&2
                echo "Stderr: " >&2
                cat $TMPFILE >&2
                exit 1
@@ -369,6 +369,13 @@ ceph osd pool set data size $new_size
 ceph osd pool get data size | grep "size: $new_size"
 ceph osd pool set data size $old_size
 
+ceph osd crush rule create-erasure ec_ruleset
+ceph osd pool create pool_erasure 12 12 erasure crush_ruleset=ec_ruleset
+set +e
+ceph osd pool set pool_erasure size 4444 2>$TMPFILE
+check_response $? 38 'can not change the size'
+set -e
+
 ceph osd pool set data hashpspool true
 ceph osd pool set data hashpspool false
 ceph osd pool set data hashpspool 0
@@ -391,16 +398,16 @@ ceph osd thrash 10
 set +e
 
 # expect error about missing 'pool' argument
-ceph osd map 2>$TMPFILE; check_response $? 22 'pool'
+ceph osd map 2>$TMPFILE; check_response 'pool' $? 22
 
 # expect error about unused argument foo
-ceph osd ls foo 2>$TMPFILE; check_response $? 22 'unused'
+ceph osd ls foo 2>$TMPFILE; check_response 'unused' $? 22 
 
 # expect "not in range" for invalid full ratio
-ceph pg set_full_ratio 95 2>$TMPFILE; check_response $? 22 'not in range'
+ceph pg set_full_ratio 95 2>$TMPFILE; check_response 'not in range' $? 22
 
 # expect "not in range" for invalid overload percentage
-ceph osd reweight-by-utilization 80 2>$TMPFILE; check_response $? 22 'not in range'
+ceph osd reweight-by-utilization 80 2>$TMPFILE; check_response 'not in range' $? 22
 
 # expect 'heap' commands to be correctly parsed
 ceph heap stats
index 0834e371a4b0b13cc14d780f355d9b3b157967d8..43e97a96cc009d91debc8059ccbcd5f390e5a0e4 100644 (file)
@@ -3078,7 +3078,7 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
   if (var == "size") {
     if (p.type == pg_pool_t::TYPE_ERASURE) {
       ss << "can not change the size of an erasure-coded pool";
-      return -ENOSYS;
+      return -ENOTSUP;
     }
     if (interr.length()) {
       ss << "error parsing integer value '" << val << "': " << interr;