New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DISPATCH-209 : dynamic request response test #134
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They layout of this test is a bit odd. See inline comments,
|
||
def on_link_opened(self, event): | ||
if event.receiver: | ||
self.sender = event.container.create_sender(self.conn1, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are going to get two on_link_opened events for receivers. This means you are creating the same sender twice. This one sender is used for both client-send and server-send operations.
self.conn1 = event.container.connect(self.address1) | ||
self.conn2 = event.container.connect(self.address2) | ||
self.server_receiver = event.container.create_receiver(self.conn2, self.dest) | ||
self.client_receiver = event.container.create_receiver(self.conn2, None, dynamic=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the client and server receivers are established on the same connection. Is this what was intended? I would think that one connection would be the client and the other the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline comments.
@@ -90,6 +90,11 @@ def test_02_anonymous_sender(self): | |||
test.run() | |||
self.assertEqual(None, test.error) | |||
|
|||
def test_03_dynamic_request_response(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get multiple tests in one here just by replicating this test with different router addresses. For example, you could have three tests: 0->0, 0->1, 0->2.
self.n_accepted = 0 | ||
|
||
def timeout(self): | ||
self.error = "Timeout Expired %d messages received." % self.n_received |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should include all of the counters here. If the test times out, you'll want as much information as you can get.
def on_sendable(self, event): | ||
if self.n_sent < self.n_expected: | ||
# We send to server, and ask it to reply to client. | ||
request = Message(body=self.n_sent, address=self.dest, reply_to=self.client_receiver.remote_source.address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a race condition here. What if you get credit on the sender before the dynamic receiver is fully attached?
|
||
# Receiver gets a message and replies to client. | ||
if event.receiver == self.server_receiver : | ||
self.sender.send ( Message(address=event.message.reply_to, body="Reply hazy, try again later.") ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The server is sending its responses on the client's sender!
phew.