[Zodb-checkins] CVS: Packages/ZEO - forker.py:1.1.2.3 multi.py:1.1.2.5 testZEO.py:1.1.2.11

jeremy@digicool.com jeremy@digicool.com
Mon, 7 May 2001 09:12:55 -0400 (EDT)


Update of /cvs-repository/Packages/ZEO/tests
In directory korak:/tmp/cvs-serv21011

Modified Files:
      Tag: ZEO-ZRPC-Dev
	forker.py multi.py testZEO.py 
Log Message:
Add profile support.
Add ZEO unit test for large commits.



--- Updated File forker.py in package Packages/ZEO --
--- forker.py	2001/05/01 18:43:53	1.1.2.2
+++ forker.py	2001/05/07 13:12:54	1.1.2.3
@@ -1,11 +1,17 @@
 """Library for forking storage server and connecting client storage"""
 
 import asyncore
+import atexit
 import os
+import profile
 import sys
+import time
+import types
 import ThreadedAsync
 import ZEO.ClientStorage, ZEO.StorageServer
 
+PROFILE = 0
+
 class ZEOServerExit(asyncore.file_dispatcher):
     """Used to exit ZEO.StorageServer when run is done"""
 
@@ -36,23 +42,28 @@
     rd, wr = os.pipe()
     pid = os.fork()
     if pid == 0:
-        # in the child, run the storage server
-        try:
-            os.close(wr)
-            ZEOServerExit(rd)
-            serv = ZEO.StorageServer.StorageServer(addr, {'1':storage})
-            asyncore.loop()
-            storage.close()
-            if domain == "AF_UNIX":
-                os.unlink(addr)
-            if cleanup:
-                cleanup()
-        finally:
-            os._exit(0)
+        if PROFILE:
+            p = profile.Profile()
+            p.runctx("run_server(storage, addr, rd, wr)", globals(),
+                     locals())
+            p.dump_stats("stats.s.%d" % os.getpid())
+        else:
+            run_server(storage, addr, rd, wr)
+        os._exit(0)
     else:
         os.close(rd)
         return pid, ZEOClientExit(wr)
 
+def run_server(storage, addr, rd, wr):
+    # in the child, run the storage server
+    os.close(wr)
+    ZEOServerExit(rd)
+    serv = ZEO.StorageServer.StorageServer(addr, {'1':storage})
+    asyncore.loop()
+    storage.close()
+    if isinstance(addr, types.StringType):
+        os.unlink(addr)
+
 def start_zeo(storage, cache=None, cleanup=None, domain="AF_INET"):
     """Setup ZEO client-server for storage.
 
@@ -72,5 +83,8 @@
 
     pid, exit = start_zeo_server(storage, addr)
     s = ZEO.ClientStorage.ClientStorage(addr, debug=1, client=cache)
+    if hasattr(s, 'is_connected'):
+        while not s.is_connected():
+            time.sleep(0.1)
     return s, exit, pid
 

--- Updated File multi.py in package Packages/ZEO --
--- multi.py	2001/05/01 22:43:12	1.1.2.4
+++ multi.py	2001/05/07 13:12:54	1.1.2.5
@@ -11,6 +11,8 @@
 import time
 import types
 
+PROFILE = 0
+
 VERBOSE = 1
 CLIENTS = 4
 RECORDS_PER_CLIENT = 100
@@ -53,14 +55,17 @@
     pid, exit = forker.start_zeo_server(storage, addr)
     return pid, exit
 
-def start_client(addr):
+def start_client(addr, client_func=None):
     pid = os.fork()
     if pid == 0:
         import ZEO.ClientStorage
         if VERBOSE:
             print "Client process started:", os.getpid()
         cli = ZEO.ClientStorage.ClientStorage(addr, client=CLIENT_CACHE)
-        run(cli)
+        if client_func is None:
+            run(cli)
+        else:
+            client_func(cli)
         cli.close()
         os._exit(0)
     else:
@@ -106,14 +111,14 @@
 
     print "Client completed:", pid
 
-def main():
+def main(client_func=None):
     if VERBOSE:
         print "Main process:", os.getpid()
     addr = tempfile.mktemp()
     t0 = time.time()
     server_pid, server = start_server(addr)
     t1 = time.time()
-    pids = [start_client(addr) for i in range(CLIENTS)]
+    pids = [start_client(addr, client_func) for i in range(CLIENTS)]
     for pid in pids:
         assert type(pid) == types.IntType, "invalid pid type: %s (%s)" % \
                (repr(pid), type(pid))

--- Updated File testZEO.py in package Packages/ZEO --
--- testZEO.py	2001/05/02 21:54:41	1.1.2.10
+++ testZEO.py	2001/05/07 13:12:54	1.1.2.11
@@ -77,6 +77,10 @@
             for oid, serial in r:
                 d[oid] = serial
         return d
+
+    def checkLargeUpdate(self):
+        obj = MinPO("X" * (10 * 128 * 1024))
+        self._dostore(data=obj)
         
 class GenericTests(ZEOTestBase,
                    Cache.StorageWithCache,