[Zodb-checkins] CVS: ZODB3/ZEO/tests - testZEO.py:1.32.2.1
Jeremy Hylton
jeremy@zope.com
Thu, 12 Sep 2002 15:20:02 -0400
Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv29228
Modified Files:
Tag: ZODB3-3_1-branch
testZEO.py
Log Message:
Small overhaul of process management for tests.
Get rid of running instance variable on tests. It served no useful purpose.
In tearDown() for connection tests, attempt to close every server that
was started. In shutdownServer() methods, deal gracefully with
multiple calls to shutdownServer().
=== ZODB3/ZEO/tests/testZEO.py 1.32 => 1.32.2.1 ===
--- ZODB3/ZEO/tests/testZEO.py:1.32 Thu Sep 5 15:28:47 2002
+++ ZODB3/ZEO/tests/testZEO.py Thu Sep 12 15:20:01 2002
@@ -99,7 +99,6 @@
def setUp(self):
zLOG.LOG("testZEO", zLOG.INFO, "setUp() %s" % self.id())
- self.running = 1
client, exit, pid = forker.start_zeo(*self.getStorage())
self._pids = [pid]
self._servers = [exit]
@@ -107,7 +106,6 @@
client.registerDB(DummyDB(), None)
def tearDown(self):
- self.running = 0
self._storage.close()
for server in self._servers:
server.close()
@@ -224,7 +222,6 @@
The ZEO server uses the storage object returned by the
getStorage() method.
"""
- self.running = 1
self.file = tempfile.mktemp()
self.addr = []
self._pids = []
@@ -252,7 +249,8 @@
"""Try to cause the tests to halt"""
if getattr(self, '_storage', None) is not None:
self._storage.close()
- self.shutdownServer()
+ for i in range(len(self._servers)):
+ self.shutdownServer(i)
# file storage appears to create four files
for i in range(len(self.addr)):
for ext in '', '.index', '.lock', '.tmp':
@@ -365,7 +363,6 @@
zLOG.LOG("checkReconnection", zLOG.INFO,
"About to shutdown server")
self.shutdownServer()
- self.running = 1
zLOG.LOG("checkReconnection", zLOG.INFO,
"About to restart server")
self._startServer(create=0)
@@ -400,13 +397,13 @@
self._servers.append(server)
def shutdownServer(self, index=0):
- if self.running:
- self.running = 0
- self._servers[index].close()
+ self._servers[index].close()
+ if self._pids[index] is not None:
try:
os.waitpid(self._pids[index], 0)
- except os.error:
- pass
+ self._pids[index] = None
+ except os.error, err:
+ print err
class WindowsConnectionTests(ConnectionTests):
@@ -419,11 +416,11 @@
self._servers.append(test_addr)
def shutdownServer(self, index=0):
- if self.running:
- self.running = 0
+ if self._servers[index] is not None:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(self._servers[index])
s.close()
+ self._servers[index] = None
# XXX waitpid() isn't available until Python 2.3
time.sleep(0.5)