Skip to content

TestJumpToDateEndpoint: Add test for seamlessly paginating from /context start token#853

Open
MadLittleMods wants to merge 5 commits intomainfrom
madlittlemods/timestamp-to-event-paginate-from-start
Open

TestJumpToDateEndpoint: Add test for seamlessly paginating from /context start token#853
MadLittleMods wants to merge 5 commits intomainfrom
madlittlemods/timestamp-to-event-paginate-from-start

Conversation

@MadLittleMods
Copy link
Collaborator

@MadLittleMods MadLittleMods commented Mar 26, 2026

TestJumpToDateEndpoint: Add test for seamlessly paginating from /context start token

Follow-up to #852

Todo

Pull Request Checklist

})

t.Run("can paginate after getting remote event from timestamp to event endpoint", func(t *testing.T) {
t.Run("can paginate backwards after getting remote event from timestamp to event endpoint (start)", func(t *testing.T) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test will fail until element-hq/synapse#19611 is merged

})

t.Run("can paginate after getting remote event from timestamp to event endpoint", func(t *testing.T) {
t.Run("can paginate backwards after getting remote event from timestamp to event endpoint (start)", func(t *testing.T) {
Copy link
Collaborator Author

@MadLittleMods MadLittleMods Mar 26, 2026

Choose a reason for hiding this comment

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

Updated to have a test for paginating from the start and end tokens from /context after getting an event from /timestamp_to_event.

Previously, we only had a test for end

Comment on lines -222 to 227
// Hit `/messages` until `eventA` has been backfilled and replicated across
// workers (the worker persisting events isn't necessarily the same as the worker
// serving `/messages`)
fetchUntilMessagesResponseHas(t, remoteCharlie, roomID, func(ev gjson.Result) bool {
return ev.Get("event_id").Str == eventA.EventID
t.Run("can paginate backwards after getting remote event from timestamp to event endpoint (end)", func(t *testing.T) {
t.Parallel()
roomID, eventA, eventB := createTestRoom(t, alice)
remoteCharlie.MustJoinRoom(t, roomID, []spec.ServerName{
deployment.GetFullyQualifiedHomeserverName(t, "hs1"),
})
Copy link
Collaborator Author

@MadLittleMods MadLittleMods Mar 26, 2026

Choose a reason for hiding this comment

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

While the idea of the comment above fetchUntilMessagesResponseHas(...) is true, we're retrying the wrong endpoint. When you use /timstamp_to_event, it should backfill the event in the cases of asking the federation. Which means we should be retrying the /context request until we see the event (not /messages)

This functionality was maintained via the client.WithRetryUntil(...) on the /context request

}
}

func fetchUntilMessagesResponseHas(t *testing.T, c *client.CSAPI, roomID string, check func(gjson.Result) bool) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Remove fetchUntilMessagesResponseHas as it's now unused

@MadLittleMods MadLittleMods marked this pull request as ready for review March 27, 2026 00:06
@MadLittleMods MadLittleMods requested review from a team as code owners March 27, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant