Skip to content
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/19890.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove wall-clock dependency of `test_redact_messages_all_rooms` test, as this caused flakiness.
27 changes: 12 additions & 15 deletions tests/rest/admin/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import hmac
import json
import os
import time
import urllib.parse
from binascii import unhexlify
from http import HTTPStatus
Expand Down Expand Up @@ -5788,21 +5787,19 @@ def test_redact_messages_all_rooms(self) -> None:
self.assertEqual(channel.code, 200)
id = channel.json_body.get("redact_id")

timeout_s = 10
start_time = time.time()
redact_result = ""
while redact_result != "complete":
if start_time + timeout_s < time.time():
self.fail("Timed out waiting for redactions.")
# Need 1 tick as we send 1 replication request per original event
# and each wait must be >= `_EPSILON` from `http/client.py`
Comment on lines +5790 to +5791

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm updating this description further in #19871 as I'm also making other related changes. Thanks for making this more precise!

Suggested change
# Need 1 tick as we send 1 replication request per original event
# and each wait must be >= `_EPSILON` from `http/client.py`
# `/redact` just schedules a background task that runs in the background
# (fire-and-forget) so we need to do the waiting here.
#
# Need 1 tick as we send 1 replication request for the redaction of each
# original event. The replication request body is streamed by a `Cooperator`
# that uses the clock to schedule each chunk at a tiny *non-zero* delay
# (`CLOCK_SCHEDULE_EPSILON`), so we need to actually advance the clock for it to
# fire.

for _ in range(len(original_event_ids)):
self.reactor.advance(0.001)

channel2 = self.make_request(
"GET",
f"/_synapse/admin/v1/user/redact_status/{id}",
access_token=self.admin_tok,
)
redact_result = channel2.json_body["status"]
if redact_result == "failed":
self.fail("Redaction task failed.")
# Verify the HTTP `redact_status` endpoint reports completion.
channel2 = self.make_request(
"GET",
f"/_synapse/admin/v1/user/redact_status/{id}",
access_token=self.admin_tok,
)
self.assertEqual(channel2.code, 200)
self.assertEqual(channel2.json_body["status"], "complete")

redaction_ids = set()
for rm in [self.rm1, self.rm2, self.rm3]:
Expand Down
Loading