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 ...@@ -20,6 +20,7 @@ from neo import protocol
import os import os
import sys import sys
import time import time
import ZODB
import signal import signal
import random import random
import MySQLdb import MySQLdb
...@@ -286,6 +287,12 @@ class NEOCluster(object): ...@@ -286,6 +287,12 @@ class NEOCluster(object):
name=self.cluster_name, name=self.cluster_name,
connector='SocketConnector') 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): def _getProcessList(self, type):
return self.process_dict.get(type) return self.process_dict.get(type)
......
...@@ -46,21 +46,14 @@ class StorageTests(unittest.TestCase): ...@@ -46,21 +46,14 @@ class StorageTests(unittest.TestCase):
result = db.store_result().fetch_row()[0][0] result = db.store_result().fetch_row()[0][0]
return result return result
def populate(self, storage): def populate(self, neo):
db = ZODB.DB(storage=storage) db, conn = neo.getConnection()
conn = db.open()
root = conn.root() root = conn.root()
for i in xrange(OBJECT_NUMBER): for i in xrange(OBJECT_NUMBER):
root[i] = PObject(i) root[i] = PObject(i)
transaction.commit() transaction.commit()
conn.close() conn.close()
storage.close() db.close()
def getNeoStorage(self, neo):
return NEOStorage(master_nodes=neo.master_nodes,
connector='SocketConnector',
name=neo.cluster_name,
)
def checkDatabase(self, neo, db_name): def checkDatabase(self, neo, db_name):
db = MySQLdb.connect(db=db_name, user='test') db = MySQLdb.connect(db=db_name, user='test')
...@@ -102,7 +95,7 @@ class StorageTests(unittest.TestCase): ...@@ -102,7 +95,7 @@ class StorageTests(unittest.TestCase):
neo.start() neo.start()
# populate the cluster and check # populate the cluster and check
self.populate(self.getNeoStorage(neo)) self.populate(neo)
self.__checkReplicationDone(neo, databases) self.__checkReplicationDone(neo, databases)
def testReplicationWithNewStorage(self): def testReplicationWithNewStorage(self):
...@@ -118,7 +111,7 @@ class StorageTests(unittest.TestCase): ...@@ -118,7 +111,7 @@ class StorageTests(unittest.TestCase):
# populate one storage # populate one storage
new_storage = neo.getStorageProcessList()[-1] new_storage = neo.getStorageProcessList()[-1]
neo.start(except_storages=[new_storage]) neo.start(except_storages=[new_storage])
self.populate(self.getNeoStorage(neo)) self.populate(neo)
# start the second # start the second
new_storage.start() 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