From 209650cdad316e60bddde83563de19911c75c226 Mon Sep 17 00:00:00 2001 From: QxBytes Date: Wed, 29 May 2024 13:16:04 -0700 Subject: [PATCH] add multitenancy delete net not found ut (noop) --- cni/network/network_test.go | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/cni/network/network_test.go b/cni/network/network_test.go index 1f86a1fda5..78ab9f446f 100644 --- a/cni/network/network_test.go +++ b/cni/network/network_test.go @@ -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"), @@ -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 {