-
Notifications
You must be signed in to change notification settings - Fork 538
Add clarification and test to fixed SSS behaviour #19734
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
d201b45
b580c1c
f86094c
812fcbe
c8e6e5d
6d83c1f
39b0b68
9966496
9727779
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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| Have SSS return a new response immediately if a room subscription have changed and produced a new response. | ||
| Update Sliding Sync to return a new response immediately if a room subscription have changed and produced a new response. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Update Sliding Sync to return a new response immediately if a room subscription have changed and produced a new response. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -25,8 +25,10 @@ | |||||
| from synapse.server import HomeServer | ||||||
| from synapse.storage.databases.main.events import DeltaState, SlidingSyncTableChanges | ||||||
| from synapse.util.clock import Clock | ||||||
| from synapse.util.duration import Duration | ||||||
|
|
||||||
| from tests.rest.client.sliding_sync.test_sliding_sync import SlidingSyncBase | ||||||
| from tests.server import TimedOutException | ||||||
| from tests.test_utils.event_injection import mark_event_as_partial_state | ||||||
|
|
||||||
| logger = logging.getLogger(__name__) | ||||||
|
|
@@ -2245,3 +2247,76 @@ def test_lazy_loading_room_members_state_reset_non_limited_timeline(self) -> Non | |||||
| response_body["rooms"][room_id]["required_state"][0]["event_id"], | ||||||
| first_event_id, | ||||||
| ) | ||||||
|
|
||||||
| def test_changing_required_state_returns_immediately(self) -> None: | ||||||
| """Test that if we change the `required_state`, then we return immediately | ||||||
| with the new `required_state`.""" | ||||||
|
|
||||||
| user1_id = self.register_user("user1", "pass") | ||||||
| user1_tok = self.login(user1_id, "pass") | ||||||
|
|
||||||
| room_id1 = self.helper.create_room_as(user1_id, tok=user1_tok) | ||||||
|
|
||||||
| # Make an initial sync request with no required state | ||||||
| sync_body = { | ||||||
| "lists": { | ||||||
| "foo-list": { | ||||||
| "ranges": [[0, 1]], | ||||||
| "required_state": [], | ||||||
| "timeline_limit": 0, | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| response_body, from_token = self.do_sync(sync_body, tok=user1_tok) | ||||||
|
|
||||||
| # We should see no required state | ||||||
| self.assertIsNone(response_body["rooms"][room_id1].get("required_state")) | ||||||
|
|
||||||
| # Get the state_map before we change the state as this is the final state we | ||||||
| # expect to see when we update the required state. | ||||||
| state_map = self.get_success( | ||||||
| self.storage_controllers.state.get_current_state(room_id1) | ||||||
| ) | ||||||
|
|
||||||
| # There is no new data, and so making another sync request will block. | ||||||
| channel = self.make_sync_request( | ||||||
| sync_body, | ||||||
| since=from_token, | ||||||
| tok=user1_tok, | ||||||
| timeout=Duration(seconds=10), | ||||||
| await_result=False, | ||||||
| ) | ||||||
|
|
||||||
| # Request will block for 10 seconds as there no updates. | ||||||
| with self.assertRaises(TimedOutException): | ||||||
| channel.await_result(timeout_ms=9500) | ||||||
|
|
||||||
| # Wait for the request to actually finish. (We do this to ensure log | ||||||
| # contexts don't leak between tests). | ||||||
| channel.await_result(timeout_ms=1000) | ||||||
|
|
||||||
| # Now update the Sliding Sync requests to include a `required_state` | ||||||
| # event, and make another sync request. | ||||||
| sync_body["lists"]["foo-list"]["required_state"] = [ | ||||||
| [EventTypes.Create, ""], | ||||||
| ] | ||||||
|
|
||||||
| channel = self.make_sync_request( | ||||||
| sync_body, | ||||||
| since=from_token, | ||||||
| tok=user1_tok, | ||||||
| timeout=Duration(seconds=10), | ||||||
| await_result=False, | ||||||
| ) | ||||||
|
|
||||||
| # We should see the new `required_state` immediately without waiting | ||||||
| # (for the full timeout, we may need to wait briefly). | ||||||
|
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.
Suggested change
Although this may not be true, see other discussion |
||||||
| channel.await_result(timeout_ms=100) | ||||||
|
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. Perhaps this would pass if we just use
Suggested change
|
||||||
| response_body = channel.json_body | ||||||
| self._assertRequiredStateIncludes( | ||||||
| response_body["rooms"][room_id1]["required_state"], | ||||||
| { | ||||||
| state_map[(EventTypes.Create, "")], | ||||||
| }, | ||||||
| exact=True, | ||||||
| ) | ||||||
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.
Thoughts?
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.
Isn't that basically what we're testing here?
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.
Yes, but this reinvents the wheel. And it would be nice to see the same thing pass without message sending or possibly adapt it so that it doesn't send messages.
At the very least, we should update the comments there to indicate that the message sending isn't necessary anymore (see this test) and move this test closer and possibly align the name better to 'expand'/'retract' just to connect them better (although the current name is fine if it were standalone)
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.
I think having the test cases be separate makes sense. The other ones are testing that we include/exclude the
required_stateeven when the room does appear in the response (due to there being a message). The fact that we immediately return is a very related but distinct thing.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.
I think we should at-least point out the new test (
test_changing_required_state_returns_immediately) in the docstring fortest_rooms_required_state_expand_retract_expand