[Zodb-checkins] CVS: ZEO/ZEO/tests - forker.py:1.10.4.6 testZEO.py:1.16.4.10
Jeremy Hylton
jeremy@zope.com
Mon, 28 Jan 2002 17:00:34 -0500
Update of /cvs-repository/ZEO/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv3219
Modified Files:
Tag: Standby-branch
forker.py testZEO.py
Log Message:
Change the Unix version of forker to be more like Windows.
XXX I should really unify Unix and Windows code here, but I can't be
bothered. I'm just fixing this to get at a different bug.
Don't create a storage and pass it across the fork. There seem to be
too many hard-to-explain problems linked to the fds that are open in
parent when child is forked.
=== ZEO/ZEO/tests/forker.py 1.10.4.5 => 1.10.4.6 ===
pass
- def start_zeo_server(storage, addr):
+ def start_zeo_server(addr, storage_name, args):
+ assert isinstance(args, types.TupleType)
rd, wr = os.pipe()
pid = os.fork()
if pid == 0:
@@ -110,7 +111,7 @@
globals(), locals())
p.close()
else:
- run_server(storage, addr, rd, wr)
+ run_server(addr, rd, wr, storage_name, args)
except:
print "Exception in ZEO server process"
traceback.print_exc()
@@ -119,20 +120,27 @@
os.close(rd)
return pid, ZEOClientExit(wr)
- def run_server(storage, addr, rd, wr):
+ def load_storage(name, args):
+ package = __import__("ZODB." + name)
+ mod = getattr(package, name)
+ klass = getattr(mod, name)
+ return klass(*args)
+
+ def run_server(addr, rd, wr, storage_name, args):
# in the child, run the storage server
global server
os.close(wr)
ZEOServerExit(rd)
import ZEO.StorageServer, ZEO.zrpc.server
+ storage = load_storage(storage_name, args)
server = ZEO.StorageServer.StorageServer(addr, {'1':storage})
ZEO.zrpc.server.loop()
storage.close()
if isinstance(addr, types.StringType):
os.unlink(addr)
- def start_zeo(storage, cache=None, cleanup=None, domain="AF_INET",
- storage_id="1", cache_size=20000000):
+ def start_zeo(storage_name, args, cache=None, cleanup=None,
+ domain="AF_INET", storage_id="1", cache_size=20000000):
"""Setup ZEO client-server for storage.
Returns a ClientStorage instance and a ZEOClientExit instance.
@@ -148,7 +156,7 @@
else:
raise ValueError, "bad domain: %s" % domain
- pid, exit = start_zeo_server(storage, addr)
+ pid, exit = start_zeo_server(addr, storage_name, args)
s = ZEO.ClientStorage.ClientStorage(addr, storage_id,
debug=1, client=cache,
cache_size=cache_size,
=== ZEO/ZEO/tests/testZEO.py 1.16.4.9 => 1.16.4.10 ===
class GenericTests(StorageTestBase.StorageTestBase,
TransactionalUndoStorage.TransactionalUndoStorage,
- TransactionalUndoVersionStorage.TransactionalUndoVersionStorage,
+ TransactionalUndoVersionStorage.TransactionalUndoVersionStorage,
ConflictResolution.ConflictResolvingStorage,
ConflictResolution.ConflictResolvingTransUndoStorage,
Cache.StorageWithCache,
@@ -79,7 +79,7 @@
def setUp(self):
zLOG.LOG("testZEO", zLOG.INFO, "setUp() %s" % self.id())
self.running = 1
- client, exit, pid = forker.start_zeo(self.getStorage())
+ client, exit, pid = forker.start_zeo(*self.getStorage())
self._pids = [pid]
self._servers = [exit]
self._storage = PackWaitWrapper(client)
@@ -116,7 +116,8 @@
wait_for_server_on_startup=1)
def getStorage(self):
- return FileStorage(self.__fs_base, create=1)
+ self.__fs_base = tempfile.mktemp()
+ return 'FileStorage', (self.__fs_base, '1')
def delStorage(self):
# file storage appears to create four files
@@ -159,7 +160,7 @@
def getStorageInfo(self):
self.__fs_base = tempfile.mktemp()
- return 'FileStorage', self.__fs_base, '1'
+ return 'FileStorage', (self.__fs_base, '1') # create=1
def delStorage(self):
# file storage appears to create four files
@@ -342,8 +343,10 @@
def _startServer(self, create=1, index=0):
fs = FileStorage("%s.%d" % (self.file, index), create=create)
+ path = "%s.%d" % (self.file, index)
addr = self.addr[index]
- pid, server = forker.start_zeo_server(fs, addr)
+ pid, server = forker.start_zeo_server(addr, 'FileStorage',
+ (path, create))
self._pids.append(pid)
self._servers.append(server)
@@ -379,10 +382,10 @@
port = self.addr[1]
else:
port = None
- self.addr, self.test_a, pid = forker.start_zeo_server('FileStorage',
+ self.addr, self.test_a, pid = forker.start_zeo_server(port,
+ 'FileStorage',
(self.file,
- str(create)),
- port)
+ str(create)))
self.running = 1
def openClientStorage(self, cache='', cache_size=200000, wait=1):