summaryrefslogtreecommitdiff
path: root/tests/functional-tests/12-transactions.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional-tests/12-transactions.py')
-rwxr-xr-xtests/functional-tests/12-transactions.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/tests/functional-tests/12-transactions.py b/tests/functional-tests/12-transactions.py
index a3c19f41d..ab62c2d24 100755
--- a/tests/functional-tests/12-transactions.py
+++ b/tests/functional-tests/12-transactions.py
@@ -30,7 +30,9 @@ from common.utils.storetest import CommonTrackerStoreTest as CommonTrackerStoreT
TEST_INSTANCE_PATTERN = "test://12-transactions-%d"
+
class TrackerTransactionsTest (CommonTrackerStoreTest):
+
"""
In a loop:
1. Inserts a Batch of instances
@@ -41,49 +43,49 @@ class TrackerTransactionsTest (CommonTrackerStoreTest):
If the commit was real, all the inserted instances should be there.
"""
- def setUp (self):
+ def setUp(self):
self.instance_counter = 0
- def tearDown (self):
+ def tearDown(self):
print "Tear down (will take some time to remove all resources)"
delete_sparql = "DELETE { ?u a rdfs:Resource } WHERE { ?u a nmo:Email} \n"
- self.tracker.update (delete_sparql,
- timeout=60000)
+ self.tracker.update(delete_sparql,
+ timeout=60000)
self.instance_counter = 0
- def insert_and_commit (self, number):
+ def insert_and_commit(self, number):
insert_sparql = "INSERT {\n"
- for i in range (0, number):
- insert_sparql += " <" + TEST_INSTANCE_PATTERN % (self.instance_counter) + ">"
+ for i in range(0, number):
+ insert_sparql += " <" + \
+ TEST_INSTANCE_PATTERN % (self.instance_counter) + ">"
insert_sparql += " a nmo:Email.\n "
self.instance_counter += 1
insert_sparql += "}"
- self.tracker.batch_update (insert_sparql)
- #print "Waiting for commit (", number," instances)"
+ self.tracker.batch_update(insert_sparql)
+ # print "Waiting for commit (", number," instances)"
#start = time.time ()
- self.tracker.batch_commit ()
+ self.tracker.batch_commit()
#end = time.time ()
- #print "BatchCommit returned (after %d s.)" % (end - start)
-
+ # print "BatchCommit returned (after %d s.)" % (end - start)
- def test_commit_and_abort (self):
+ def test_commit_and_abort(self):
- for i in range (0, 20):
+ for i in range(0, 20):
NUMBER_OF_INSTANCES = 1000
- self.insert_and_commit (NUMBER_OF_INSTANCES)
+ self.insert_and_commit(NUMBER_OF_INSTANCES)
- self.system.tracker_store_stop_brutally ()
- self.system.tracker_store_start ()
+ self.system.tracker_store_stop_brutally()
+ self.system.tracker_store_start()
try:
- results = self.tracker.count_instances ("nmo:Email")
+ results = self.tracker.count_instances("nmo:Email")
except:
print "Timeout, probably replaying journal or something (wait 20 sec.)"
- time.sleep (20)
- results = self.tracker.count_instances ()
+ time.sleep(20)
+ results = self.tracker.count_instances()
# Every iteration we are adding new instances in the store!
- self.assertEquals (results, NUMBER_OF_INSTANCES * (i+1))
+ self.assertEquals(results, NUMBER_OF_INSTANCES * (i + 1))
if __name__ == "__main__":
- ut.main ()
+ ut.main()