-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix session recording truncation #60891
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
Changes from all commits
7cec059
64e4b59
af8087e
aa973fe
9177f92
fa65c63
e9ce236
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 |
|---|---|---|
|
|
@@ -128,14 +128,6 @@ func TestCompleteUpload(t *testing.T) { | |
| createPart(t, handler, upload, int64(5), []byte("withreservation")) | ||
| }, | ||
| }, | ||
| { | ||
| desc: "OnlyReservation", | ||
| expectedContent: []byte{}, | ||
| partsFunc: func(t *testing.T, handler *Handler, upload *events.StreamUpload) { | ||
| createPart(t, handler, upload, int64(1), []byte{}) | ||
| createPart(t, handler, upload, int64(2), []byte{}) | ||
| }, | ||
| }, | ||
| } { | ||
| t.Run(test.desc, func(t *testing.T) { | ||
| handler, err := NewHandler(Config{ | ||
|
|
@@ -169,3 +161,48 @@ func TestCompleteUpload(t *testing.T) { | |
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestCleanupEmptyUpload(t *testing.T) { | ||
| ctx := t.Context() | ||
|
|
||
| handler, err := NewHandler(Config{ | ||
| Directory: t.TempDir(), | ||
| OpenFile: os.OpenFile, | ||
| }) | ||
| require.NoError(t, err) | ||
|
|
||
| sessionID := session.NewID() | ||
|
|
||
| // Create a completed upload. | ||
| upload, err := handler.CreateUpload(ctx, sessionID) | ||
| require.NoError(t, err) | ||
|
|
||
| err = handler.ReserveUploadPart(ctx, *upload, 1) | ||
| require.NoError(t, err) | ||
|
|
||
| content := []byte("hello world") | ||
| part, err := handler.UploadPart(ctx, *upload, 1, bytes.NewReader(content)) | ||
| require.NoError(t, err) | ||
|
|
||
| err = handler.CompleteUpload(ctx, *upload, []events.StreamPart{*part}) | ||
| require.NoError(t, err) | ||
|
|
||
| // Create an empty upload with the same session ID and try to complete it. | ||
| emptyUpload, err := handler.CreateUpload(ctx, sessionID) | ||
| require.NoError(t, err) | ||
|
|
||
| err = handler.CompleteUpload(ctx, *emptyUpload, []events.StreamPart{}) | ||
| require.NoError(t, err) | ||
|
|
||
| // The empty upload should be cleaned up without impacting the original completed upload. | ||
| uploadPath := handler.recordingPath(upload.SessionID) | ||
| f, err := os.Open(uploadPath) | ||
| require.NoError(t, err) | ||
|
|
||
| gotContent, err := io.ReadAll(f) | ||
| require.NoError(t, err) | ||
| require.Equal(t, content, gotContent) | ||
|
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. Let's take a closer look at this fix since test is failing in CI.
Contributor
Author
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. This was caused by 9177f92, reverted. Sorry for the haphazard change, in addition to being done wrong, I don't think it's necessary. |
||
|
|
||
| require.NoDirExists(t, handler.uploadRootPath(*upload)) | ||
| require.NoDirExists(t, handler.uploadRootPath(*emptyUpload)) | ||
| } | ||
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.
@rosstimothy FYI I had to remove this test as it was basically ensuring that we do upload empty uploads if we find an empty upload instead of discarding it.