[Zodb-checkins] CVS: ZODB3/ZEO/tests - zeoserver.py:1.21.2.1 testZEO.py:1.75.2.6 testMonitor.py:1.7.2.1 testAuth.py:1.4.2.2 stress.py:1.8.88.1 speed.py:1.9.90.1 multi.py:1.10.88.1 forker.py:1.38.2.1 auth_plaintext.py:1.4.2.1 ConnectionTests.py:1.46.2.4 CommitLockTests.py:1.15.2.5

Jeremy Hylton jeremy at zope.com
Tue Dec 23 14:06:59 EST 2003


Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv26665/ZEO/tests

Modified Files:
      Tag: ZODB3-mvcc-2-branch
	zeoserver.py testZEO.py testMonitor.py testAuth.py stress.py 
	speed.py multi.py forker.py auth_plaintext.py 
	ConnectionTests.py CommitLockTests.py 
Log Message:
Merge the head to the mvcc branch.

This merge should be the final preparation for merging the branch to
the trunk.


=== ZODB3/ZEO/tests/zeoserver.py 1.21 => 1.21.2.1 ===
--- ZODB3/ZEO/tests/zeoserver.py:1.21	Thu Oct  2 14:17:21 2003
+++ ZODB3/ZEO/tests/zeoserver.py	Tue Dec 23 14:05:56 2003
@@ -20,11 +20,11 @@
 import getopt
 import random
 import socket
+import signal
 import asyncore
 import threading
 import ThreadedAsync.LoopCallback
 
-import ZConfig.Context
 import zLOG
 from ZEO.StorageServer import StorageServer
 from ZEO.runzeo import ZEOOptions
@@ -128,14 +128,26 @@
         # chance that the server gives up before the clients.
         time.sleep(330)
         log("zeoserver", "suicide thread invoking shutdown")
-        from ZEO.tests.forker import shutdown_zeo_server
-        # XXX If the -k option was given to zeoserver, then the process will
-        # go away but the temp files won't get cleaned up.
-        shutdown_zeo_server(self._adminaddr)
+
+        # If the server hasn't shut down yet, the client may not be
+        # able to connect to it.  If so, try to kill the process to
+        # force it to shutdown.
+        if hasattr(os, "kill"):
+            os.kill(pid, signal.SIGTERM)
+            time.sleep(5)
+            os.kill(pid, signal.SIGKILL)
+        else:
+            from ZEO.tests.forker import shutdown_zeo_server
+            # XXX If the -k option was given to zeoserver, then the
+            # process will go away but the temp files won't get
+            # cleaned up.
+            shutdown_zeo_server(self._adminaddr)
 
 
 def main():
-    label = 'zeoserver:%d' % os.getpid()
+    global pid
+    pid = os.getpid()
+    label = 'zeoserver:%d' % pid
     log(label, 'starting')
 
     # We don't do much sanity checking of the arguments, since if we get it


=== ZODB3/ZEO/tests/testZEO.py 1.75.2.5 => 1.75.2.6 ===
--- ZODB3/ZEO/tests/testZEO.py:1.75.2.5	Mon Nov 24 13:04:12 2003
+++ ZODB3/ZEO/tests/testZEO.py	Tue Dec 23 14:05:56 2003
@@ -215,10 +215,6 @@
 
 
 def test_suite():
-    # shutup warnings about mktemp
-    import warnings
-    warnings.filterwarnings("ignore", "mktemp")
-
     suite = unittest.TestSuite()
     for klass in test_classes:
         sub = unittest.makeSuite(klass, "check")


=== ZODB3/ZEO/tests/testMonitor.py 1.7 => 1.7.2.1 ===


=== ZODB3/ZEO/tests/testAuth.py 1.4.2.1 => 1.4.2.2 ===
--- ZODB3/ZEO/tests/testAuth.py:1.4.2.1	Tue Nov 11 17:16:26 2003
+++ ZODB3/ZEO/tests/testAuth.py	Tue Dec 23 14:05:56 2003
@@ -21,6 +21,7 @@
 import zLOG
 
 from ThreadedAsync import LoopCallback
+from ZEO import zeopasswd
 from ZEO.ClientStorage import ClientStorage
 from ZEO.Exceptions import ClientDisconnected
 from ZEO.StorageServer import StorageServer
