]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tasks/cephfs: fix race in TestStrays
authorJohn Spray <john.spray@redhat.com>
Wed, 22 Jul 2015 14:27:39 +0000 (15:27 +0100)
committerJohn Spray <john.spray@redhat.com>
Fri, 2 Oct 2015 16:41:16 +0000 (17:41 +0100)
We weren't waiting for export dir to complete (the asok
just starts the process).  This wasn't noticeable when running
remotely due to latency between the test runner and the MDS,
but it shows up when running against a local vstart cluster.

Signed-off-by: John Spray <john.spray@redhat.com>
tasks/cephfs/test_strays.py

index 7530e5c6710d0f6e0dbd506befe572d9a6c8ae3c..9c1f569ac9cc61055f24e066fde700e50e5b6ff3 100644 (file)
@@ -1,4 +1,4 @@
-
+import json
 import logging
 from textwrap import dedent
 import time
@@ -400,6 +400,26 @@ class TestStrays(CephFSTestCase):
         result = self.fs.mds_asok(["export", "dir", "/ALPHA", "1"], rank_0_id)
         self.assertEqual(result["return_code"], 0)
 
+        # Pool the MDS cache dump to watch for the export completing
+        migrated = False
+        migrate_timeout = 60
+        migrate_elapsed = 0
+        while not migrated:
+            data = self.fs.mds_asok(["dump", "cache"], rank_1_id)
+            for inode_data in data:
+                if inode_data['ino'] == ino:
+                    log.debug("Found ino in cache: {0}".format(json.dumps(inode_data, indent=2)))
+                    if inode_data['is_auth'] is True:
+                        migrated = True
+                    break
+
+            if not migrated:
+                if migrate_elapsed > migrate_timeout:
+                    raise RuntimeError("Migration hasn't happened after {0}s!".format(migrate_elapsed))
+                else:
+                    migrate_elapsed += 1
+                    time.sleep(1)
+
         # Delete the file on rank 1
         self.mount_a.run_shell(["rm", "-f", "ALPHA/alpha_file"])