-
Notifications
You must be signed in to change notification settings - Fork 260
feat: [NPM] call policy reconcile in dataplane #1188
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
2158914
a5dcc10
d9f2e1a
7a83224
66be271
fea8283
e433728
a0d1377
de3d6e2
261acda
e1e4a3e
729f7f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,6 +47,50 @@ Chain AZURE-NPM-ACCEPT (1 references) | |||||||||||||||||||||||
| ` | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| func TestStaleChainsForceLock(t *testing.T) { | ||||||||||||||||||||||||
| testChains := []string{} | ||||||||||||||||||||||||
| for i := 0; i < 100000; i++ { | ||||||||||||||||||||||||
| testChains = append(testChains, fmt.Sprintf("test-chain-%d", i)) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| calls := []testutils.TestCmd{} | ||||||||||||||||||||||||
| for _, chain := range testChains { | ||||||||||||||||||||||||
| calls = append(calls, getFakeDestroyCommand(chain)) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| ioshim := common.NewMockIOShim(calls) | ||||||||||||||||||||||||
| // don't verify calls because there shouldn't be as many commands as we create if forceLock works properly | ||||||||||||||||||||||||
| pMgr := NewPolicyManager(ioshim, ipsetConfig) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| start := make(chan struct{}, 1) | ||||||||||||||||||||||||
| done := make(chan struct{}, 1) | ||||||||||||||||||||||||
| go func() { | ||||||||||||||||||||||||
| pMgr.reconcileManager.Lock() | ||||||||||||||||||||||||
| defer pMgr.reconcileManager.Unlock() | ||||||||||||||||||||||||
| start <- struct{}{} | ||||||||||||||||||||||||
| require.NoError(t, pMgr.cleanupChains(testChains)) | ||||||||||||||||||||||||
|
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. for cleanupChains function can we move azure-container-networking/npm/pkg/dataplane/policies/chain-management_linux.go Lines 227 to 237 in fea8283
default case in the select loop above it?
|
||||||||||||||||||||||||
| done <- struct{}{} | ||||||||||||||||||||||||
| }() | ||||||||||||||||||||||||
| <-start | ||||||||||||||||||||||||
| pMgr.reconcileManager.forceLock() | ||||||||||||||||||||||||
| <-done | ||||||||||||||||||||||||
| // the releaseLockSignal should be empty, there should be some stale chains, and staleChains should be unlockable | ||||||||||||||||||||||||
| fmt.Println("weren't able to delete this many chains:", len(pMgr.staleChains.chainsToCleanup)) | ||||||||||||||||||||||||
| require.NotEqual(t, 0, len(pMgr.staleChains.chainsToCleanup), "stale chains should not be empty") | ||||||||||||||||||||||||
| require.Equal(t, 0, len(pMgr.reconcileManager.releaseLockSignal), "releaseLockSignal should be empty") | ||||||||||||||||||||||||
| pMgr.reconcileManager.Unlock() | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| func TestStaleChainsForceUnlock(t *testing.T) { | ||||||||||||||||||||||||
| ioshim := common.NewMockIOShim(nil) | ||||||||||||||||||||||||
| defer ioshim.VerifyCalls(t, nil) | ||||||||||||||||||||||||
| pMgr := NewPolicyManager(ioshim, ipsetConfig) | ||||||||||||||||||||||||
| pMgr.reconcileManager.forceLock() | ||||||||||||||||||||||||
| require.Equal(t, 1, len(pMgr.reconcileManager.releaseLockSignal), "releaseLockSignal should be non-empty") | ||||||||||||||||||||||||
| pMgr.reconcileManager.forceUnlock() | ||||||||||||||||||||||||
| // the releaseLockSignal should be empty and staleChains should be lockable | ||||||||||||||||||||||||
| require.Equal(t, 0, len(pMgr.reconcileManager.releaseLockSignal), "releaseLockSignal should be empty") | ||||||||||||||||||||||||
| pMgr.reconcileManager.Lock() | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| func TestStaleChainsAddAndRemove(t *testing.T) { | ||||||||||||||||||||||||
| ioshim := common.NewMockIOShim(nil) | ||||||||||||||||||||||||
| defer ioshim.VerifyCalls(t, nil) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.