]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/cephtool: test setting options using SI units 1857/head
authorJoao Eduardo Luis <joao.luis@inktank.com>
Fri, 23 May 2014 16:02:23 +0000 (17:02 +0100)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Fri, 30 May 2014 21:09:23 +0000 (22:09 +0100)
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
qa/workunits/cephtool/test.sh

index 8ed6bd12c015924a791b3c4d32d96f10e4df7d65..99a83445959f16d64f1211ba4e9ed45d1f918bd4 100755 (executable)
@@ -51,6 +51,66 @@ function check_response()
        fi
 }
 
+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
+}
+
+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
@@ -590,5 +650,4 @@ expect_false ceph tell osd.0 bench 51 2097152
 # but 50 must succeed
 ceph tell osd.0 bench 50 2097152
 
-
 echo OK