Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Reduce run-times of tests by advancing the reactor less #7757

Merged
merged 5 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/7757.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce run times of some unit tests by advancing the reactor a fewer number of times.
2 changes: 1 addition & 1 deletion tests/handlers/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def test_initial_earliest_token(self):
# self.handler.notify_new_event()

# We need to let the delta processor advance…
self.pump(10 * 60)
self.reactor.advance(10 * 60)

# Get the slices! There should be two -- day 1, and day 2.
r = self.get_success(self.store.get_statistics_for_subject("room", room_1, 0))
Expand Down
2 changes: 1 addition & 1 deletion tests/http/test_fedclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,6 @@ def test_closes_connection(self):
self.assertFalse(conn.disconnecting)

# wait for a while
self.pump(120)
self.reactor.advance(120)

self.assertTrue(conn.disconnecting)
2 changes: 1 addition & 1 deletion tests/push/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _check_for_mail(self):
last_stream_ordering = pushers[0]["last_stream_ordering"]

# Advance time a bit, so the pusher will register something has happened
self.pump(100)
self.pump(10)

# It hasn't succeeded yet, so the stream ordering shouldn't have moved
pushers = self.get_success(
Expand Down
2 changes: 1 addition & 1 deletion tests/storage/test_cleanup_extrems.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def test_send_dummy_event(self):

# Pump the reactor repeatedly so that the background updates have a
# chance to run.
self.pump(10 * 60)
self.pump(20)

latest_event_ids = self.get_success(
self.store.get_latest_event_ids_in_room(self.room_id)
Expand Down
6 changes: 3 additions & 3 deletions tests/storage/test_roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_count_known_servers_stat_counter_disabled(self):
self.inject_room_member(self.room, self.u_bob, Membership.JOIN)
self.inject_room_member(self.room, self.u_charlie.to_string(), Membership.JOIN)

self.pump(20)
self.pump()

self.assertTrue("_known_servers_count" not in self.store.__dict__.keys())

Expand All @@ -101,7 +101,7 @@ def test_count_known_servers_stat_counter_enabled(self):
# Initialises to 1 -- itself
self.assertEqual(self.store._known_servers_count, 1)

self.pump(20)
self.pump()

# No rooms have been joined, so technically the SQL returns 0, but it
# will still say it knows about itself.
Expand All @@ -111,7 +111,7 @@ def test_count_known_servers_stat_counter_enabled(self):
self.inject_room_member(self.room, self.u_bob, Membership.JOIN)
self.inject_room_member(self.room, self.u_charlie.to_string(), Membership.JOIN)

self.pump(20)
self.pump(1)

# It now knows about Charlie's server.
self.assertEqual(self.store._known_servers_count, 2)
Expand Down
2 changes: 1 addition & 1 deletion tests/util/test_retryutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_limiter(self):
#
# one more go, with success
#
self.pump(MIN_RETRY_INTERVAL * RETRY_MULTIPLIER * 2.0)
self.reactor.advance(MIN_RETRY_INTERVAL * RETRY_MULTIPLIER * 2.0)
limiter = self.get_success(get_retry_limiter("test_dest", self.clock, store))

self.pump(1)
Expand Down