[tracker/sam/functional-test-fixes: 15/28] functional-tests: Wait for changes using GraphUpdated, not Miner.Status



commit ce761de27ac69b9e4eec15d1b3a8a11cee0e78fe
Author: Sam Thursfield <sam afuera me uk>
Date:   Sat Aug 2 03:27:12 2014 +0100

    functional-tests: Wait for changes using GraphUpdated, not Miner.Status
    
    Use the await_resource_inserted(), await_resource_deleted() and
    await_property_changed() methods as these are reliable. Waiting for
    the miner to go idle and hoping this means that the desired file was
    crawled and extracted is not reliable at all.
    
    This should hopefully make the tests robust enough to be run continuously
    without random failures occuring.
    
    The tracker_miner_fs_wait_for_idle() functions are gone forever!

 tests/functional-tests/300-miner-basic-ops.py   |    3 --
 tests/functional-tests/601-applications-sync.py |    3 +-
 tests/functional-tests/common/utils/helpers.py  |   27 -----------------------
 tests/functional-tests/common/utils/system.py   |    7 ------
 4 files changed, 1 insertions(+), 39 deletions(-)
---
diff --git a/tests/functional-tests/300-miner-basic-ops.py b/tests/functional-tests/300-miner-basic-ops.py
index 124e992..1fc50da 100755
--- a/tests/functional-tests/300-miner-basic-ops.py
+++ b/tests/functional-tests/300-miner-basic-ops.py
@@ -295,11 +295,8 @@ class MinerCrawlTest (CommonTrackerMinerTest):
         self.assertIn ( uri ("test-monitored/file1.txt"), unpacked_result)
 
         # Restore the dirs
-        #  Wait after each operation to be sure of the results
         os.makedirs (os.path.join (MINER_TMP_DIR, "test-monitored", "dir1"))
-        self.system.tracker_miner_fs_wait_for_idle ()
         os.makedirs (os.path.join (MINER_TMP_DIR, "test-monitored", "dir1", "dir2"))
-        self.system.tracker_miner_fs_wait_for_idle ()
         for f in ["test-monitored/dir1/file2.txt",
                   "test-monitored/dir1/dir2/file3.txt"]:
             filename = os.path.join (MINER_TMP_DIR, f)
diff --git a/tests/functional-tests/601-applications-sync.py b/tests/functional-tests/601-applications-sync.py
index 2dc753c..5655b57 100755
--- a/tests/functional-tests/601-applications-sync.py
+++ b/tests/functional-tests/601-applications-sync.py
@@ -36,7 +36,6 @@ import unittest2 as ut
 from common.utils.applicationstest import CommonTrackerApplicationTest as CommonTrackerApplicationTest
 from common.utils.helpers import log
 
-MINER_FS_IDLE_TIMEOUT = 30
 
 class TrackerSyncApplicationTests (CommonTrackerApplicationTest):
 
@@ -91,7 +90,7 @@ class TrackerSyncApplicationTests (CommonTrackerApplicationTest):
         # Copy the image to the dest path
         self.slowcopy_file (origin_filepath, dest_filepath)
         assert os.path.exists (dest_filepath)
-        self.system.tracker_miner_fs_wait_for_idle (MINER_FS_IDLE_TIMEOUT)
+        self.tracker.await_resource_inserted ('nmm:MusicPiece', url=dest_fileuri)
         self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
 
         # Clean the new file so the test directory is as before
diff --git a/tests/functional-tests/common/utils/helpers.py b/tests/functional-tests/common/utils/helpers.py
index 5a2b875..1ff422a 100644
--- a/tests/functional-tests/common/utils/helpers.py
+++ b/tests/functional-tests/common/utils/helpers.py
@@ -618,10 +618,6 @@ class MinerFsHelper (Helper):
     if cfg.haveMaemo:
         FLAGS.append ('--disable-miner=userguides')
 
-    def _minerfs_status_cb (self, status, progress, remaining_time):
-        if (status == "Idle"):
-            self.loop.quit ()
-
     def start (self):
         Helper.start (self)
 
@@ -650,29 +646,6 @@ class MinerFsHelper (Helper):
     def ignore (self, filelist):
         self.miner_fs.IgnoreNextUpdate (filelist)
 
-    def wait_for_idle (self, timeout=REASONABLE_TIMEOUT):
-        """
-        Block until the miner has finished crawling and its status becomes "Idle"
-        """
-        status = self.miner_fs.GetStatus()
-        log ('Current miner FS status: %s' % status)
-
-        if status == 'Idle':
-            return
-
-        self.status_match = self.bus.add_signal_receiver (self._minerfs_status_cb,
-                                                          signal_name="Progress",
-                                                          path=cfg.MINERFS_OBJ_PATH,
-                                                          dbus_interface=cfg.MINER_IFACE)
-        self.timeout_id = GLib.timeout_add_seconds (REASONABLE_TIMEOUT, self._timeout_on_idle_cb)
-        self._name_source (self.timeout_id, 'wait-for-idle-timeout')
-
-        self.loop.run ()
-
-        if self.timeout_id is not None:
-            GLib.source_remove (self.timeout_id)
-        self.bus._clean_up_signal_match (self.status_match)
-
 
 class ExtractorHelper (Helper):
 
diff --git a/tests/functional-tests/common/utils/system.py b/tests/functional-tests/common/utils/system.py
index 8759750..16540c7 100644
--- a/tests/functional-tests/common/utils/system.py
+++ b/tests/functional-tests/common/utils/system.py
@@ -178,13 +178,6 @@ class TrackerSystemAbstraction:
         self.miner_fs = helpers.MinerFsHelper ()
         self.miner_fs.start ()
 
-    def tracker_miner_fs_wait_for_idle (self, timeout=REASONABLE_TIMEOUT):
-        """
-        Copy the files physically in the filesyste and wait for the miner to complete the work
-        """
-        self.miner_fs.wait_for_idle (timeout)
-
-
     def tracker_miner_fs_testing_stop (self):
         """
         Stops the miner-fs and store running and unset all the XDG_*_HOME vars


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]