@@ -43,8 +44,19 @@
             self.pwdb = self.dbclass(self.pwfile)
         self.pwdb.add_user("foo", "bar")
         self.pwdb.save()
+        self._checkZEOpasswd()
         self.__super_setUp()
 
+    def _checkZEOpasswd(self):
+        args = ["-f", self.pwfile, "-p", self.protocol]
+        if self.protocol == "plaintext":
+            from ZEO.auth.base import Database
+            zeopasswd.main(args + ["-d", "foo"], Database)
+            zeopasswd.main(args + ["foo", "bar"], Database)
+        else:
+            zeopasswd.main(args + ["-d", "foo"])
+            zeopasswd.main(args + ["foo", "bar"])
+
     def tearDown(self):
         self.__super_tearDown()
         os.remove(self.pwfile)
@@ -100,6 +112,7 @@
         self._storage._connection._SizedMessageAsyncConnection__hmac_send = None
         # Once the client stops using the hmac, it should be disconnected.
         self.assertRaises(ClientDisconnected, self._storage.versions)
+
 
 class PlainTextAuth(AuthTest):
     import ZEO.tests.auth_plaintext


=== ZODB3/ZEO/tests/stress.py 1.8 => 1.8.88.1 ===
--- ZODB3/ZEO/tests/stress.py:1.8	Thu Sep 26 11:24:08 2002
+++ ZODB3/ZEO/tests/stress.py	Tue Dec 23 14:05:56 2003
@@ -18,8 +18,6 @@
 """
 # XXX This code is currently broken.
 
-from __future__ import nested_scopes
-
 import ZODB
 from ZEO.ClientStorage import ClientStorage
 from ZODB.MappingStorage import MappingStorage


=== ZODB3/ZEO/tests/speed.py 1.9 => 1.9.90.1 ===
--- ZODB3/ZEO/tests/speed.py:1.9	Thu Sep  5 15:28:07 2002
+++ ZODB3/ZEO/tests/speed.py	Tue Dec 23 14:05:56 2003
@@ -46,12 +46,12 @@
 ##sys.path.insert(0, os.getcwd())
 
 import ZODB, ZODB.FileStorage
-import Persistence
+import persistent
 import ZEO.ClientStorage, ZEO.StorageServer
 from ZEO.tests import forker
 from ZODB.POSException import ConflictError
 
-class P(Persistence.Persistent):
+class P(persistent.Persistent):
     pass
 
 fs_name = "zeo-speed.fs"


=== ZODB3/ZEO/tests/multi.py 1.10 => 1.10.88.1 ===
--- ZODB3/ZEO/tests/multi.py:1.10	Thu Sep 26 11:23:08 2002
+++ ZODB3/ZEO/tests/multi.py	Tue Dec 23 14:05:56 2003
@@ -15,8 +15,8 @@
 # XXX This code is currently broken.
 
 import ZODB, ZODB.DB, ZODB.FileStorage, ZODB.POSException
-import Persistence
-import PersistentMapping
+import persistent
+import persistent.mapping
 from ZEO.tests import forker
 
 import asyncore
@@ -32,7 +32,7 @@
 CONNECT_DELAY = 0.1
 CLIENT_CACHE = '' # use temporary cache
 
-class Record(Persistence.Persistent):
+class Record(persistent.Persistent):
     def __init__(self, client=None, value=None):
         self.client = client
         self.value = None
@@ -41,7 +41,7 @@
     def set_next(self, next):
         self.next = next
 
-class Stats(Persistence.Persistent):
+class Stats(persistent.Persistent):
     def __init__(self):
         self.begin = time.time()
         self.end = None
@@ -57,7 +57,7 @@
 
     db = ZODB.DB(fs)
     root = db.open().root()
-    root["multi"] = PersistentMapping.PersistentMapping()
+    root["multi"] = persistent.mapping.PersistentMapping()
     get_transaction().commit()
 
     return fs


=== ZODB3/ZEO/tests/forker.py 1.38 => 1.38.2.1 ===
--- ZODB3/ZEO/tests/forker.py:1.38	Thu Oct  2 14:17:21 2003
+++ ZODB3/ZEO/tests/forker.py	Tue Dec 23 14:05:56 2003
@@ -93,8 +93,10 @@
     d['PYTHONPATH'] = os.pathsep.join(sys.path)
     pid = os.spawnve(os.P_NOWAIT, sys.executable, tuple(args), d)
     adminaddr = ('localhost', port + 1)
-    # We need to wait until the server starts, but not forever
-    for i in range(20):
+    # We need to wait until the server starts, but not forever.
+    # 30 seconds is a somewhat arbitrary upper bound.  A BDBStorage
+    # takes a long time to open -- more than 10 seconds on occasion.
+    for i in range(120):
         time.sleep(0.25)
         try:
             zLOG.LOG('forker', zLOG.DEBUG, 'connect %s' % i)
@@ -123,12 +125,23 @@
 
 
 def shutdown_zeo_server(adminaddr):
-    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-    s.connect(adminaddr)
-    try:
-        ack = s.recv(1024)
-    except socket.error, e:
-        if e[0] <> errno.ECONNRESET: raise
-        ack = 'no ack received'
-    zLOG.LOG('shutdownServer', zLOG.DEBUG, 'acked: %s' % ack)
-    s.close()
+    # Do this in a loop to guard against the possibility that the
+    # client failed to connect to the adminaddr earlier.  That really
+    # only requires two iterations, but do a third for pure
+    # superstition.
+    for i in range(3):
+        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        try:
+            s.connect(adminaddr)
+        except socket.error, e:
+            if e[0] == errno.ECONNREFUSED and i > 0:
+                break
+            raise
+        try:
+            ack = s.recv(1024)
+        except socket.error, e:
+            if e[0] == errno.ECONNRESET:
+                raise
+            ack = 'no ack received'
+        zLOG.LOG('shutdownServer', zLOG.DEBUG, 'acked: %s' % ack)
+        s.close()


=== ZODB3/ZEO/tests/auth_plaintext.py 1.4 => 1.4.2.1 ===
--- ZODB3/ZEO/tests/auth_plaintext.py:1.4	Thu Oct  2 18:14:03 2003
+++ ZODB3/ZEO/tests/auth_plaintext.py	Tue Dec 23 14:05:56 2003
@@ -29,6 +29,7 @@
     return sha.new("%s:%s:%s" % (username, realm, password)).hexdigest()
 
 class StorageClass(ZEOStorage):
+    
     def auth(self, username, password):
         try:
             dbpw = self.database.get_password(username)
@@ -41,7 +42,6 @@
                                                       self.database.realm,
                                                       password))
         return self.finish_auth(dbpw == password_dig)
-
 
 class PlaintextClient(Client):
     extensions = ["auth"]


=== ZODB3/ZEO/tests/ConnectionTests.py 1.46.2.3 => 1.46.2.4 ===
--- ZODB3/ZEO/tests/ConnectionTests.py:1.46.2.3	Tue Nov 11 17:16:12 2003
+++ ZODB3/ZEO/tests/ConnectionTests.py	Tue Dec 23 14:05:56 2003
@@ -453,11 +453,8 @@
                          "Error after server restart; retrying.",
                          error=sys.exc_info())
                 get_transaction().abort()
-            # XXX This is a bloody pain.  We're placing a heavy burden
-            # on users to catch a plethora of exceptions in order to
-            # write robust code.  Need to think about implementing
-            # John Heintz's suggestion to make sure all exceptions
-            # inherit from POSException.
+            # Give the other thread a chance to run.
+            time.sleep(0.1)
         zLOG.LOG("checkReconnection", zLOG.INFO, "finished")
         self._storage.close()
 


=== ZODB3/ZEO/tests/CommitLockTests.py 1.15.2.4 => 1.15.2.5 ===
--- ZODB3/ZEO/tests/CommitLockTests.py:1.15.2.4	Mon Dec  1 10:16:09 2003
+++ ZODB3/ZEO/tests/CommitLockTests.py	Tue Dec 23 14:05:56 2003
@@ -17,7 +17,7 @@
 import time
 
 from ZODB.Transaction import Transaction
-from ZODB.TimeStamp import TimeStamp
+from persistent.TimeStamp import TimeStamp
 from ZODB.tests.StorageTestBase import zodb_pickle, MinPO
 
 import ZEO.ClientStorage




More information about the Zodb-checkins mailing list