Commit 6c672fea authored by Grégory Wisniewski's avatar Grégory Wisniewski

Storage functional tests use getStorage() defined on NeoCluster. Add

getConnection().


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1204 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent c2f6e4af
......@@ -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)
......
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment