From 55095d56ea9179ee3025719dc0c4e9a8d018df13 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Fri, 2 Aug 2013 20:50:20 -0700 Subject: [PATCH] cephtool/test.sh: add a few tests for invalid command args Signed-off-by: Dan Mick Reviewed-by: Sage Weil --- qa/workunits/cephtool/test.sh | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index d759d675276..e84119920cf 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -25,6 +25,29 @@ expect_false() if "$@"; then return 1; else return 0; fi } +TMPFILE=/tmp/test_invalid.$$ +trap "rm $TMPFILE" 0 + +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 + exit 1 + fi + + if ! grep "$3" $TMPFILE >/dev/null 2>&1 ; then + echo "Didn't find $3 in stderr output" >&2 + echo "Stderr: " >&2 + cat $TMPFILE >&2 + exit 1 + fi +} + + + # # Assumes there are at least 3 MDSes and two OSDs # @@ -255,4 +278,18 @@ ceph osd pool get rbd crush_ruleset | grep 'crush_ruleset: 2' ceph osd thrash 10 +set +e + +# expect error about missing 'pool' argument +ceph osd map 2>$TMPFILE; check_response $? 22 'pool' + +# expect error about unused argument foo +ceph osd ls foo 2>$TMPFILE; check_response $? 22 'unused' + +# expect "not in range" for invalid full ratio +ceph pg set_full_ratio 95 2>$TMPFILE; check_response $? 22 'not in range' + +# expect "not in range" for invalid overload percentage +ceph osd reweight-by-utilization 80 2>$TMPFILE; check_response $? 22 'not in range' + echo OK -- 2.47.3