-
Notifications
You must be signed in to change notification settings - Fork 564
Remove unnecessary self.pump calls in some of our tests.
#19676
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Remove unnecessary `self.pump` calls in some of our tests. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,8 +133,6 @@ def do_request() -> Generator["Deferred[Any]", object, object]: | |
| b"%s" % (len(res_json), res_json) | ||
| ) | ||
|
|
||
| self.pump() | ||
|
|
||
| res = self.successResultOf(test_d) | ||
|
|
||
| # check the response is as expected | ||
|
|
@@ -710,8 +708,6 @@ def test_json_error(self, return_value: bytes) -> None: | |
| b"%s" % (len(return_value), return_value) | ||
| ) | ||
|
|
||
| self.pump() | ||
|
|
||
| f = self.failureResultOf(test_d) | ||
| self.assertIsInstance(f.value, RequestSendFailed) | ||
|
|
||
|
|
@@ -751,8 +747,6 @@ def test_too_big(self) -> None: | |
| b"HTTP/1.1 200 OK\r\nServer: Fake\r\nContent-Type: application/json\r\n\r\n" | ||
| ) | ||
|
|
||
| self.pump() | ||
|
|
||
| # should still be waiting | ||
| self.assertNoResult(test_d) | ||
|
|
||
|
|
@@ -853,7 +847,7 @@ def test_proxy_requests_through_federation_sender_worker(self) -> None: | |
| self.hs.get_federation_http_client().get_json("remoteserv:8008", "foo/bar") | ||
| ) | ||
|
|
||
| # Pump the reactor so our deferred goes through the motions | ||
| # Needed under Postgres | ||
| self.pump() | ||
|
Comment on lines
+850
to
851
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could use with a better explanation if we understand. Or at-least some |
||
|
|
||
| # Make sure that the request was proxied through the `federation_sender` worker | ||
|
|
@@ -905,9 +899,7 @@ def test_proxy_request_with_network_error_through_federation_sender_worker( | |
| self.hs.get_federation_http_client().get_json("remoteserv:8008", "foo/bar") | ||
| ) | ||
|
|
||
| # Pump the reactor so our deferred goes through the motions. We pump with 10 | ||
| # seconds (0.1 * 100) so the `MatrixFederationHttpClient` runs out of retries | ||
| # and finally passes along the error response. | ||
| # Needed under Postgres | ||
| self.pump(0.1) | ||
|
|
||
| # Make sure that the request was proxied through the `federation_sender` worker | ||
|
|
@@ -984,7 +976,7 @@ def test_proxy_requests_and_discards_hop_by_hop_headers(self) -> None: | |
| ) | ||
| ) | ||
|
|
||
| # Pump the reactor so our deferred goes through the motions | ||
| # Needed under Postgres | ||
| self.pump() | ||
|
|
||
| # Make sure that the request was proxied through the `federation_sender` worker | ||
|
|
@@ -1078,9 +1070,7 @@ def test_not_able_to_proxy_requests_through_federation_sender_worker_when_wrong_ | |
| self.hs.get_federation_http_client().get_json("remoteserv:8008", "foo/bar") | ||
| ) | ||
|
|
||
| # Pump the reactor so our deferred goes through the motions. We pump with 10 | ||
| # seconds (0.1 * 100) so the `MatrixFederationHttpClient` runs out of retries | ||
| # and finally passes along the error response. | ||
| # Needed under Postgres | ||
| self.pump(0.1) | ||
|
Comment on lines
-1081
to
1084
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was the previous comment a untrue? It sounds plausible. Introduced in matrix-org/synapse#15913 "deferred goes through the motions" is wrong but the retries explanation sounds accurate given we
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah ok derp, this test is skipped on SQLite, d'oh, that explains the difference. I will check the Postgres ones more carefully |
||
|
|
||
| # Make sure that the request was *NOT* proxied through the `federation_sender` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -159,9 +159,6 @@ def test_sends_http(self) -> None: | |
| self.assertEqual(len(pushers), 1) | ||
| last_stream_ordering = pushers[0].last_stream_ordering | ||
|
|
||
| # Advance time a bit, so the pusher will register something has happened | ||
| self.pump() | ||
|
|
||
| # It hasn't succeeded yet, so the stream ordering shouldn't have moved | ||
| pushers = list( | ||
| self.get_success( | ||
|
|
@@ -182,7 +179,6 @@ def test_sends_http(self) -> None: | |
|
|
||
| # Make the push succeed | ||
| self.push_attempts[0][0].callback({}) | ||
| self.pump() | ||
|
|
||
| # The stream ordering has increased | ||
| pushers = list( | ||
|
|
@@ -205,7 +201,6 @@ def test_sends_http(self) -> None: | |
|
|
||
| # Make the second push succeed | ||
| self.push_attempts[1][0].callback({}) | ||
| self.pump() | ||
|
|
||
| # The stream ordering has increased, again | ||
| pushers = list( | ||
|
|
@@ -284,12 +279,8 @@ def test_sends_high_priority_for_encrypted(self) -> None: | |
| tok=other_access_token, | ||
| ) | ||
|
|
||
| # Advance time a bit, so the pusher will register something has happened | ||
| self.pump() | ||
|
|
||
| # Make the push succeed | ||
| self.push_attempts[0][0].callback({}) | ||
| self.pump() | ||
|
|
||
| # Check our push made it with high priority | ||
| self.assertEqual(len(self.push_attempts), 1) | ||
|
|
@@ -308,7 +299,6 @@ def test_sends_high_priority_for_encrypted(self) -> None: | |
|
|
||
| # Check no push notifications are sent regarding the membership changes | ||
| # (that would confuse the test) | ||
| self.pump() | ||
| self.assertEqual(len(self.push_attempts), 1) | ||
|
|
||
| # Send another encrypted event | ||
|
|
@@ -330,8 +320,6 @@ def test_sends_high_priority_for_encrypted(self) -> None: | |
| tok=other_access_token, | ||
| ) | ||
|
|
||
| # Advance time a bit, so the pusher will register something has happened | ||
| self.pump() | ||
| self.assertEqual(len(self.push_attempts), 2) | ||
| self.assertEqual( | ||
| self.push_attempts[1][1], "http://example.com/_matrix/push/v1/notify" | ||
|
|
@@ -385,12 +373,8 @@ def test_sends_high_priority_for_one_to_one_only(self) -> None: | |
| # Send a message | ||
| self.helper.send(room, body="Hi!", tok=other_access_token) | ||
|
|
||
| # Advance time a bit, so the pusher will register something has happened | ||
| self.pump() | ||
|
|
||
| # Make the push succeed | ||
| self.push_attempts[0][0].callback({}) | ||
| self.pump() | ||
|
|
||
| # Check our push made it with high priority — this is a one-to-one room | ||
| self.assertEqual(len(self.push_attempts), 1) | ||
|
|
@@ -406,14 +390,11 @@ def test_sends_high_priority_for_one_to_one_only(self) -> None: | |
|
|
||
| # Check no push notifications are sent regarding the membership changes | ||
| # (that would confuse the test) | ||
| self.pump() | ||
| self.assertEqual(len(self.push_attempts), 1) | ||
|
|
||
| # Send another event | ||
| self.helper.send(room, body="Welcome!", tok=other_access_token) | ||
|
|
||
| # Advance time a bit, so the pusher will register something has happened | ||
| self.pump() | ||
| self.assertEqual(len(self.push_attempts), 2) | ||
| self.assertEqual( | ||
| self.push_attempts[1][1], "http://example.com/_matrix/push/v1/notify" | ||
|
|
@@ -472,12 +453,8 @@ def test_sends_high_priority_for_mention(self) -> None: | |
| # Send a message | ||
| self.helper.send(room, body="Oh, user, hello!", tok=other_access_token) | ||
|
|
||
| # Advance time a bit, so the pusher will register something has happened | ||
| self.pump() | ||
|
|
||
| # Make the push succeed | ||
| self.push_attempts[0][0].callback({}) | ||
| self.pump() | ||
|
|
||
| # Check our push made it with high priority | ||
| self.assertEqual(len(self.push_attempts), 1) | ||
|
|
@@ -489,8 +466,6 @@ def test_sends_high_priority_for_mention(self) -> None: | |
| # Send another event, this time with no mention | ||
| self.helper.send(room, body="Are you there?", tok=other_access_token) | ||
|
|
||
| # Advance time a bit, so the pusher will register something has happened | ||
| self.pump() | ||
| self.assertEqual(len(self.push_attempts), 2) | ||
| self.assertEqual( | ||
| self.push_attempts[1][1], "http://example.com/_matrix/push/v1/notify" | ||
|
|
@@ -554,12 +529,8 @@ def test_sends_high_priority_for_atroom(self) -> None: | |
| tok=other_access_token, | ||
| ) | ||
|
|
||
| # Advance time a bit, so the pusher will register something has happened | ||
| self.pump() | ||
|
|
||
| # Make the push succeed | ||
| self.push_attempts[0][0].callback({}) | ||
| self.pump() | ||
|
|
||
| # Check our push made it with high priority | ||
| self.assertEqual(len(self.push_attempts), 1) | ||
|
|
@@ -573,8 +544,6 @@ def test_sends_high_priority_for_atroom(self) -> None: | |
| room, body="@room the spider is gone", tok=yet_another_access_token | ||
| ) | ||
|
|
||
| # Advance time a bit, so the pusher will register something has happened | ||
| self.pump() | ||
| self.assertEqual(len(self.push_attempts), 2) | ||
| self.assertEqual( | ||
| self.push_attempts[1][1], "http://example.com/_matrix/push/v1/notify" | ||
|
|
@@ -703,7 +672,6 @@ def _test_push_unread_count(self) -> None: | |
| self.helper.send(room_id, body="HELLO???", tok=other_access_token) | ||
|
|
||
| def _advance_time_and_make_push_succeed(self, expected_push_attempts: int) -> None: | ||
| self.pump() | ||
| self.push_attempts[expected_push_attempts - 1][0].callback({}) | ||
|
|
||
| def _check_push_attempt( | ||
|
|
@@ -1084,7 +1052,6 @@ def test_jitter(self) -> None: | |
| index += 1 | ||
|
|
||
| self.reactor.advance(1) | ||
| self.pump() | ||
|
|
||
| self.assertEqual(len(self.push_attempts), 11) | ||
|
|
||
|
|
@@ -1150,7 +1117,6 @@ def test_msc4076_badge_count( | |
| self.helper.send(room, body="Hi!", tok=other_access_token) | ||
|
|
||
| # Advance time a bit, so the pusher will register something has happened | ||
| self.pump() | ||
|
|
||
| # One push was attempted to be sent | ||
| self.assertEqual(len(self.push_attempts), 1) | ||
|
|
@@ -1218,17 +1184,14 @@ def test_push_backoff(self) -> None: | |
| self.push_attempts[0][2]["notification"]["content"]["body"], "Message 1" | ||
| ) | ||
| self.push_attempts[0][0].callback({}) | ||
| self.pump() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does the push backoff stuff work? Seems plausible that we're dealing with schedule We need to make sure these don't have any meaning regardless of whether the test passes without them. (applies to this whole file) |
||
|
|
||
| # Send another message, this time it fails | ||
| self.helper.send(room, body="Message 2", tok=other_access_token) | ||
| self.assertEqual(len(self.push_attempts), 2) | ||
| self.push_attempts[1][0].errback(Exception("couldn't connect")) | ||
| self.pump() | ||
|
|
||
| # Sending yet another message doesn't trigger a push immediately | ||
| self.helper.send(room, body="Message 3", tok=other_access_token) | ||
| self.pump() | ||
| self.assertEqual(len(self.push_attempts), 2) | ||
|
|
||
| # .. but waiting for a bit will cause more pushes | ||
|
|
||
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.
For reference, as far as I understand, these were found by commenting out the pump functionality and removing them from any tests that still passed.