-
Notifications
You must be signed in to change notification settings - Fork 2
Make sure config values are actually being used not defaults #175
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
Open
yushan8
wants to merge
6
commits into
main
Choose a base branch
from
yushan/ensure-configs-used
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ae5861c
Make sure config values are actually being used not defaults
yushan8 bdbca68
Update defaults
yushan8 bfeb301
Update
yushan8 c417693
Update
yushan8 4ab07be
Address review comments: reuse remote var, test metadata chunking
yushan8 28d54a5
Shrink chunking test data sizes
yushan8 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
Some comments aren't visible on the classic Files Changed page.
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 |
|---|---|---|
|
|
@@ -186,7 +186,6 @@ func TestChunkTargets(t *testing.T) { | |
| func TestResultToGetTargetGraphResponse_Chunking(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| // 500 targets with DefaultTargetChunkSize=250 → 2 target chunks + 1 metadata = 3 responses | ||
| numTargets := 500 | ||
| result := targethasher.Result{ | ||
| TargetNames: make([]string, numTargets), | ||
|
|
@@ -198,16 +197,45 @@ func TestResultToGetTargetGraphResponse_Chunking(t *testing.T) { | |
| result.Targets[name] = &targethasher.Target{Name: name, Hash: []byte{0}, RuleType: "go_library"} | ||
| } | ||
|
|
||
| responses, err := ResultToGetTargetGraphResponse(context.Background(), result) | ||
| require.NoError(t, err) | ||
|
|
||
| // 2 target chunks + 1 metadata chunk (500 targets well under DefaultMetadataMapChunkSize) | ||
| require.Len(t, responses, 3) | ||
| tests := []struct { | ||
| name string | ||
| targetChunkSize int | ||
| metadataMapChunkSize int | ||
| wantTargetChunks int | ||
| }{ | ||
| { | ||
| name: "250 per chunk", | ||
| targetChunkSize: 250, | ||
| metadataMapChunkSize: 50_000, | ||
|
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. nit: set it to a smaler value to test the metadata chunks size, 100-200 ish |
||
| wantTargetChunks: 2, | ||
| }, | ||
| { | ||
| name: "100 per chunk", | ||
| targetChunkSize: 100, | ||
| metadataMapChunkSize: 50_000, | ||
| wantTargetChunks: 5, | ||
| }, | ||
| { | ||
| name: "all in one chunk", | ||
| targetChunkSize: 1000, | ||
| metadataMapChunkSize: 50_000, | ||
| wantTargetChunks: 1, | ||
| }, | ||
| } | ||
|
|
||
| for _, resp := range responses[:2] { | ||
| _, ok := resp.Item.(*pb.GetTargetGraphResponse_Targets) | ||
| assert.True(t, ok, "expected Targets chunk") | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| responses, err := ResultToGetTargetGraphResponse(context.Background(), result, tt.targetChunkSize, tt.metadataMapChunkSize) | ||
| require.NoError(t, err) | ||
|
|
||
| var targetChunks int | ||
| for _, resp := range responses { | ||
| if _, ok := resp.Item.(*pb.GetTargetGraphResponse_Targets); ok { | ||
| targetChunks++ | ||
| } | ||
| } | ||
| assert.Equal(t, tt.wantTargetChunks, targetChunks) | ||
| }) | ||
| } | ||
| _, ok := responses[2].Item.(*pb.GetTargetGraphResponse_Metadata) | ||
| assert.True(t, ok, "last response should be Metadata") | ||
| } | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.