[tracker-miners/sam/tracker-miners-2.3-functional-tests-intermittent-failures: 3/3] functional-tests: Fix intermittent test failures



commit fbc456b0a157f3212005df9744652346bc3d4e2f
Author: Sam Thursfield <sam afuera me uk>
Date:   Sat Sep 21 16:40:27 2019 +0200

    functional-tests: Fix intermittent test failures
    
    The various intermittent test failures were caused by a race condition,
    where the miner sometimes ignores files created during the initial
    crawl. (https://gitlab.gnome.org/GNOME/tracker-miners/issues/79).
    
    Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/issues/56, 
https://gitlab.gnome.org/GNOME/tracker-miners/issues/57, 
https://gitlab.gnome.org/GNOME/tracker-miners/issues/62

 tests/functional-tests/common/utils/minertest.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/tests/functional-tests/common/utils/minertest.py 
b/tests/functional-tests/common/utils/minertest.py
index 92d81fb5f..c611305b3 100644
--- a/tests/functional-tests/common/utils/minertest.py
+++ b/tests/functional-tests/common/utils/minertest.py
@@ -71,6 +71,11 @@ class CommonTrackerMinerTest (ut.TestCase):
             }
         }
 
+        # We must create the test data before the miner does its
+        # initial crawl, or it may miss some files due
+        # https://gitlab.gnome.org/GNOME/tracker-miners/issues/79.
+        monitored_files = self.create_test_data()
+
         try:
             self.system.tracker_miner_fs_testing_start(config)
         except RuntimeError as e:
@@ -79,7 +84,11 @@ class CommonTrackerMinerTest (ut.TestCase):
         self.tracker = self.system.store
 
         try:
-            self.create_test_data()
+            for tf in monitored_files:
+                self.tracker.await_resource_inserted(NFO_DOCUMENT, url=self.uri(tf))
+
+            # We reset update-tracking, so that updates for data created in the
+            # fixture can't be mixed up with updates created by the test case.
             self.tracker.reset_graph_updates_tracking()
         except Exception as e:
             self.tearDown()
@@ -113,8 +122,7 @@ class CommonTrackerMinerTest (ut.TestCase):
             with open(testfile, 'w') as f:
                 f.write(DEFAULT_TEXT)
 
-        for tf in monitored_files:
-            self.tracker.await_resource_inserted(NFO_DOCUMENT, url=self.uri(tf))
+        return monitored_files
 
     def remove_test_data(self):
         try:


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