diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2018-09-18 18:17:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-18 18:17:15 +0100 |
commit | 31c15dcb80c8f11fd03dbb9b0ccff4777dc8e457 (patch) | |
tree | 2ee45023e518888d996b2f0743bf16f2c5769f5f /tests/replication/slave/storage | |
parent | Merge pull request #3894 from matrix-org/hs/phone_home_py_version (diff) | |
download | synapse-31c15dcb80c8f11fd03dbb9b0ccff4777dc8e457.tar.xz |
Refactor matrixfederationclient to fix logging (#3906)
We want to wait until we have read the response body before we log the request as complete, otherwise a confusing thing happens where the request appears to have completed, but we later fail it. To do this, we factor the salient details of a request out to a separate object, which can then keep track of the txn_id, so that it can be logged.
Diffstat (limited to 'tests/replication/slave/storage')
-rw-r--r-- | tests/replication/slave/storage/_base.py | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/tests/replication/slave/storage/_base.py b/tests/replication/slave/storage/_base.py index 089cecfbee..9e9fbbfe93 100644 --- a/tests/replication/slave/storage/_base.py +++ b/tests/replication/slave/storage/_base.py @@ -15,8 +15,6 @@ from mock import Mock, NonCallableMock -import attr - from synapse.replication.tcp.client import ( ReplicationClientFactory, ReplicationClientHandler, @@ -24,6 +22,7 @@ from synapse.replication.tcp.client import ( from synapse.replication.tcp.resource import ReplicationStreamProtocolFactory from tests import unittest +from tests.server import FakeTransport class BaseSlavedStoreTestCase(unittest.HomeserverTestCase): @@ -56,36 +55,8 @@ class BaseSlavedStoreTestCase(unittest.HomeserverTestCase): server = server_factory.buildProtocol(None) client = client_factory.buildProtocol(None) - @attr.s - class FakeTransport(object): - - other = attr.ib() - disconnecting = False - buffer = attr.ib(default=b'') - - def registerProducer(self, producer, streaming): - - self.producer = producer - - def _produce(): - self.producer.resumeProducing() - reactor.callLater(0.1, _produce) - - reactor.callLater(0.0, _produce) - - def write(self, byt): - self.buffer = self.buffer + byt - - if getattr(self.other, "transport") is not None: - self.other.dataReceived(self.buffer) - self.buffer = b"" - - def writeSequence(self, seq): - for x in seq: - self.write(x) - - client.makeConnection(FakeTransport(server)) - server.makeConnection(FakeTransport(client)) + client.makeConnection(FakeTransport(server, reactor)) + server.makeConnection(FakeTransport(client, reactor)) def replicate(self): """Tell the master side of replication that something has happened, and then |