Commit 5f4af306 authored by Vincent Pelletier's avatar Vincent Pelletier

Also stop clients in NEOCluster.stop.

But make it optional, as some tests might want to stop everything
except clients (stopping single processes is already possible
separately).

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2388 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent cbb7371f
...@@ -157,6 +157,7 @@ class NEOCluster(object): ...@@ -157,6 +157,7 @@ class NEOCluster(object):
cleanup_on_delete=False, temp_dir=None, cleanup_on_delete=False, temp_dir=None,
clear_databases=True, adapter='MySQL', clear_databases=True, adapter='MySQL',
verbose=True): verbose=True):
self.zodb_storage_list = []
self.cleanup_on_delete = cleanup_on_delete self.cleanup_on_delete = cleanup_on_delete
self.verbose = verbose self.verbose = verbose
self.uuid_set = set() self.uuid_set = set()
...@@ -308,7 +309,7 @@ class NEOCluster(object): ...@@ -308,7 +309,7 @@ class NEOCluster(object):
self.expectClusterRunning() self.expectClusterRunning()
neoctl.enableStorageList([x[2] for x in storage_node_list]) neoctl.enableStorageList([x[2] for x in storage_node_list])
def stop(self): def stop(self, clients=True):
for process_list in self.process_dict.itervalues(): for process_list in self.process_dict.itervalues():
for process in process_list: for process in process_list:
try: try:
...@@ -316,6 +317,10 @@ class NEOCluster(object): ...@@ -316,6 +317,10 @@ class NEOCluster(object):
process.wait() process.wait()
except AlreadyStopped: except AlreadyStopped:
pass pass
if clients:
for zodb_storage in self.zodb_storage_list:
zodb_storage.close()
self.zodb_storage_list = []
time.sleep(0.5) time.sleep(0.5)
def getNEOCTL(self): def getNEOCTL(self):
...@@ -323,13 +328,15 @@ class NEOCluster(object): ...@@ -323,13 +328,15 @@ class NEOCluster(object):
def getZODBStorage(self): def getZODBStorage(self):
master_nodes = self.master_nodes.replace('/', ' ') master_nodes = self.master_nodes.replace('/', ' ')
return Storage( result = Storage(
master_nodes=master_nodes, master_nodes=master_nodes,
name=self.cluster_name, name=self.cluster_name,
connector='SocketConnector', connector='SocketConnector',
logfile=os.path.join(self.temp_dir, 'client.log'), logfile=os.path.join(self.temp_dir, 'client.log'),
verbose=self.verbose, verbose=self.verbose,
) )
self.zodb_storage_list.append(result)
return result
def getZODBConnection(self): def getZODBConnection(self):
""" Return a tuple with the database and a connection """ """ Return a tuple with the database and a connection """
......
...@@ -89,7 +89,7 @@ class ClusterTests(NEOFunctionalTest): ...@@ -89,7 +89,7 @@ class ClusterTests(NEOFunctionalTest):
db, conn = self.neo.getZODBConnection() db, conn = self.neo.getZODBConnection()
conn.root()[0] = 'ok' conn.root()[0] = 'ok'
transaction.commit() transaction.commit()
self.neo.stop() self.neo.stop(clients=False)
# XXX: (obj|trans) become t(obj|trans) # XXX: (obj|trans) become t(obj|trans)
self.neo.switchTables('test_neo1') self.neo.switchTables('test_neo1')
self.neo.start() self.neo.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