]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test: Add tests for pool recovery priority conversion
authorDavid Zafman <dzafman@redhat.com>
Tue, 23 Apr 2019 21:04:54 +0000 (14:04 -0700)
committerDavid Zafman <dzafman@redhat.com>
Thu, 25 Apr 2019 20:53:27 +0000 (13:53 -0700)
Signed-off-by: David Zafman <dzafman@redhat.com>
qa/standalone/mon/osd-pool-create.sh
src/common/legacy_config_opts.h
src/common/options.cc
src/mon/OSDMonitor.cc

index 992cbf583aaf57c7df1d831c86a6c930db5f4ca5..f404cdda919a3aa7e618fad83035896b432ec5b1 100755 (executable)
@@ -233,6 +233,95 @@ function TEST_pool_create_rep_expected_num_objects() {
     fi
 }
 
+function check_pool_priority() {
+    local dir=$1
+    shift
+    local pools=$1
+    shift
+    local spread="$1"
+    shift
+    local results="$1"
+
+    setup $dir || return 1
+
+    EXTRA_OPTS="--debug_allow_any_pool_priority=true"
+    export EXTRA_OPTS
+    run_mon $dir a || return 1
+    run_mgr $dir x || return 1
+    run_osd $dir 0 || return 1
+    run_osd $dir 1 || return 1
+    run_osd $dir 2 || return 1
+
+    # Add pool 0 too
+    for i in $(seq 0 $pools)
+    do
+      num=$(expr $i + 1)
+      ceph osd pool create test${num} 1 1
+    done
+
+    wait_for_clean || return 1
+    for i in $(seq 0 $pools)
+    do
+       num=$(expr $i + 1)
+       ceph osd pool set test${num} recovery_priority $(expr $i \* $spread)
+    done
+
+    #grep "recovery_priority.*pool set" out/mon.a.log
+
+    bin/ceph osd dump
+
+    # Restart everything so mon converts the priorities
+    kill_daemons
+    run_mon $dir a || return 1
+    run_mgr $dir x || return 1
+    activate_osd $dir 0 || return 1
+    activate_osd $dir 1 || return 1
+    activate_osd $dir 2 || return 1
+    sleep 5
+
+    grep convert $dir/mon.a.log
+    ceph osd dump
+
+    pos=1
+    for i in $(ceph osd dump | grep ^pool | sed 's/.*recovery_priority //' | awk '{ print $1 }')
+    do
+      result=$(echo $results | awk "{ print \$${pos} }")
+      # A value of 0 is an unset value so sed/awk gets "pool"
+      if test $result = "0"
+      then
+        result="pool"
+      fi
+      test "$result" = "$i" || return 1
+      pos=$(expr $pos + 1)
+    done
+}
+
+function TEST_pool_pos_only_prio() {
+   local dir=$1
+   check_pool_priority $dir 20 5 "0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10" || return 1
+}
+
+function TEST_pool_neg_only_prio() {
+   local dir=$1
+   check_pool_priority $dir 20 -5 "0 0 -1 -1 -2 -2 -3 -3 -4 -4 -5 -5 -6 -6 -7 -7 -8 -8 -9 -9 -10" || return 1
+}
+
+function TEST_pool_both_prio() {
+   local dir=$1
+   check_pool_priority $dir 20 "5 - 50" "-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10" || return 1
+}
+
+function TEST_pool_both_prio_no_neg() {
+   local dir=$1
+   check_pool_priority $dir 20 "2 - 4" "-4 -2 0 0 1 1 2 2 3 3 4 5 5 6 6 7 7 8 8 9 10" || return 1
+}
+
+function TEST_pool_both_prio_no_pos() {
+   local dir=$1
+   check_pool_priority $dir 20 "2 - 36" "-10 -9 -8 -8 -7 -7 -6 -6 -5 -5 -4 -3 -3 -2 -2 -1 -1 0 0 2 4" || return 1
+}
+
+
 main osd-pool-create "$@"
 
 # Local Variables:
index 7d78a292afb651685182b5945c79a33d256ad181..74fb120e87d74939ead2e0f1c06433ff77dc5d90 100644 (file)
@@ -1536,3 +1536,4 @@ OPTION(fake_statfs_for_testing, OPT_INT) // Set a value for kb and compute kb_us
 OPTION(rgw_sts_token_introspection_url, OPT_STR)  // url for introspecting web tokens
 OPTION(rgw_sts_client_id, OPT_STR) // Client Id
 OPTION(rgw_sts_client_secret, OPT_STR) // Client Secret
+OPTION(debug_allow_any_pool_priority, OPT_BOOL)
index 36ed0fbb355fdf1c88fac8bb80f275ba9b94f7a9..f7c8e821884429f8532b2dafa4e4b6b78fd8751c 100644 (file)
@@ -8146,6 +8146,10 @@ std::vector<Option> get_mds_client_options() {
     Option("fake_statfs_for_testing", Option::TYPE_INT, Option::LEVEL_DEV)
     .set_default(0)
     .set_description("Set a value for kb and compute kb_used from total of num_bytes"),
+
+    Option("debug_allow_any_pool_priority", Option::TYPE_BOOL, Option::LEVEL_DEV)
+    .set_default(false)
+    .set_description("Allow any pool priority to be set to test conversion to new range"),
   });
 }
 
index 58a1096a1aae16babc108aa80bc9340de9e84cc3..88c6ca35b254630e276886204e8dc312ddf2f07e 100644 (file)
@@ -7625,10 +7625,12 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap,
         ss << "error parsing int value '" << val << "': " << interr;
         return -EINVAL;
       }
-      if (n > OSD_POOL_PRIORITY_MAX || n < OSD_POOL_PRIORITY_MIN) {
-        ss << "pool recovery_priority must be between " << OSD_POOL_PRIORITY_MIN
-          << " and " << OSD_POOL_PRIORITY_MAX;
-        return -EINVAL;
+      if (!g_conf()->debug_allow_any_pool_priority) {
+        if (n > OSD_POOL_PRIORITY_MAX || n < OSD_POOL_PRIORITY_MIN) {
+          ss << "pool recovery_priority must be between " << OSD_POOL_PRIORITY_MIN
+            << " and " << OSD_POOL_PRIORITY_MAX;
+          return -EINVAL;
+        }
       }
     } else if (var == "pg_autoscale_bias") {
       if (f < 0.0 || f > 1000.0) {