[tracker] functional-tests: Use GraphUpdated signal from store, not miner-fs Idle status
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] functional-tests: Use GraphUpdated signal from store, not miner-fs Idle status
- Date: Mon, 24 Feb 2014 16:32:25 +0000 (UTC)
commit 853eb94d78aa269b3b1024c138387ead0c601080
Author: Martin Kampas <martin kampas+gnomebugs ubedi net>
Date: Mon Feb 24 16:21:17 2014 +0000
functional-tests: Use GraphUpdated signal from store, not miner-fs Idle status
The tracker_miner_fs_wait_for_idle() call is used to detect miner operation
has completed. It returns when miner's status changes to "Idle" (or on
timeout). Unfortunately at the time miner goes idle it is not guaranteed the
data are already in store - and the related test fails.
A better way is to listen to GraphUpdated signal sent by store and wait until
the desired resource is announced beng added or removed.
Depends on tracker-tests-allow-reuse-graph-updated-signal-handling.patch.
tests/functional-tests/310-fts-indexing.py | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/tests/functional-tests/310-fts-indexing.py b/tests/functional-tests/310-fts-indexing.py
index 0093d4c..99db45d 100755
--- a/tests/functional-tests/310-fts-indexing.py
+++ b/tests/functional-tests/310-fts-indexing.py
@@ -29,6 +29,7 @@ the text contents are updated accordingly in the indexes.
import os
import shutil
import locale
+import time
import unittest2 as ut
from common.utils.helpers import log
@@ -40,9 +41,13 @@ class CommonMinerFTS (CommonTrackerMinerTest):
Superclass to share methods. Shouldn't be run by itself.
"""
def setUp (self):
+ self.tracker.reset_graph_updates_tracking ()
self.testfile = "test-monitored/miner-fts-test.txt"
if os.path.exists (path (self.testfile)):
+ id = self._query_id (uri (self.testfile))
os.remove (path (self.testfile))
+ self.tracker.await_resource_deleted (id)
+ self.tracker.reset_graph_updates_tracking ()
# Shouldn't we wait here for the miner to idle? (it works without it)
def tearDown (self):
@@ -54,7 +59,9 @@ class CommonMinerFTS (CommonTrackerMinerTest):
f = open (path (self.testfile), "w")
f.write (text)
f.close ()
- self.system.tracker_miner_fs_wait_for_idle ()
+ self.tracker.await_resource_inserted (rdf_class = 'nfo:Document',
+ url = uri (self.testfile))
+ self.tracker.reset_graph_updates_tracking ()
def search_word (self, word):
"""
@@ -83,6 +90,11 @@ class CommonMinerFTS (CommonTrackerMinerTest):
self.assertEquals (len (results), 1)
self.assertIn ( uri (self.testfile), results)
+ def _query_id (self, uri):
+ query = "SELECT tracker:id(?urn) WHERE { ?urn nie:url \"%s\". }" % uri
+ result = self.tracker.query (query)
+ assert len (result) == 1
+ return int (result[0][0])
class MinerFTSBasicTest (CommonMinerFTS):
@@ -176,8 +188,9 @@ class MinerFTSFileOperationsTest (CommonMinerFTS):
TEXT = "automobile is red and big and whatnot"
self.basic_test (TEXT, "automobile")
+ id = self._query_id (uri (self.testfile))
os.remove ( path (self.testfile))
- self.system.tracker_miner_fs_wait_for_idle ()
+ self.tracker.await_resource_deleted (id)
results = self.search_word ("automobile")
self.assertEquals (len (results), 0)
@@ -201,6 +214,7 @@ class MinerFTSFileOperationsTest (CommonMinerFTS):
self.basic_test (TEXT, "automobile")
self.set_text ("airplane is blue and small and wonderful")
+
results = self.search_word ("automobile")
self.assertEquals (len (results), 0)
@@ -245,12 +259,15 @@ class MinerFTSFileOperationsTest (CommonMinerFTS):
TEST_16_DEST = "test-monitored/fts-indexing-text-16.txt"
self.__recreate_file (path (TEST_16_SOURCE), TEXT)
+ # the file is supposed to be ignored by tracker, so there is no notification..
+ time.sleep (5)
results = self.search_word ("airplane")
self.assertEquals (len (results), 0)
shutil.copyfile ( path (TEST_16_SOURCE), path (TEST_16_DEST))
- self.system.tracker_miner_fs_wait_for_idle ()
+ self.tracker.await_resource_inserted (rdf_class = 'nfo:Document',
+ url = uri (TEST_16_DEST))
results = self.search_word ("airplane")
self.assertEquals (len (results), 1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]