Skip to content

Commit

Permalink
remove test not relevant to 1.5.x and clean up logic
Browse files Browse the repository at this point in the history
  • Loading branch information
QxBytes committed Aug 28, 2024
1 parent d55388b commit 5bf6d4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 46 deletions.
12 changes: 5 additions & 7 deletions cni/network/network_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,14 @@ func TestPluginMultitenancyLinuxDelete(t *testing.T) {
} else if method == CNI_DEL {
err = plugin.Delete(tt.args)
}
if tt.wantErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}
endpoints, _ := plugin.nm.GetAllEndpoints(localNwCfg.Name)
require.Len(t, endpoints, tt.wantNumEps[idx])
}
if tt.wantErr {
require.Error(t, err)
} else {
require.NoError(t, err)
endpoints, _ := plugin.nm.GetAllEndpoints(localNwCfg.Name)
require.Empty(t, endpoints)
}
})
}
}
44 changes: 5 additions & 39 deletions cni/network/network_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,38 +717,6 @@ func TestPluginMultitenancyWindowsDelete(t *testing.T) {
},
},
},
{
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: "bc526fae-4ba0-4e80-bc90-ad721e5850bf",
Args: fmt.Sprintf("K8S_POD_NAME=%v;K8S_POD_NAMESPACE=%v", "test-pod", "test-pod-ns"),
// if we set to eth0 we get an endpoint already exists error, but this is okay in dualnic since they are in different networks
IfName: "eth1",
},
wantErr: false,
wantNumEps: []map[string]int{
// after add, this should be the state
{
"mulnet-vlan1-20-0-0-0_24": 1,
"mulnet-vlan2-10-0-0-0_24": 1,
},
// after delete, this should be the state
{
"mulnet-vlan1-20-0-0-0_24": 0,
"mulnet-vlan2-10-0-0-0_24": 0,
},
},
},
}

for _, tt := range tests {
Expand All @@ -761,19 +729,17 @@ func TestPluginMultitenancyWindowsDelete(t *testing.T) {
} else if method == CNI_DEL {
err = plugin.Delete(tt.delArgs)
}
if tt.wantErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}
// check state
for networkID, wantedState := range tt.wantNumEps[idx] {
endpoints, _ := plugin.nm.GetAllEndpoints(networkID)
require.Len(t, endpoints, wantedState)
}
}
if tt.wantErr {
require.Error(t, err)
} else {
require.NoError(t, err)
endpoints, _ := plugin.nm.GetAllEndpoints(localNwCfg.Name)
require.Empty(t, endpoints)
}
})
}
}

0 comments on commit 5bf6d4f

Please sign in to comment.