From fc605cedee2e243075ea57a3a892ac2784f7b925 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Thu, 4 Nov 2010 17:28:39 -0700 Subject: [PATCH] test_unfound.sh: verify that we have unfound objs test_unfound.sh: verify that we have unfound objs. Then, when we bring up the other OSD, verify that those unfound objects are found (on that OSD). Signed-off-by: Colin McCabe --- src/mon/PGMonitor.cc | 20 ++++++++++++++++++++ src/test/test_common.sh | 17 +++++++++++++++++ src/test/test_unfound.sh | 11 +++++++++-- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 7e75dfab2824c..52c8d92f32fd9 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -735,6 +735,26 @@ bool PGMonitor::preprocess_command(MMonCommand *m) } else ss << "invalid pgid '" << m->cmd[2] << "'"; } + else if ((m->cmd[1] == "debug") && (m->cmd.size() > 2)) { + if (m->cmd[2] == "unfound_objects_exist") { + bool unfound_objects_exist = false; + hash_map::const_iterator end = pg_map.pg_stat.end(); + for (hash_map::const_iterator s = pg_map.pg_stat.begin(); + s != end; ++s) + { + if (s->second.num_objects_unfound > 0) { + unfound_objects_exist = true; + break; + } + } + if (unfound_objects_exist) + ss << "TRUE"; + else + ss << "FALSE"; + + r = 0; + } + } } if (r != -1) { diff --git a/src/test/test_common.sh b/src/test/test_common.sh index 4f644d5fc07f4..04f9642d4a8f4 100755 --- a/src/test/test_common.sh +++ b/src/test/test_common.sh @@ -99,4 +99,21 @@ write_objects() { done } +poll_cmd() { + command=$1 + search_str=$2 + polling_interval=$3 + total_time=$4 + + t=0 + while [ $t -lt $total_time ]; do + $command | grep $search_str + [ $? -eq 0 ] && return 1 + sleep $polling_interval + t=$(($t+$polling_interval)) + done + + return 0 +} + init diff --git a/src/test/test_unfound.sh b/src/test/test_unfound.sh index e214323bf2adf..4fd3685124284 100755 --- a/src/test/test_unfound.sh +++ b/src/test/test_unfound.sh @@ -41,10 +41,17 @@ do_test() { # Objects should be lost. stop_osd 0 - echo "There should be unfound objects." - continue_prompt "to test finding the unfound objects." + poll_cmd "./ceph pg debug unfound_objects_exist" TRUE 3 120 + [ $? -eq 1 ] || die "Failed to see unfound objects." + echo "Got unfound objects." restart_osd 0 + + poll_cmd "./ceph pg debug unfound_objects_exist" FALSE 3 120 + [ $? -eq 1 ] || die "Failed to recover unfound objects." + + # success + return 1 } run() { -- 2.39.5