-
Notifications
You must be signed in to change notification settings - Fork 656
manager/state/raft/storage: TestReadRepairWAL: fix for etcd v3.5.5 #3095
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -231,12 +231,24 @@ func TestReadRepairWAL(t *testing.T) { | |
| require.NoError(t, err) | ||
| require.Len(t, files, 1) | ||
|
|
||
| fName := filepath.Join(tempdir, files[0].Name()) | ||
| fileContents, err := os.ReadFile(fName) | ||
| require.NoError(t, err) | ||
| info, err := files[0].Info() | ||
| require.NoError(t, err) | ||
| require.NoError(t, os.WriteFile(fName, fileContents[:200], info.Mode())) | ||
| // Corrupt the file by truncating it to replicate a broken state (partial | ||
| // write), but for this test, make sure that there's enough bytes left to | ||
| // read a record (24 bytes). The record size (recBytes) is calculated here; | ||
| // | ||
| // - https://github.com/etcd-io/etcd/blob/621cd7b9e5aa2ccf634b555e4ebe0037b8975066/server/wal/decoder.go#L83 | ||
| // - https://github.com/etcd-io/etcd/blob/621cd7b9e5aa2ccf634b555e4ebe0037b8975066/server/wal/decoder.go#L122-L131 | ||
| // | ||
| // Using a shorter length will make the test fail: | ||
| // | ||
| // wal: max entry size limit exceeded, recBytes: 24, fileSize(200) - offset(184) - padBytes(0) = entryLimit(16) | ||
| // | ||
| // So the file should be >= 208 bytes. | ||
| // | ||
| // For further details, see: | ||
| // | ||
| // - https://github.com/etcd-io/etcd/commit/621cd7b9e5aa2ccf634b555e4ebe0037b8975066 / https://github.com/etcd-io/etcd/pull/14127 (backport of https://github.com/etcd-io/etcd/pull/14122) | ||
| // - https://github.com/etcd-io/etcd/issues/14114 | ||
| require.NoError(t, os.Truncate(filepath.Join(tempdir, files[0].Name()), 300)) | ||
|
Member
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. Effectively the fix is |
||
|
|
||
| ogWAL, err := OriginalWAL.Open(tempdir, snapshot) | ||
| require.NoError(t, err) | ||
|
|
||
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.
Replaced this with
os.Truncate()below, which was shorter, and more descriptive what we're doing 😅