From 9f7aabbe9fb77c5a7d76286f9e6c31fe106977e3 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Mon, 13 Jan 2020 17:29:11 -0800 Subject: [PATCH] test: Fix wait_for_state() to wait for a PG to get into a state To avoid confusion fix function names in osd-backfill-space.sh for how they actually work. Fixes: https://tracker.ceph.com/issues/43592 Signed-off-by: David Zafman --- qa/standalone/osd/osd-backfill-space.sh | 42 ++++++++++++------------- qa/standalone/osd/osd-recovery-space.sh | 8 ++--- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/qa/standalone/osd/osd-backfill-space.sh b/qa/standalone/osd/osd-backfill-space.sh index cd3f8dff9210b..3978668eae23c 100755 --- a/qa/standalone/osd/osd-backfill-space.sh +++ b/qa/standalone/osd/osd-backfill-space.sh @@ -49,7 +49,7 @@ function get_num_in_state() { } -function wait_for_state() { +function wait_for_not_state() { local state=$1 local num_in_state=-1 local cur_in_state @@ -78,15 +78,15 @@ function wait_for_state() { } -function wait_for_backfill() { +function wait_for_not_backfilling() { local timeout=$1 - wait_for_state backfilling $timeout + wait_for_not_state backfilling $timeout } -function wait_for_active() { +function wait_for_not_activating() { local timeout=$1 - wait_for_state activating $timeout + wait_for_not_state activating $timeout } # All tests are created in an environment which has fake total space @@ -149,8 +149,8 @@ function TEST_backfill_test_simple() { done sleep 30 - wait_for_backfill 240 || return 1 - wait_for_active 60 || return 1 + wait_for_not_backfilling 240 || return 1 + wait_for_not_activating 60 || return 1 ERRORS=0 if [ "$(ceph pg dump pgs | grep +backfill_toofull | wc -l)" != "1" ]; @@ -228,8 +228,8 @@ function TEST_backfill_test_multi() { done sleep 30 - wait_for_backfill 240 || return 1 - wait_for_active 60 || return 1 + wait_for_not_backfilling 240 || return 1 + wait_for_not_activating 60 || return 1 ERRORS=0 full="$(ceph pg dump pgs | grep +backfill_toofull | wc -l)" @@ -380,8 +380,8 @@ function TEST_backfill_test_sametarget() { ceph osd pool set $pool2 size 2 sleep 30 - wait_for_backfill 240 || return 1 - wait_for_active 60 || return 1 + wait_for_not_backfilling 240 || return 1 + wait_for_not_activating 60 || return 1 ERRORS=0 if [ "$(ceph pg dump pgs | grep +backfill_toofull | wc -l)" != "1" ]; @@ -512,8 +512,8 @@ function TEST_backfill_multi_partial() { ceph osd in osd.$fillosd sleep 30 - wait_for_backfill 240 || return 1 - wait_for_active 60 || return 1 + wait_for_not_backfilling 240 || return 1 + wait_for_not_activating 60 || return 1 flush_pg_stats || return 1 ceph pg dump pgs @@ -695,8 +695,8 @@ function TEST_ec_backfill_simple() { ceph pg dump pgs - wait_for_backfill 240 || return 1 - wait_for_active 60 || return 1 + wait_for_not_backfilling 240 || return 1 + wait_for_not_activating 60 || return 1 ceph pg dump pgs @@ -819,8 +819,8 @@ function TEST_ec_backfill_multi() { sleep 30 - wait_for_backfill 240 || return 1 - wait_for_active 60 || return 1 + wait_for_not_backfilling 240 || return 1 + wait_for_not_activating 60 || return 1 ceph pg dump pgs @@ -958,8 +958,8 @@ function SKIP_TEST_ec_backfill_multi_partial() { sleep 30 ceph pg dump pgs - wait_for_backfill 240 || return 1 - wait_for_active 60 || return 1 + wait_for_not_backfilling 240 || return 1 + wait_for_not_activating 60 || return 1 ceph pg dump pgs @@ -1066,8 +1066,8 @@ function SKIP_TEST_ec_backfill_multi_partial() { ceph osd in osd.$fillosd sleep 30 - wait_for_backfill 240 || return 1 - wait_for_active 60 || return 1 + wait_for_not_backfilling 240 || return 1 + wait_for_not_activating 60 || return 1 ERRORS=0 if [ "$(ceph pg dump pgs | grep -v "^1.0" | grep +backfill_toofull | wc -l)" != "1" ]; diff --git a/qa/standalone/osd/osd-recovery-space.sh b/qa/standalone/osd/osd-recovery-space.sh index d12494a90cafb..82cdf82e5733a 100755 --- a/qa/standalone/osd/osd-recovery-space.sh +++ b/qa/standalone/osd/osd-recovery-space.sh @@ -49,7 +49,6 @@ function get_num_in_state() { function wait_for_state() { local state=$1 - local num_in_state=-1 local cur_in_state local -a delays=($(get_timeout_delays $2 5)) local -i loop=0 @@ -61,11 +60,8 @@ function wait_for_state() { while true ; do cur_in_state=$(get_num_in_state ${state}) - test $cur_in_state = "0" && break - if test $cur_in_state != $num_in_state ; then - loop=0 - num_in_state=$cur_in_state - elif (( $loop >= ${#delays[*]} )) ; then + test $cur_in_state -gt 0 && break + if (( $loop >= ${#delays[*]} )) ; then ceph pg dump pgs return 1 fi -- 2.39.5