]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test_unfound.sh: verify that we have unfound objs
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 5 Nov 2010 00:28:39 +0000 (17:28 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 10 Nov 2010 19:46:28 +0000 (11:46 -0800)
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 <colinm@hq.newdream.net>
src/mon/PGMonitor.cc
src/test/test_common.sh
src/test/test_unfound.sh

index 7e75dfab2824c6740660ebac1d8d092f5f8c6be4..52c8d92f32fd9a72430fbafdf288be41f5c3c1f9 100644 (file)
@@ -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<pg_t,pg_stat_t>::const_iterator end = pg_map.pg_stat.end();
+       for (hash_map<pg_t,pg_stat_t>::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) {
index 4f644d5fc07f4786e81dd7442520a64eb6f615e9..04f9642d4a8f4fb841a24ff32f40e53aecc1b079 100755 (executable)
@@ -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
index e214323bf2adf6e4b965a1c7bdff45ffa73180af..4fd368512428470952e53b78e5b4f4b2f7203ad9 100755 (executable)
@@ -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() {