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

Commit 4c0d637

Browse files
committed
Add a test for testing that unblocking await_full_state on rooms works cross-workers
1 parent 09d073a commit 4c0d637

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright 2022 The Matrix.org Foundation C.I.C.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
from twisted.internet.defer import ensureDeferred
15+
16+
from synapse.rest.client import room
17+
18+
from tests.replication._base import BaseMultiWorkerStreamTestCase
19+
20+
21+
class PartialStateStreamsTestCase(BaseMultiWorkerStreamTestCase):
22+
servlets = [room.register_servlets]
23+
hijack_auth = True
24+
user_id = "@bob:test"
25+
26+
def setUp(self):
27+
super().setUp()
28+
self.store = self.hs.get_datastores().main
29+
30+
def test_un_partial_stated_room_unblocks_over_replication(self) -> None:
31+
"""
32+
Tests that, when a room is un-partial-stated on another worker,
33+
pending calls to `await_full_state` get unblocked.
34+
"""
35+
36+
# user_id = self.register_user("bob", "verysecret")
37+
# token = self.login("bob", "verysecret")
38+
# Make a room.
39+
room_id = self.helper.create_room_as("@bob:test")
40+
# Mark the room as partial-stated.
41+
self.get_success(
42+
self.store.store_partial_state_room(room_id, ["serv1", "serv2"], 0, "serv1")
43+
)
44+
45+
worker = self.make_worker_hs("synapse.app.generic_worker")
46+
47+
# On the worker, attempt to get the current hosts in the room
48+
d = ensureDeferred(
49+
worker.get_storage_controllers().state.get_current_hosts_in_room(room_id)
50+
)
51+
52+
self.reactor.advance(0.1)
53+
54+
# This should block
55+
self.assertFalse(
56+
d.called, "get_current_hosts_in_room/await_full_state did not block"
57+
)
58+
59+
# On the master, clear the partial state flag.
60+
self.get_success(self.store.clear_partial_state_room(room_id))
61+
62+
self.reactor.advance(0.1)
63+
64+
# The worker should have unblocked
65+
self.assertTrue(
66+
d.called, "get_current_hosts_in_room/await_full_state did not unblock"
67+
)

0 commit comments

Comments
 (0)