[Zope-Checkins] CVS: ZODB3/ZEO/tests - zeoserver.py:1.21
testZEO.py:1.75 testMonitor.py:1.7 testClientCache.py:1.11
testAuth.py:1.4 forker.py:1.38 auth_plaintext.py:1.3
InvalidationTests.py:1.6 ConnectionTests.py:1.44
CommitLockTests.py:1.15
Jeremy Hylton
jeremy at zope.com
Thu Oct 2 14:17:52 EDT 2003
Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv18770/ZEO/tests
Modified Files:
zeoserver.py testZEO.py testMonitor.py testClientCache.py
testAuth.py forker.py auth_plaintext.py InvalidationTests.py
ConnectionTests.py CommitLockTests.py
Log Message:
Merge changes from Zope-2_7-branch to the trunk.
=== ZODB3/ZEO/tests/zeoserver.py 1.20 => 1.21 ===
--- ZODB3/ZEO/tests/zeoserver.py:1.20 Mon Sep 15 12:29:18 2003
+++ ZODB3/ZEO/tests/zeoserver.py Thu Oct 2 14:17:21 2003
@@ -122,8 +122,11 @@
self._adminaddr = addr
def run(self):
- # If this process doesn't exit in 300 seconds, commit suicide
- time.sleep(300)
+ # If this process doesn't exit in 330 seconds, commit suicide.
+ # The client threads in the ConcurrentUpdate tests will run for
+ # as long as 300 seconds. Set this timeout to 330 to minimize
+ # 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
@@ -134,7 +137,7 @@
def main():
label = 'zeoserver:%d' % os.getpid()
log(label, 'starting')
-
+
# We don't do much sanity checking of the arguments, since if we get it
# wrong, it's a bug in the test suite.
keep = 0
@@ -150,11 +153,11 @@
zo = ZEOOptions()
zo.realize(["-C", configfile])
zeo_port = int(zo.address[1])
-
+
# XXX a hack
if zo.auth_protocol == "plaintext":
import ZEO.tests.auth_plaintext
-
+
# Open the config file and let ZConfig parse the data there. Then remove
# the config file, otherwise we'll leave turds.
# The rest of the args are hostname, portnum
@@ -186,7 +189,7 @@
storage.close()
cleanup(storage)
sys.exit(2)
-
+
t.register_socket(server.dispatcher)
# Create daemon suicide thread
d = Suicide(test_addr)
=== ZODB3/ZEO/tests/testZEO.py 1.74 => 1.75 ===
--- ZODB3/ZEO/tests/testZEO.py:1.74 Mon Sep 15 12:29:18 2003
+++ ZODB3/ZEO/tests/testZEO.py Thu Oct 2 14:17:21 2003
@@ -132,7 +132,8 @@
self._servers = [adminaddr]
self._conf_path = path
self._storage = ClientStorage(zport, '1', cache_size=20000000,
- min_disconnect_poll=0.5, wait=1)
+ min_disconnect_poll=0.5, wait=1,
+ wait_timeout=60)
self._storage.registerDB(DummyDB(), None)
def tearDown(self):
=== ZODB3/ZEO/tests/testMonitor.py 1.6 => 1.7 ===
--- ZODB3/ZEO/tests/testMonitor.py:1.6 Fri May 30 15:20:56 2003
+++ ZODB3/ZEO/tests/testMonitor.py Thu Oct 2 14:17:21 2003
@@ -70,7 +70,7 @@
s.parse("\n".join(sect[1:]))
return d
-
+
def getConfig(self, path, create, read_only):
return """<mappingstorage 1/>"""
=== ZODB3/ZEO/tests/testClientCache.py 1.10 => 1.11 ===
--- ZODB3/ZEO/tests/testClientCache.py:1.10 Mon Sep 15 12:29:18 2003
+++ ZODB3/ZEO/tests/testClientCache.py Thu Oct 2 14:17:21 2003
@@ -396,7 +396,7 @@
version = "folio"
vdata = "Mend your speech a little, lest you may mar your fortunes."
vserial = "12346789"
-
+
self.cache.store(self._oid, nvdata, nvserial, version, vdata, vserial)
self.cache.checkSize(10 * self.cachesize) # force a cache flip
@@ -421,7 +421,7 @@
data, serial = self.cache.load(self._oid, xversion)
self.assertEqual(data, xdata)
self.assertEqual(serial, xserial)
-
+
class ClientCacheLongOIDTests(ClientCacheTests):
_oid = 'abcdefghijklmnop' * 2
_oid2 = 'bcdefghijklmnopq' * 2
=== ZODB3/ZEO/tests/testAuth.py 1.3 => 1.4 ===
--- ZODB3/ZEO/tests/testAuth.py:1.3 Fri May 30 15:20:56 2003
+++ ZODB3/ZEO/tests/testAuth.py Thu Oct 2 14:17:21 2003
@@ -18,8 +18,11 @@
import time
import unittest
+import zLOG
+
from ThreadedAsync import LoopCallback
from ZEO.ClientStorage import ClientStorage
+from ZEO.Exceptions import ClientDisconnected
from ZEO.StorageServer import StorageServer
from ZEO.tests.ConnectionTests import CommonSetupTearDown
@@ -30,7 +33,7 @@
__super_getServerConfig = CommonSetupTearDown.getServerConfig
__super_setUp = CommonSetupTearDown.setUp
__super_tearDown = CommonSetupTearDown.tearDown
-
+
realm = None
def setUp(self):
@@ -74,7 +77,9 @@
self.assert_(self._storage._connection)
self._storage._connection.poll()
self.assert_(self._storage.is_connected())
-
+ # Make a call to make sure the mechanism is working
+ self._storage.versions()
+
def testNOK(self):
self._storage = self.openClientStorage(wait=0, username="foo",
password="noogie",
@@ -83,6 +88,20 @@
# If the test established a connection, then it failed.
self.failIf(self._storage._connection)
+ def testUnauthenticatedMessage(self):
+ # Test that an unauthenticated message is rejected by the server
+ # if it was sent after the connection was authenticated.
+ # Sleep for 0.2 seconds to give the server some time to start up
+ # seems to be needed before and after creating the storage
+ self._storage = self.openClientStorage(wait=0, username="foo",
+ password="bar", realm=self.realm)
+ self.wait()
+ self._storage.versions()
+ # Manually clear the state of the hmac connection
+ 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
protocol = "plaintext"
@@ -108,4 +127,3 @@
if __name__ == "__main__":
unittest.main(defaultTest='test_suite')
-
=== ZODB3/ZEO/tests/forker.py 1.37 => 1.38 ===
--- ZODB3/ZEO/tests/forker.py:1.37 Fri May 30 13:40:30 2003
+++ ZODB3/ZEO/tests/forker.py Thu Oct 2 14:17:21 2003
@@ -70,20 +70,20 @@
Returns the ZEO port, the test server port, the pid, and the path
to the config file.
"""
-
+
# Store the config info in a temp file.
tmpfile = tempfile.mktemp(".conf")
fp = open(tmpfile, 'w')
zeo_conf.dump(fp)
fp.write(storage_conf)
fp.close()
-
+
# Find the zeoserver script
import ZEO.tests.zeoserver
script = ZEO.tests.zeoserver.__file__
if script.endswith('.pyc'):
script = script[:-1]
-
+
# Create a list of arguments, which we'll tuplify below
qa = _quote_arg
args = [qa(sys.executable), qa(script), '-C', qa(tmpfile)]
=== ZODB3/ZEO/tests/auth_plaintext.py 1.2 => 1.3 ===
--- ZODB3/ZEO/tests/auth_plaintext.py:1.2 Fri May 30 15:20:56 2003
+++ ZODB3/ZEO/tests/auth_plaintext.py Thu Oct 2 14:17:21 2003
@@ -13,11 +13,11 @@
##############################################################################
"""Implements plaintext password authentication. The password is stored in
an SHA hash in the Database. The client sends over the plaintext
-password, and the SHA hashing is done on the server side.
-
+password, and the SHA hashing is done on the server side.
+
This mechanism offers *no network security at all*; the only security
-is provided by not storing plaintext passwords on disk. (See the
-auth_srp module for a secure mechanism)"""
+is provided by not storing plaintext passwords on disk.
+"""
import sha
@@ -25,20 +25,31 @@
from ZEO.auth import register_module
from ZEO.auth.base import Client, Database
+def session_key(username, realm, password):
+ 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)
except LookupError:
return 0
-
- password = sha.new(password).hexdigest()
- return self.finish_auth(dbpw == password)
-
+
+ password_dig = sha.new(password).hexdigest()
+ if dbpw == password_dig:
+ self.connection.setSessionKey(session_key(username,
+ self.database.realm,
+ password))
+ return self.finish_auth(dbpw == password_dig)
+
+
class PlaintextClient(Client):
extensions = ["auth"]
def start(self, username, realm, password):
- return self.stub.auth(username, password)
+ if self.stub.auth(username, password):
+ return session_key(username, realm, password)
+ else:
+ return None
register_module("plaintext", StorageClass, PlaintextClient, Database)
=== ZODB3/ZEO/tests/InvalidationTests.py 1.5 => 1.6 ===
--- ZODB3/ZEO/tests/InvalidationTests.py:1.5 Mon Sep 15 12:29:18 2003
+++ ZODB3/ZEO/tests/InvalidationTests.py Thu Oct 2 14:17:21 2003
@@ -347,8 +347,8 @@
# Run two threads that update the BTree
cd = {}
- t1 = self.StressThread(self, db1, stop, 1, cd, 1, sleep=0.001)
- t2 = self.StressThread(self, db1, stop, 2, cd, 2, sleep=0.001)
+ t1 = self.StressThread(self, db1, stop, 1, cd, 1, sleep=0.01)
+ t2 = self.StressThread(self, db1, stop, 2, cd, 2, sleep=0.01)
self.go(stop, cd, t1, t2)
cn.sync()
@@ -375,8 +375,8 @@
cd = {}
t1 = self.StressThread(self, db1, stop, 1, cd, 1, 3)
- t2 = self.StressThread(self, db2, stop, 2, cd, 2, 3, 0.001)
- t3 = self.StressThread(self, db2, stop, 3, cd, 3, 3, 0.001)
+ t2 = self.StressThread(self, db2, stop, 2, cd, 2, 3, 0.01)
+ t3 = self.StressThread(self, db2, stop, 3, cd, 3, 3, 0.01)
self.go(stop, cd, t1, t2, t3)
cn.sync()
@@ -404,8 +404,8 @@
cd = {}
t1 = VersionStressThread(self, db1, stop, 1, cd, 1, 3)
- t2 = VersionStressThread(self, db2, stop, 2, cd, 2, 3, 0.001)
- t3 = VersionStressThread(self, db2, stop, 3, cd, 3, 3, 0.001)
+ t2 = VersionStressThread(self, db2, stop, 2, cd, 2, 3, 0.01)
+ t3 = VersionStressThread(self, db2, stop, 3, cd, 3, 3, 0.01)
self.go(stop, cd, t1, t2, t3)
cn.sync()
@@ -435,9 +435,9 @@
# at the same time.
cd = {}
- t1 = LargeUpdatesThread(self, db1, stop, 1, cd, 1, 3, 0.001)
- t2 = LargeUpdatesThread(self, db2, stop, 2, cd, 2, 3, 0.001)
- t3 = LargeUpdatesThread(self, db2, stop, 3, cd, 3, 3, 0.001)
+ t1 = LargeUpdatesThread(self, db1, stop, 1, cd, 1, 3, 0.02)
+ t2 = LargeUpdatesThread(self, db2, stop, 2, cd, 2, 3, 0.01)
+ t3 = LargeUpdatesThread(self, db2, stop, 3, cd, 3, 3, 0.01)
self.go(stop, cd, t1, t2, t3)
cn.sync()
=== ZODB3/ZEO/tests/ConnectionTests.py 1.43 => 1.44 ===
--- ZODB3/ZEO/tests/ConnectionTests.py:1.43 Mon Sep 15 12:29:18 2003
+++ ZODB3/ZEO/tests/ConnectionTests.py Thu Oct 2 14:17:21 2003
@@ -170,7 +170,7 @@
if ro_svr:
zconf.read_only = 1
if self.monitor:
- zconf.monitor_address = ("", 42000)
+ zconf.monitor_address = ("", 42000)
if self.invq:
zconf.invalidation_queue_size = self.invq
if self.timeout:
=== ZODB3/ZEO/tests/CommitLockTests.py 1.14 => 1.15 ===
--- ZODB3/ZEO/tests/CommitLockTests.py:1.14 Mon Sep 15 12:29:18 2003
+++ ZODB3/ZEO/tests/CommitLockTests.py Thu Oct 2 14:17:21 2003
@@ -27,7 +27,7 @@
ZERO = '\0'*8
class DummyDB:
- def invalidate(self, *args):
+ def invalidate(self, *args, **kwargs):
pass
class WorkerThread(TestThread):
@@ -116,7 +116,7 @@
self._dostore()
self._cleanup()
-
+
def checkCommitLockVoteAbort(self):
oid, txn = self._start_txn()
self._storage.tpc_vote(txn)
@@ -129,7 +129,7 @@
self._dostore()
self._cleanup()
-
+
def checkCommitLockVoteClose(self):
oid, txn = self._start_txn()
self._storage.tpc_vote(txn)
@@ -153,7 +153,7 @@
def _finish_undo(self, msgid):
return self._storage._server.rpc._deferred_wait(msgid)
-
+
def checkCommitLockUndoFinish(self):
trans_id = self._get_trans_id()
oid, txn = self._start_txn()
@@ -170,7 +170,7 @@
self._dostore()
self._cleanup()
-
+
def checkCommitLockUndoAbort(self):
trans_id = self._get_trans_id()
oid, txn = self._start_txn()
@@ -186,7 +186,7 @@
self._dostore()
self._cleanup()
-
+
def checkCommitLockUndoClose(self):
trans_id = self._get_trans_id()
oid, txn = self._start_txn()
@@ -201,23 +201,24 @@
self._finish_threads()
self._cleanup()
-
+
def _begin_threads(self):
# Start a second transaction on a different connection without
- # blocking the test thread.
+ # blocking the test thread. Returns only after each thread has
+ # set it's ready event.
self._storages = []
self._threads = []
-
+
for i in range(self.NUM_CLIENTS):
storage = self._duplicate_client()
txn = Transaction()
tid = self._get_timestamp()
-
+
t = WorkerThread(self, storage, txn)
self._threads.append(t)
t.start()
t.ready.wait()
-
+
# Close on the connections abnormally to test server response
if i == 0:
storage.close()
More information about the Zope-Checkins
mailing list