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

Commit 6abb1ad

Browse files
Consolidate purge table lists to prevent desyncronisation (#8713)
I idly noticed that these lists were out of sync with each other, causing us to miss a table in a test case (`local_invites`). Let's consolidate this list instead to prevent this from happening in the future.
1 parent 4fda58d commit 6abb1ad

File tree

2 files changed

+39
-67
lines changed

2 files changed

+39
-67
lines changed

changelog.d/8713.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Consolidate duplicated lists of purged tables that are checked in tests.

tests/rest/admin/test_room.py

Lines changed: 38 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -531,40 +531,7 @@ def _is_member(self, room_id, user_id):
531531
def _is_purged(self, room_id):
532532
"""Test that the following tables have been purged of all rows related to the room.
533533
"""
534-
for table in (
535-
"current_state_events",
536-
"event_backward_extremities",
537-
"event_forward_extremities",
538-
"event_json",
539-
"event_push_actions",
540-
"event_search",
541-
"events",
542-
"group_rooms",
543-
"public_room_list_stream",
544-
"receipts_graph",
545-
"receipts_linearized",
546-
"room_aliases",
547-
"room_depth",
548-
"room_memberships",
549-
"room_stats_state",
550-
"room_stats_current",
551-
"room_stats_historical",
552-
"room_stats_earliest_token",
553-
"rooms",
554-
"stream_ordering_to_exterm",
555-
"users_in_public_rooms",
556-
"users_who_share_private_rooms",
557-
"appservice_room_list",
558-
"e2e_room_keys",
559-
"event_push_summary",
560-
"pusher_throttle",
561-
"group_summary_rooms",
562-
"local_invites",
563-
"room_account_data",
564-
"room_tags",
565-
# "state_groups", # Current impl leaves orphaned state groups around.
566-
"state_groups_state",
567-
):
534+
for table in PURGE_TABLES:
568535
count = self.get_success(
569536
self.store.db_pool.simple_select_one_onecol(
570537
table=table,
@@ -633,39 +600,7 @@ def test_purge_room(self):
633600
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
634601

635602
# Test that the following tables have been purged of all rows related to the room.
636-
for table in (
637-
"current_state_events",
638-
"event_backward_extremities",
639-
"event_forward_extremities",
640-
"event_json",
641-
"event_push_actions",
642-
"event_search",
643-
"events",
644-
"group_rooms",
645-
"public_room_list_stream",
646-
"receipts_graph",
647-
"receipts_linearized",
648-
"room_aliases",
649-
"room_depth",
650-
"room_memberships",
651-
"room_stats_state",
652-
"room_stats_current",
653-
"room_stats_historical",
654-
"room_stats_earliest_token",
655-
"rooms",
656-
"stream_ordering_to_exterm",
657-
"users_in_public_rooms",
658-
"users_who_share_private_rooms",
659-
"appservice_room_list",
660-
"e2e_room_keys",
661-
"event_push_summary",
662-
"pusher_throttle",
663-
"group_summary_rooms",
664-
"room_account_data",
665-
"room_tags",
666-
# "state_groups", # Current impl leaves orphaned state groups around.
667-
"state_groups_state",
668-
):
603+
for table in PURGE_TABLES:
669604
count = self.get_success(
670605
self.store.db_pool.simple_select_one_onecol(
671606
table=table,
@@ -1500,3 +1435,39 @@ def test_join_private_room_if_owner(self):
15001435
self.render(request)
15011436
self.assertEquals(200, int(channel.result["code"]), msg=channel.result["body"])
15021437
self.assertEqual(private_room_id, channel.json_body["joined_rooms"][0])
1438+
1439+
1440+
PURGE_TABLES = [
1441+
"current_state_events",
1442+
"event_backward_extremities",
1443+
"event_forward_extremities",
1444+
"event_json",
1445+
"event_push_actions",
1446+
"event_search",
1447+
"events",
1448+
"group_rooms",
1449+
"public_room_list_stream",
1450+
"receipts_graph",
1451+
"receipts_linearized",
1452+
"room_aliases",
1453+
"room_depth",
1454+
"room_memberships",
1455+
"room_stats_state",
1456+
"room_stats_current",
1457+
"room_stats_historical",
1458+
"room_stats_earliest_token",
1459+
"rooms",
1460+
"stream_ordering_to_exterm",
1461+
"users_in_public_rooms",
1462+
"users_who_share_private_rooms",
1463+
"appservice_room_list",
1464+
"e2e_room_keys",
1465+
"event_push_summary",
1466+
"pusher_throttle",
1467+
"group_summary_rooms",
1468+
"local_invites",
1469+
"room_account_data",
1470+
"room_tags",
1471+
# "state_groups", # Current impl leaves orphaned state groups around.
1472+
"state_groups_state",
1473+
]

0 commit comments

Comments
 (0)