[tracker-miners/wip/carlosg/test-error-fixes] tests: Await for all resources being deleted



commit 74ea644b9badf1f8611ad4dc34c941997eb6840a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jul 14 18:21:28 2021 +0200

    tests: Await for all resources being deleted
    
    In miner-basic's 09_deletion_directory test, we have a directory
    containing 2 text files, and test that removing the directory ends
    up with these 2 files removed.
    
    However the test infrastructure only allows awaiting for one
    resource at a time, so we pick one of those text files to monitor
    for removal while removing the directory, and call the whole operation
    done when that did happen.
    
    However the ordering and timing of events is racy here, we could
    receive the expected event and proceed while the other file was not
    deleted yet from the database. When that happens, this is seen as:
    
      AssertionError: 2 != 1
    
    In that testcase, since we are expecting to see one text document
    from a different folder, but we additionally see the not-yet-deleted
    file. To fix this, ensure (in a more lenient way) that the other
    text file is also deleted in a reasonable time.
    
    Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/185

 tests/functional-tests/miner-basic.py | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/tests/functional-tests/miner-basic.py b/tests/functional-tests/miner-basic.py
index e259fb9cf..0713dab6a 100755
--- a/tests/functional-tests/miner-basic.py
+++ b/tests/functional-tests/miner-basic.py
@@ -332,6 +332,14 @@ class MinerCrawlTest(fixtures.TrackerMinerTest):
         with self.tracker.await_delete(fixtures.DOCUMENTS_GRAPH, file_inside_victim_id, 
timeout=cfg.AWAIT_TIMEOUT):
             shutil.rmtree(victim)
 
+        # We have 2 text files inside the directory, but only look for one, assert that
+        # the other file is gone as well.
+        file_inside_victim_url2 = self.uri(os.path.join(victim, "dir2/file3.txt"))
+        counter = 0
+        while counter < 10 and self.tracker.ask("ASK { <%s> a nfo:Document }" % (file_inside_victim_url2)):
+            counter += 1
+            time.sleep(1)
+
         result = self.__get_text_documents()
         self.assertEqual(result, [[self.uri("test-monitored/file1.txt")]])
 


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