]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/cephtool: test setting options using SI units
authorJoao Eduardo Luis <joao.luis@inktank.com>
Fri, 23 May 2014 16:02:23 +0000 (17:02 +0100)
committerSage Weil <sage@redhat.com>
Fri, 1 Aug 2014 23:54:28 +0000 (16:54 -0700)
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
(cherry picked from commit 38405d3554dfb0caf2b0a2c010b95a61bdb99349)

Conflicts:
qa/workunits/cephtool/test.sh

qa/workunits/cephtool/test.sh

index 4786514138634b2c40871da1f4f829637d3f2e8d..dc99a086da6c1c41e1e2c4ee4e33662a7ca98dfd 100755 (executable)
@@ -51,31 +51,66 @@ function check_response()
        fi
 }
 
-#
-# Verify ceph osd pool set data crush_ruleset when
-# when ruleset != rule_id http://tracker.ceph.com/issues/8599
-#
-MAP=$TMPFILE.map.$$
-ceph osd getcrushmap -o $MAP
-[ -s $MAP ]
-crushtool --decompile $MAP -o $MAP.decompiled
-RULESET=55
-cat >> $MAP.decompiled <<EOF
-rule testrule1 {
-       ruleset $RULESET
-       type replicated
-       min_size 1
-       max_size 10
-       step take default
-       step choose firstn 0 type osd
-       step emit
+function get_config_value_or_die()
+{
+  local target config_opt raw val
+
+  target=$1
+  config_opt=$2
+
+  raw="`ceph daemon $target config get $config_opt 2>/dev/null`"
+  if [[ $? -ne 0 ]]; then
+    echo "error obtaining config opt '$config_opt' from '$target': $raw"
+    exit 1
+  fi
+
+  raw=`echo $raw | sed -e 's/[{} "]//g'`
+  val=`echo $raw | cut -f2 -d:`
+
+  echo "$val"
+  return 0
 }
-EOF
-crushtool --compile $MAP.decompiled -o $MAP.modified
-ceph osd setcrushmap -i $MAP.modified
-ceph osd pool set data crush_ruleset $RULESET
-ceph osd pool set data crush_ruleset 0
-rm $MAP{,.decompiled,.modified}
+
+function expect_config_value()
+{
+  local target config_opt expected_val val
+  target=$1
+  config_opt=$2
+  expected_val=$3
+
+  val=$(get_config_value_or_die $target $config_opt)
+
+  if [[ "$val" != "$expected_val" ]]; then
+    echo "expected '$expected_val', got '$val'"
+    exit 1
+  fi
+}
+
+
+# Test SI units during injectargs and 'config set'
+# We only aim at testing the units are parsed accordingly
+# and don't intend to test whether the options being set
+# actually expect SI units to be passed.
+# Keep in mind that all integer based options (i.e., INT,
+# LONG, U32, U64) will accept SI unit modifiers.
+initial_value=$(get_config_value_or_die "mon.a" "mon_pg_warn_min_objects")
+ceph daemon mon.a config set mon_pg_warn_min_objects 10
+expect_config_value "mon.a" "mon_pg_warn_min_objects" 10
+ceph daemon mon.a config set mon_pg_warn_min_objects 10K
+expect_config_value "mon.a" "mon_pg_warn_min_objects" 10240
+ceph daemon mon.a config set mon_pg_warn_min_objects 1G
+expect_config_value "mon.a" "mon_pg_warn_min_objects" 1073741824
+ceph daemon mon.a config set mon_pg_warn_min_objects 10F > $TMPFILE || true
+check_response "'10F': (22) Invalid argument"
+# now test with injectargs
+ceph tell mon.a injectargs '--mon_pg_warn_min_objects 10'
+expect_config_value "mon.a" "mon_pg_warn_min_objects" 10
+ceph tell mon.a injectargs '--mon_pg_warn_min_objects 10K'
+expect_config_value "mon.a" "mon_pg_warn_min_objects" 10240
+ceph tell mon.a injectargs '--mon_pg_warn_min_objects 1G'
+expect_config_value "mon.a" "mon_pg_warn_min_objects" 1073741824
+expect_false ceph injectargs mon.a '--mon_pg_warn_min_objects 10F'
+ceph daemon mon.a config set mon_pg_warn_min_objects $initial_value
 
 # tiering
 ceph osd pool create cache 2
@@ -616,5 +651,4 @@ expect_false ceph tell osd.0 bench 51 2097152
 # but 50 must succeed
 ceph tell osd.0 bench 50 2097152
 
-
 echo OK