-
Notifications
You must be signed in to change notification settings - Fork 52
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
Ensure many batches are able to be imported (MSC2716) #212
Closed
MadLittleMods
wants to merge
4
commits into
master
from
madlittlemods/ensure-many-historical-chunks-work
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,6 +207,54 @@ func TestImportHistoricalMessages(t *testing.T) { | |
} | ||
}) | ||
|
||
t.Run("Many batches are able to be imported and recalled from /messages", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
roomID := as.CreateRoom(t, createPublicRoomOpts) | ||
alice.JoinRoom(t, roomID, nil) | ||
|
||
// Create some normal messages in the timeline | ||
eventIDsBefore := createMessagesInRoom(t, alice, roomID, 2) | ||
eventIdBefore := eventIDsBefore[len(eventIDsBefore)-1] | ||
timeAfterEventBefore := time.Now() | ||
|
||
// wait X number of ms to ensure that the timestamp changes enough for | ||
// each of the historical messages we try to import later | ||
numBatches := 11 | ||
numHistoricalMessagesPerBatch := 100 | ||
time.Sleep(time.Duration(numBatches*numHistoricalMessagesPerBatch) * timeBetweenMessages) | ||
|
||
// eventIDsAfter | ||
createMessagesInRoom(t, alice, roomID, 2) | ||
|
||
// Import a long chain of batches connected to each other. | ||
// We want to make sure Synapse doesn't blow up after we import | ||
// many messages. | ||
nextBatchID := "" | ||
for i := 0; i < numBatches; i++ { | ||
insertTime := timeAfterEventBefore.Add(timeBetweenMessages * time.Duration(numBatches-numHistoricalMessagesPerBatch*i)) | ||
batchSendRes := batchSendHistoricalMessages( | ||
t, | ||
as, | ||
roomID, | ||
eventIdBefore, | ||
nextBatchID, | ||
createJoinStateEventsForBatchSendRequest([]string{virtualUserID}, insertTime), | ||
createMessageEventsForBatchSendRequest([]string{virtualUserID}, insertTime, numHistoricalMessagesPerBatch), | ||
// Status | ||
200, | ||
) | ||
batchSendResBody := client.ParseJSON(t, batchSendRes) | ||
nextBatchID = client.GetJSONFieldStr(t, batchSendResBody, "next_batch_id") | ||
} | ||
|
||
// Ensure the /message response gives a 200 | ||
alice.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "messages"}, client.WithContentType("application/json"), client.WithQueries(url.Values{ | ||
"dir": []string{"b"}, | ||
"limit": []string{"100"}, | ||
})) | ||
}) | ||
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. Maybe move this down one more test |
||
|
||
t.Run("Historical events from multiple users in the same batch", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It would be nice to assert the number of events returned too, and that they have different event IDs.
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.
👍 Going to close this one in favor of #214 which actually checks for all of the messages in the batches