divmod-dev team mailing list archive
-
divmod-dev team
-
Mailing list archive
-
Message #00407
[Merge] lp:~alfred-54/divmod.org/divmod.org into lp:divmod.org
Zectbumo has proposed merging lp:~alfred-54/divmod.org/divmod.org into lp:divmod.org.
Requested reviews:
Divmod-dev (divmod-dev)
For more details, see:
https://code.launchpad.net/~alfred-54/divmod.org/divmod.org/+merge/158833
* completed juice to amp transition
* cleanup client connections to keep the reactor clean
* WRITE will return ConnectionDone when no connection is found
OS X 10.8 and Windows 7 trial vertex both return PASSED (skips=5, successes=52)
--
https://code.launchpad.net/~alfred-54/divmod.org/divmod.org/+merge/158833
Your team Divmod-dev is requested to review the proposed merge of lp:~alfred-54/divmod.org/divmod.org into lp:divmod.org.
=== modified file 'Vertex/vertex/q2q.py'
--- Vertex/vertex/q2q.py 2012-03-14 23:42:53 +0000
+++ Vertex/vertex/q2q.py 2013-04-15 01:06:29 +0000
@@ -1309,7 +1309,7 @@
"""
id = int(box['id'])
if id not in self.connections:
- raise error.ConnectionDone()
+ return error.ConnectionDone()
connection = self.connections[id]
data = box['body']
connection.dataReceived(data)
=== modified file 'Vertex/vertex/q2qclient.py'
--- Vertex/vertex/q2qclient.py 2010-04-17 15:10:09 +0000
+++ Vertex/vertex/q2qclient.py 2013-04-15 01:06:29 +0000
@@ -310,8 +310,8 @@
class UserAdder(AMP):
def connectionMade(self):
- self.d = AddUser(name=self.factory.name,
- password=self.factory.password).do(self)
+ self.d = self.callRemote(AddUser, name=self.factory.name,
+ password=self.factory.password)
class UserAdderFactory(protocol.ClientFactory):
=== modified file 'Vertex/vertex/q2qstandalone.py'
--- Vertex/vertex/q2qstandalone.py 2010-04-17 15:10:09 +0000
+++ Vertex/vertex/q2qstandalone.py 2013-04-15 01:06:29 +0000
@@ -12,13 +12,13 @@
class IdentityAdmin(AMP):
- def command_ADD_USER(self, name, password):
+ def _add_user(self, name, password):
# all security is transport security
theDomain = self.transport.getQ2QHost().domain
self.factory.store.addUser(theDomain, name, password)
return {}
- command_ADD_USER.command = AddUser
+ AddUser.responder(_add_user)
class IdentityAdminFactory:
def __init__(self, certstore):
=== modified file 'Vertex/vertex/test/test_q2q.py'
--- Vertex/vertex/test/test_q2q.py 2012-03-12 18:30:09 +0000
+++ Vertex/vertex/test/test_q2q.py 2013-04-15 01:06:29 +0000
@@ -33,7 +33,8 @@
class FakeConnectTCP:
implements(IResolverSimple)
- def __init__(self, connectTCP):
+ def __init__(self, tester, connectTCP):
+ self.tester = tester
self._connectTCP = connectTCP
self.hostPortToHostPort = {}
self.hostToLocalHost = {}
@@ -50,9 +51,22 @@
self.hostPortToHostPort[(localIP, fakePortNumber)] = (localIP, realPortNumber)
self.hostPortToHostPort[(hostname, fakePortNumber)] = (hostname, realPortNumber)
+ def _cleanupClient(self, client):
+ client.transport.closingDeferred = defer.Deferred()
+ transport_connectionLost = client.transport.connectionLost
+ def connectionLost(*args, **kwargs):
+ transport_connectionLost(*args, **kwargs)
+ if not client.transport.closingDeferred.called:
+ client.transport.closingDeferred.callback(None)
+ client.transport.connectionLost = connectionLost
+ self.tester.addCleanup(lambda: client.transport.closingDeferred)
+
def connectTCP(self, host, port, *args, **kw):
localhost, localport = self.hostPortToHostPort.get((host,port), (host, port))
- return self._connectTCP(localhost, localport, *args, **kw)
+ client = self._connectTCP(localhost, localport, *args, **kw)
+ self._cleanupClient(client)
+ self.tester.addCleanup(client.transport.loseConnection)
+ return client
def getHostSync(self,name):
result = self.hostToLocalHost[name]
@@ -335,7 +349,7 @@
# A mapping of host names to port numbers Our connectTCP will always
# connect to 127.0.0.1 and on a port which is a value in this
# dictionary.
- fakeDNS = FakeConnectTCP(reactor.connectTCP)
+ fakeDNS = FakeConnectTCP(self, reactor.connectTCP)
reactor.connectTCP = fakeDNS.connectTCP
# ALSO WE MUST DO OTHER SIMILAR THINGS
@@ -627,7 +641,7 @@
def connected(proto):
d1 = self.assertFailure(proto.callRemote(Fatal), FatalError)
def noMoreCalls(_):
- self.assertFailure(proto.callRemote(Flag),
+ return self.assertFailure(proto.callRemote(Flag),
ConnectionDone)
d1.addCallback(noMoreCalls)
return d1
Follow ups