[tracker] functional-tests: Kill/stop the store in a realistic way for backup/restore
- From: Ivan Frade <ifrade src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] functional-tests: Kill/stop the store in a realistic way for backup/restore
- Date: Thu, 10 Feb 2011 12:24:02 +0000 (UTC)
commit 6c7c48428f317fa189e304cd8466dcfb930af1a4
Author: Ivan Frade <ivan frade nokia com>
Date: Thu Feb 10 14:21:21 2011 +0200
functional-tests: Kill/stop the store in a realistic way for backup/restore
Kill or stop the store in the right moment, before corrupting or removing the DBs.
This should make the test more predictable (before there were race conditions)
tests/functional-tests/12-transactions.py | 3 ++-
tests/functional-tests/200-backup-restore.py | 24 ++++++++++++++----------
tests/functional-tests/common/utils/system.py | 10 ++++++----
3 files changed, 22 insertions(+), 15 deletions(-)
---
diff --git a/tests/functional-tests/12-transactions.py b/tests/functional-tests/12-transactions.py
index ea02335..7cfbb87 100755
--- a/tests/functional-tests/12-transactions.py
+++ b/tests/functional-tests/12-transactions.py
@@ -73,7 +73,8 @@ class TrackerTransactionsTest (CommonTrackerStoreTest):
NUMBER_OF_INSTANCES = 1000
self.insert_and_commit (NUMBER_OF_INSTANCES)
- self.system.tracker_store_brutal_restart ()
+ self.system.tracker_store_stop_brutally ()
+ self.system.tracker_store_start ()
# Reconnect dbus
self.tracker.connect ()
try:
diff --git a/tests/functional-tests/200-backup-restore.py b/tests/functional-tests/200-backup-restore.py
index 96ec099..47060f7 100755
--- a/tests/functional-tests/200-backup-restore.py
+++ b/tests/functional-tests/200-backup-restore.py
@@ -178,9 +178,10 @@ class BackupRestoreTest (CommonTrackerStoreTest):
instances_before = self.tracker.count_instances ("nco:Contact")
self.tracker.backup (self.BACKUP_FILE)
+ self.system.tracker_store_stop_nicely ()
self.system.tracker_store_remove_dbs ()
self.system.tracker_store_remove_journal ()
- self.system.tracker_store_brutal_restart ()
+ self.system.tracker_store_start ()
instances_before_restore = self.tracker.count_instances ("nco:Contact")
self.assertNotEqual (instances_before_restore, instances_before)
@@ -204,9 +205,10 @@ class BackupRestoreTest (CommonTrackerStoreTest):
instances_before = self.tracker.count_instances ("nco:Contact")
self.tracker.backup (self.BACKUP_FILE)
+ self.system.tracker_store_stop_brutally ()
self.system.tracker_store_corrupt_dbs ()
self.system.tracker_store_remove_journal ()
- self.system.tracker_store_brutal_restart ()
+ self.system.tracker_store_start ()
instances_before_restore = self.tracker.count_instances ("nco:Contact")
self.assertNotEqual (instances_before_restore, instances_before)
@@ -257,8 +259,9 @@ class JournalReplayTest (CommonTrackerStoreTest):
Insert few data (to have more than the pre-defined instances)
Check instances of different classes
+ Kill the store (SIGKILL)
Replace the DB with a random file
- Restart the daemon
+ Start the store
Check instances of different classes
"""
self.tracker.update ("INSERT { <test://journal-replay/01> a nco:Contact. }")
@@ -267,10 +270,11 @@ class JournalReplayTest (CommonTrackerStoreTest):
ie = self.tracker.count_instances ("nie:InformationElement")
contacts = self.tracker.count_instances ("nco:Contact")
+ self.system.tracker_store_stop_brutally ()
self.system.tracker_store_corrupt_dbs ()
- self.system.tracker_store_brutal_restart ()
+ self.system.tracker_store_start ()
## Start it twice... the first time it detects the broken DB and aborts
- self.system.tracker_store_brutal_restart ()
+ #self.system.tracker_store_start ()
self.tracker.connect ()
@@ -290,8 +294,9 @@ class JournalReplayTest (CommonTrackerStoreTest):
Insert few data (to have more than the pre-defined instances)
Check instances of different classes
- Remove the DB
- Restart the daemon
+ KILL the store
+ Force a journal replay (DB missing, .meta.isrunning exists, journal OK)
+ Start the store
Check instances of different classes
"""
self.tracker.update ("INSERT { <test://journal-replay/02> a nco:Contact. }")
@@ -300,10 +305,9 @@ class JournalReplayTest (CommonTrackerStoreTest):
ie = self.tracker.count_instances ("nie:InformationElement")
contacts = self.tracker.count_instances ("nco:Contact")
-
+ self.system.tracker_store_stop_brutally ()
self.system.tracker_store_prepare_journal_replay ()
-
- self.system.tracker_store_brutal_restart ()
+ self.system.tracker_store_start ()
self.tracker.connect ()
diff --git a/tests/functional-tests/common/utils/system.py b/tests/functional-tests/common/utils/system.py
index 0e786b5..4230957 100644
--- a/tests/functional-tests/common/utils/system.py
+++ b/tests/functional-tests/common/utils/system.py
@@ -350,6 +350,12 @@ class TrackerSystemAbstraction:
def tracker_store_start (self):
self.store.start ()
+ def tracker_store_stop_nicely (self):
+ self.store.stop ()
+
+ def tracker_store_stop_brutally (self):
+ self.store.kill ()
+
def tracker_store_restart_with_new_ontologies (self, ontodir):
self.store.stop ()
if ontodir:
@@ -360,10 +366,6 @@ class TrackerSystemAbstraction:
except dbus.DBusException, e:
raise UnableToBootException ("Unable to boot the store \n(" + str(e) + ")")
- def tracker_store_brutal_restart (self):
- self.store.kill ()
- self.store.start ()
-
def tracker_store_prepare_journal_replay (self):
db_location = os.path.join (TEST_ENV_VARS ['XDG_CACHE_HOME'], "tracker", "meta.db")
os.unlink (db_location)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]