-
Notifications
You must be signed in to change notification settings - Fork 260
fix: [NPM] fix incorrect ipset create, fix 1-off prometheus logic, and add cache checking for UTs #1202
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
fix: [NPM] fix incorrect ipset create, fix 1-off prometheus logic, and add cache checking for UTs #1202
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dc21ec2
wip
huntergregory fe81c79
dont touch v1 metrics code and fix lints
huntergregory aff520c
add comment and comment code to resolve lint
huntergregory 4d68949
optimize looping and dirty cache updates
huntergregory f9bc5e8
address comments and change param type of modifyCacheForKernelMemberU…
huntergregory 00bd755
Merge branch 'master' into ipsetmanager-bug-fix-and-UTs
huntergregory 6e71db9
add exec time metrics
huntergregory 00fc589
UTs
huntergregory 4ae8e86
fix lints
huntergregory ef03e40
initialize metrics in policymanager tests
huntergregory 7d2be89
fix bug in publishing npm logs
huntergregory 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
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 |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| package ipsets | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestShouldBeInKernelAndCanDelete(t *testing.T) { | ||
| s := &IPSetMetadata{"test-set", Namespace} | ||
| l := &IPSetMetadata{"test-list", KeyLabelOfNamespace} | ||
| tests := []struct { | ||
| name string | ||
| set *IPSet | ||
| wantInKernel bool | ||
| wantDeletable bool | ||
| }{ | ||
| { | ||
| name: "only has selector reference", | ||
| set: &IPSet{ | ||
| Name: s.GetPrefixName(), | ||
| SetProperties: SetProperties{ | ||
| Type: s.Type, | ||
| Kind: s.GetSetKind(), | ||
| }, | ||
| SelectorReference: map[string]struct{}{ | ||
| "ref-1": {}, | ||
| }, | ||
| }, | ||
| wantInKernel: true, | ||
| wantDeletable: false, | ||
| }, | ||
| { | ||
| name: "only has netpol reference", | ||
| set: &IPSet{ | ||
| Name: s.GetPrefixName(), | ||
| SetProperties: SetProperties{ | ||
| Type: s.Type, | ||
| Kind: s.GetSetKind(), | ||
| }, | ||
| NetPolReference: map[string]struct{}{ | ||
| "ref-1": {}, | ||
| }, | ||
| }, | ||
| wantInKernel: true, | ||
| wantDeletable: false, | ||
| }, | ||
| { | ||
| name: "only referenced in list (in kernel)", | ||
| set: &IPSet{ | ||
| Name: s.GetPrefixName(), | ||
| SetProperties: SetProperties{ | ||
| Type: s.Type, | ||
| Kind: s.GetSetKind(), | ||
| }, | ||
| ipsetReferCount: 1, | ||
| kernelReferCount: 1, | ||
| }, | ||
| wantInKernel: true, | ||
| wantDeletable: false, | ||
| }, | ||
| { | ||
| name: "only referenced in list (not in kernel)", | ||
| set: &IPSet{ | ||
| Name: s.GetPrefixName(), | ||
| SetProperties: SetProperties{ | ||
| Type: s.Type, | ||
| Kind: s.GetSetKind(), | ||
| }, | ||
| ipsetReferCount: 1, | ||
| }, | ||
| wantInKernel: false, | ||
| wantDeletable: false, | ||
| }, | ||
| { | ||
| name: "only has set members", | ||
| set: &IPSet{ | ||
| Name: l.GetPrefixName(), | ||
| SetProperties: SetProperties{ | ||
| Type: l.Type, | ||
| Kind: l.GetSetKind(), | ||
| }, | ||
| MemberIPSets: map[string]*IPSet{ | ||
| s.GetPrefixName(): NewIPSet(s), | ||
| }, | ||
| }, | ||
| wantInKernel: false, | ||
| wantDeletable: false, | ||
| }, | ||
| { | ||
| name: "only has ip members", | ||
| set: &IPSet{ | ||
| Name: s.GetPrefixName(), | ||
| SetProperties: SetProperties{ | ||
| Type: s.Type, | ||
| Kind: s.GetSetKind(), | ||
| }, | ||
| IPPodKey: map[string]string{ | ||
| "1.2.3.4": "pod-a", | ||
| }, | ||
| }, | ||
| wantInKernel: false, | ||
| wantDeletable: false, | ||
| }, | ||
| { | ||
| name: "deletable", | ||
| set: &IPSet{ | ||
| Name: s.GetPrefixName(), | ||
| SetProperties: SetProperties{ | ||
| Type: Namespace, | ||
| Kind: s.GetSetKind(), | ||
| }, | ||
| }, | ||
| wantInKernel: false, | ||
| wantDeletable: true, | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| tt := tt | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if tt.wantInKernel { | ||
| require.True(t, tt.set.shouldBeInKernel()) | ||
| } else { | ||
| require.False(t, tt.set.shouldBeInKernel()) | ||
| } | ||
|
|
||
| if tt.wantDeletable { | ||
| require.True(t, tt.set.canBeDeleted()) | ||
| } else { | ||
| require.False(t, tt.set.canBeDeleted()) | ||
| } | ||
| }) | ||
| } | ||
| } |
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.