Skip to content

Commit

Permalink
add multitenancy delete net not found ut (noop)
Browse files Browse the repository at this point in the history
  • Loading branch information
QxBytes committed May 29, 2024
1 parent 07ce9d7 commit 209650c
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions cni/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,18 +696,41 @@ func TestPluginMultitenancyDelete(t *testing.T) {
Master: "eth0",
}

happyArgs := &cniSkel.CmdArgs{
StdinData: localNwCfg.Serialize(),
ContainerID: "test-container",
Netns: "test-container",
Args: fmt.Sprintf("K8S_POD_NAME=%v;K8S_POD_NAMESPACE=%v", "test-pod", "test-pod-ns"),
IfName: eth0IfName,
}

tests := []struct {
name string
methods []string
args *cniSkel.CmdArgs
delArgs *cniSkel.CmdArgs
wantErr bool
wantErrMsg string
}{
{
name: "Multitenancy delete success",
methods: []string{CNI_ADD, CNI_DEL},
args: &cniSkel.CmdArgs{
StdinData: localNwCfg.Serialize(),
args: happyArgs,
delArgs: happyArgs,
wantErr: false,
},
{
name: "Multitenancy delete net not found",
methods: []string{CNI_ADD, CNI_DEL},
args: happyArgs,
delArgs: &cniSkel.CmdArgs{
StdinData: (&cni.NetworkConfig{
CNIVersion: "0.3.0",
Name: "othernet",
MultiTenancy: true,
EnableExactMatchForPodName: true,
Master: "eth0",
}).Serialize(),
ContainerID: "test-container",
Netns: "test-container",
Args: fmt.Sprintf("K8S_POD_NAME=%v;K8S_POD_NAMESPACE=%v", "test-pod", "test-pod-ns"),
Expand All @@ -725,7 +748,7 @@ func TestPluginMultitenancyDelete(t *testing.T) {
if method == CNI_ADD {
err = plugin.Add(tt.args)
} else if method == CNI_DEL {
err = plugin.Delete(tt.args)
err = plugin.Delete(tt.delArgs)
}
}
if tt.wantErr {
Expand Down

0 comments on commit 209650c

Please sign in to comment.