-
Notifications
You must be signed in to change notification settings - Fork 417
Clean up GC tests #9751
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
base: master
Are you sure you want to change the base?
Clean up GC tests #9751
Changes from all commits
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ import ( | |||||||||||||||||
| "context" | ||||||||||||||||||
| "errors" | ||||||||||||||||||
| "fmt" | ||||||||||||||||||
| "hash/fnv" | ||||||||||||||||||
| "sort" | ||||||||||||||||||
| "testing" | ||||||||||||||||||
| "time" | ||||||||||||||||||
|
|
@@ -165,12 +166,44 @@ func TestCommitsMap(t *testing.T) { | |||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| type testRepoCommits struct { | ||||||||||||||||||
| commits map[string]testCommit | ||||||||||||||||||
| headsRetentionDays map[string]int32 | ||||||||||||||||||
| expectedActiveIDs []string | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| func fingerprint[T ~string](s T) T { | ||||||||||||||||||
| h := fnv.New64a() | ||||||||||||||||||
| h.Write([]byte(s)) // Write cannot fail for a hash func. | ||||||||||||||||||
| fingerprint := h.Sum64() | ||||||||||||||||||
| return T(fmt.Sprintf("%016x-%s", fingerprint, s)) | ||||||||||||||||||
|
Comment on lines
+178
to
+179
|
||||||||||||||||||
| fingerprint := h.Sum64() | |
| return T(fmt.Sprintf("%016x-%s", fingerprint, s)) | |
| hash := h.Sum64() | |
| return T(fmt.Sprintf("%016x-%s", hash, s)) |
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.
nit; can keep it simple while accepting strings
Copilot
AI
Dec 2, 2025
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.
[nitpick] The scrambleIDs function lacks documentation explaining its purpose. Consider adding a comment describing that it applies fingerprinting to all IDs in the test data structure.
Suggested addition:
// scrambleIDs applies fingerprinting to all commit IDs, head IDs, and expected
// active IDs in the test data to ensure they are not alphabetically ordered.
func scrambleIDs(tst testRepoCommits) testRepoCommits {| // scrambleIDs applies fingerprinting to all commit IDs, head IDs, and expected | |
| // active IDs in the test data to ensure they are not alphabetically ordered. |
Copilot
AI
Dec 2, 2025
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.
The commit.parents slice is being modified, but since commit is a value copy from the range loop, these modifications won't be reflected in the commit value stored in the commits map on line 188. The parents should be modified before storing the commit.
Suggested fix:
for id, commit := range tst.commits {
parents := make([]graveler.CommitID, len(commit.parents))
for idx, parent := range commit.parents {
parents[idx] = fingerprint(parent)
}
commit.parents = parents
commits[fingerprint(id)] = commit
}| for idx, parent := range commit.parents { | |
| commit.parents[idx] = fingerprint(parent) | |
| } | |
| parents := make([]graveler.CommitID, len(commit.parents)) | |
| for idx, parent := range commit.parents { | |
| parents[idx] = fingerprint(parent) | |
| } | |
| commit.parents = parents |
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.
[nitpick] The
fingerprintfunction lacks documentation explaining its purpose and behavior. Consider adding a comment describing that it creates a deterministic hash-prefixed string to scramble commit IDs for testing purposes.Suggested addition: