Skip to content
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

Sliding Sync: Move filters tests to rest layer #17703

Merged
merged 8 commits into from
Sep 12, 2024

Conversation

MadLittleMods
Copy link
Contributor

@MadLittleMods MadLittleMods commented Sep 11, 2024

Move filters tests to rest layer in order to test the new (with sliding sync tables) and fallback paths that Sliding Sync can use.

Also found a bug in the new path because it's not being tested which is also fixed in this PR. We now take into account has_known_state when filtering.

Spawning from #17662 (comment). This should have been done when we started using the new sliding sync tables in #17630

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct
    (run the linters)

Comment on lines +1745 to +1748
# Remove rooms if we can't figure out what room type it is
if not sync_room_map[room_id].has_known_state:
filtered_room_id_set.remove(room_id)
continue
Copy link
Contributor Author

@MadLittleMods MadLittleMods Sep 11, 2024

Choose a reason for hiding this comment

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

Fixing filter_rooms_using_tables (the new path using the new sliding sync tables) to take into account has_known_state.

The _no_stripped_state tests exercise these scenarios.

Found this bug because we're actually testing the new path now with this PR.

@@ -1139,3 +1139,61 @@ def test_rooms_bump_stamp_invites(self) -> None:
self.assertEqual(
response_body["rooms"][room_id]["bump_stamp"], invite_pos.stream
)

def test_rooms_meta_is_dm(self) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test is "new" because I moved the "Ensure DM's are correctly marked" checking from one of the filtering tests to it's own separate thing here.

)

def test_filters_is_dm(self) -> None:
"""
Copy link
Contributor Author

@MadLittleMods MadLittleMods Sep 11, 2024

Choose a reason for hiding this comment

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

These tests existed before as unit tests against filter_rooms(...) directly but now that we also have filter_rooms_using_tables(...) they've been migrated to integration tests at the REST layer operating against the Sliding Sync API itself. This way we can test both code paths with the same tests.

They are just refactored to be at this new layer and interact with the API.

@@ -547,323 +622,6 @@ def test_wait_for_new_data_timeout(self) -> None:
# There should be no room sent down.
self.assertFalse(channel.json_body["rooms"])

def test_filter_list(self) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These filter tests already at the REST layer were just moved to tests/rest/client/sliding_sync/test_lists_filters.py now that we have a specific file for it.

@@ -141,6 +142,167 @@ def _assertRequiredStateIncludes(
message=str(actual_required_state),
)

def _add_new_dm_to_global_account_data(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just moving some helpers to the SlidingSyncBase so we can use them across the Sliding Sync tests more easily.

@@ -2984,1384 +2979,6 @@ def test_state_reset(self) -> None:
self.assertTrue(room_id1 in newly_left)


class FilterRoomsTestCase(HomeserverTestCase):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests we're moved to tests/rest/client/sliding_sync/test_lists_filters.py and refactored to interact with the Sliding Sync API directly.

@MadLittleMods MadLittleMods marked this pull request as ready for review September 12, 2024 00:44
@MadLittleMods MadLittleMods requested a review from a team as a code owner September 12, 2024 00:44
Copy link
Member

@devonh devonh left a comment

Choose a reason for hiding this comment

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

Overall looks good to me!
Just a few comments.

}
response_body, _ = self.do_sync(sync_body, tok=user1_tok)
self.assertIncludes(
set(response_body["lists"]["foo-list"]["ops"][0]["room_ids"]),
Copy link
Member

Choose a reason for hiding this comment

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

Not an issue here, but the ops field in sync responses is completely omitted from the MSC. ie. https://github.com/matrix-org/matrix-spec-proposals/blob/erikj/sss/proposals/4186-simplified-sliding-sync.md#response-format

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're thinking about removing it in favor of just a straight list like room_ids: [] but until then I'll use it (context #17671 (comment))

@MadLittleMods MadLittleMods merged commit 9b83fb7 into develop Sep 12, 2024
39 checks passed
@MadLittleMods MadLittleMods deleted the madlittlemods/sliding-sync-move-filters-tests branch September 12, 2024 20:27
@MadLittleMods
Copy link
Contributor Author

Thanks for the review @devonh 🦌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants