From 0cc810360b8e4a415f7f182e4b21f64713004825 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Wed, 27 Nov 2019 10:50:01 -0800 Subject: [PATCH] test: Add test case based on Xie script in commit comment Other test fixes to reflect changes Signed-off-by: David Zafman (cherry picked from commit 9d2e0267e1f025a634ee4925c919008cacdd3d38) Conflict: src/test/cli/osdmaptool/upmap-out.t (older output format) src/test/cli/osdmaptool/upmap.t (older output format) --- qa/standalone/mgr/balancer.sh | 92 +++++++++++++++++++++++++++++ src/test/cli/osdmaptool/help.t | 2 +- src/test/cli/osdmaptool/upmap-out.t | 10 ++-- src/test/cli/osdmaptool/upmap.t | 10 ++-- 4 files changed, 105 insertions(+), 9 deletions(-) diff --git a/qa/standalone/mgr/balancer.sh b/qa/standalone/mgr/balancer.sh index 979d70e3c2c3e..b8dffccbe8fa8 100755 --- a/qa/standalone/mgr/balancer.sh +++ b/qa/standalone/mgr/balancer.sh @@ -118,6 +118,98 @@ function TEST_balancer() { teardown $dir || return 1 } +function TEST_balancer2() { + local dir=$1 + TEST_PGS1=118 + TEST_PGS2=132 + TOTAL_PGS=$(expr $TEST_PGS1 + $TEST_PGS2) + OSDS=5 + DEFAULT_REPLICAS=3 + # Integer average of PGS per OSD (70.8), so each OSD >= this + FINAL_PER_OSD1=$(expr \( $TEST_PGS1 \* $DEFAULT_REPLICAS \) / $OSDS) + # Integer average of PGS per OSD (150) + FINAL_PER_OSD2=$(expr \( \( $TEST_PGS1 + $TEST_PGS2 \) \* $DEFAULT_REPLICAS \) / $OSDS) + + CEPH_ARGS+="--osd_pool_default_pg_autoscale_mode=off " + CEPH_ARGS+="--debug_osd=20 " + setup $dir || return 1 + run_mon $dir a || return 1 + run_mgr $dir x || return 1 + for i in $(seq 0 $(expr $OSDS - 1)) + do + run_osd $dir $i || return 1 + done + + ceph osd set-require-min-compat-client luminous + ceph balancer mode upmap || return 1 + ceph balancer on || return 1 + ceph config set mgr mgr/balancer/sleep_interval 5 + + create_pool $TEST_POOL1 $TEST_PGS1 + + wait_for_clean || return 1 + + # Wait up to 2 minutes + OK=no + for i in $(seq 1 25) + do + sleep 5 + if grep -q "Optimization plan is almost perfect" $dir/mgr.x.log + then + OK=yes + break + fi + done + test $OK = "yes" || return 1 + # Plan is found, but PGs still need to move + sleep 30 + ceph osd df + + PGS=$(ceph osd df --format=json-pretty | jq '.nodes[0].pgs') + test $PGS -ge $FINAL_PER_OSD1 || return 1 + PGS=$(ceph osd df --format=json-pretty | jq '.nodes[1].pgs') + test $PGS -ge $FINAL_PER_OSD1 || return 1 + PGS=$(ceph osd df --format=json-pretty | jq '.nodes[2].pgs') + test $PGS -ge $FINAL_PER_OSD1 || return 1 + PGS=$(ceph osd df --format=json-pretty | jq '.nodes[3].pgs') + test $PGS -ge $FINAL_PER_OSD1 || return 1 + PGS=$(ceph osd df --format=json-pretty | jq '.nodes[4].pgs') + test $PGS -ge $FINAL_PER_OSD1 || return 1 + + create_pool $TEST_POOL2 $TEST_PGS2 + + # Wait up to 2 minutes + OK=no + for i in $(seq 1 25) + do + sleep 5 + COUNT=$(grep "Optimization plan is almost perfect" $dir/mgr.x.log | wc -l) + if test $COUNT = "2" + then + OK=yes + break + fi + done + test $OK = "yes" || return 1 + # Plan is found, but PGs still need to move + sleep 30 + ceph osd df + + # FINAL_PER_OSD2 should distribute evenly + PGS=$(ceph osd df --format=json-pretty | jq '.nodes[0].pgs') + test $PGS -eq $FINAL_PER_OSD2 || return 1 + PGS=$(ceph osd df --format=json-pretty | jq '.nodes[1].pgs') + test $PGS -eq $FINAL_PER_OSD2 || return 1 + PGS=$(ceph osd df --format=json-pretty | jq '.nodes[2].pgs') + test $PGS -eq $FINAL_PER_OSD2 || return 1 + PGS=$(ceph osd df --format=json-pretty | jq '.nodes[3].pgs') + test $PGS -eq $FINAL_PER_OSD2 || return 1 + PGS=$(ceph osd df --format=json-pretty | jq '.nodes[4].pgs') + test $PGS -eq $FINAL_PER_OSD2 || return 1 + + teardown $dir || return 1 +} + main balancer "$@" # Local Variables: diff --git a/src/test/cli/osdmaptool/help.t b/src/test/cli/osdmaptool/help.t index 643b624a7741f..9309cfbdcba4f 100644 --- a/src/test/cli/osdmaptool/help.t +++ b/src/test/cli/osdmaptool/help.t @@ -20,7 +20,7 @@ writing commands to [default: - for stdout] --upmap-max set max upmap entries to calculate [default: 10] --upmap-deviation - max deviation from target [default: .01] + max deviation from target [default: 1] --upmap-pool restrict upmap balancing to 1 or more pools --upmap-save write modified OSDMap with upmap changes [1] diff --git a/src/test/cli/osdmaptool/upmap-out.t b/src/test/cli/osdmaptool/upmap-out.t index 54a1def1a9603..8a167aba09a92 100644 --- a/src/test/cli/osdmaptool/upmap-out.t +++ b/src/test/cli/osdmaptool/upmap-out.t @@ -7,16 +7,18 @@ marking OSD@147 as out writing upmap command output to: c checking for upmap cleanups - upmap, max-count 11, max deviation 0.01 + upmap, max-count 11, max deviation 1 pools rbd prepared 11/11 changes $ cat c ceph osd pg-upmap-items 1.7 142 145 ceph osd pg-upmap-items 1.8 219 223 - ceph osd pg-upmap-items 1.17 171 173 201 202 + ceph osd pg-upmap-items 1.17 201 202 171 173 ceph osd pg-upmap-items 1.1a 201 202 - ceph osd pg-upmap-items 1.1c 171 173 201 202 - ceph osd pg-upmap-items 1.20 88 87 201 202 + ceph osd pg-upmap-items 1.1c 201 202 + ceph osd pg-upmap-items 1.20 201 202 + ceph osd pg-upmap-items 1.51 201 202 ceph osd pg-upmap-items 1.62 219 223 ceph osd pg-upmap-items 1.6f 219 223 + ceph osd pg-upmap-items 1.82 219 223 $ rm -f om c diff --git a/src/test/cli/osdmaptool/upmap.t b/src/test/cli/osdmaptool/upmap.t index 4ff14306fe113..8fa1a61031364 100644 --- a/src/test/cli/osdmaptool/upmap.t +++ b/src/test/cli/osdmaptool/upmap.t @@ -6,16 +6,18 @@ marking all OSDs up and in writing upmap command output to: c checking for upmap cleanups - upmap, max-count 11, max deviation 0.01 + upmap, max-count 11, max deviation 1 pools rbd prepared 11/11 changes $ cat c ceph osd pg-upmap-items 1.7 142 147 ceph osd pg-upmap-items 1.8 219 223 - ceph osd pg-upmap-items 1.17 171 173 201 202 + ceph osd pg-upmap-items 1.17 201 202 171 173 ceph osd pg-upmap-items 1.1a 201 202 - ceph osd pg-upmap-items 1.1c 171 173 201 202 - ceph osd pg-upmap-items 1.20 88 87 201 202 + ceph osd pg-upmap-items 1.1c 201 202 + ceph osd pg-upmap-items 1.20 201 202 + ceph osd pg-upmap-items 1.24 232 233 ceph osd pg-upmap-items 1.51 201 202 ceph osd pg-upmap-items 1.62 219 223 + ceph osd pg-upmap-items 1.6f 219 223 $ rm -f om c -- 2.39.5