diff --git a/neo/tests/functional/__init__.py b/neo/tests/functional/__init__.py index eed732eb8529ae7ce3c4f69cb5182e7f02194940..f44fa572602faffdfe1ca1cc232c03989f4b82d3 100644 --- a/neo/tests/functional/__init__.py +++ b/neo/tests/functional/__init__.py @@ -20,6 +20,7 @@ from neo import protocol import os import sys import time +import ZODB import signal import random import MySQLdb @@ -286,6 +287,12 @@ class NEOCluster(object): name=self.cluster_name, connector='SocketConnector') + def getConnection(self): + """ Return a tuple with the database and a connection """ + storage = self.getStorage() + db = ZODB.DB(storage=self.getStorage()) + return (db, db.open()) + def _getProcessList(self, type): return self.process_dict.get(type) diff --git a/neo/tests/functional/testStorage.py b/neo/tests/functional/testStorage.py index 98b638d4286fbb53c386d3fc2917fe37d4d13e7a..df4894d5e264e57dd18bcdadedb800a7e971fdb3 100644 --- a/neo/tests/functional/testStorage.py +++ b/neo/tests/functional/testStorage.py @@ -46,21 +46,14 @@ class StorageTests(unittest.TestCase): result = db.store_result().fetch_row()[0][0] return result - def populate(self, storage): - db = ZODB.DB(storage=storage) - conn = db.open() + def populate(self, neo): + db, conn = neo.getConnection() root = conn.root() for i in xrange(OBJECT_NUMBER): root[i] = PObject(i) transaction.commit() conn.close() - storage.close() - - def getNeoStorage(self, neo): - return NEOStorage(master_nodes=neo.master_nodes, - connector='SocketConnector', - name=neo.cluster_name, - ) + db.close() def checkDatabase(self, neo, db_name): db = MySQLdb.connect(db=db_name, user='test') @@ -102,7 +95,7 @@ class StorageTests(unittest.TestCase): neo.start() # populate the cluster and check - self.populate(self.getNeoStorage(neo)) + self.populate(neo) self.__checkReplicationDone(neo, databases) def testReplicationWithNewStorage(self): @@ -118,7 +111,7 @@ class StorageTests(unittest.TestCase): # populate one storage new_storage = neo.getStorageProcessList()[-1] neo.start(except_storages=[new_storage]) - self.populate(self.getNeoStorage(neo)) + self.populate(neo) # start the second new_storage.start()