Remove outdated network plugin code
The code was added to support rktnetes and non-CRI docker integrations. These legacy integrations have already been removed from the codebase. This change removes the compatibility code existing soley for the legacy integrations.
This commit is contained in:
@@ -22,73 +22,94 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNetworkHostGetsPodNotFound(t *testing.T) {
|
||||
testKubelet := newTestKubelet(t, true)
|
||||
defer testKubelet.Cleanup()
|
||||
nh := networkHost{testKubelet.kubelet}
|
||||
|
||||
actualPod, _ := nh.GetPodByName("", "")
|
||||
if actualPod != nil {
|
||||
t.Fatalf("Was expected nil, received %v instead", actualPod)
|
||||
func TestNodeIPParam(t *testing.T) {
|
||||
type test struct {
|
||||
nodeIP string
|
||||
success bool
|
||||
testName string
|
||||
}
|
||||
}
|
||||
|
||||
func TestNetworkHostGetsKubeClient(t *testing.T) {
|
||||
testKubelet := newTestKubelet(t, true)
|
||||
defer testKubelet.Cleanup()
|
||||
nh := networkHost{testKubelet.kubelet}
|
||||
|
||||
if nh.GetKubeClient() != testKubelet.fakeKubeClient {
|
||||
t.Fatalf("NetworkHost client does not match testKubelet's client")
|
||||
tests := []test{
|
||||
{
|
||||
nodeIP: "",
|
||||
success: false,
|
||||
testName: "IP not set",
|
||||
},
|
||||
{
|
||||
nodeIP: "127.0.0.1",
|
||||
success: false,
|
||||
testName: "IPv4 loopback address",
|
||||
},
|
||||
{
|
||||
nodeIP: "::1",
|
||||
success: false,
|
||||
testName: "IPv6 loopback address",
|
||||
},
|
||||
{
|
||||
nodeIP: "224.0.0.1",
|
||||
success: false,
|
||||
testName: "multicast IPv4 address",
|
||||
},
|
||||
{
|
||||
nodeIP: "ff00::1",
|
||||
success: false,
|
||||
testName: "multicast IPv6 address",
|
||||
},
|
||||
{
|
||||
nodeIP: "169.254.0.1",
|
||||
success: false,
|
||||
testName: "IPv4 link-local unicast address",
|
||||
},
|
||||
{
|
||||
nodeIP: "fe80::0202:b3ff:fe1e:8329",
|
||||
success: false,
|
||||
testName: "IPv6 link-local unicast address",
|
||||
},
|
||||
{
|
||||
nodeIP: "0.0.0.0",
|
||||
success: false,
|
||||
testName: "Unspecified IPv4 address",
|
||||
},
|
||||
{
|
||||
nodeIP: "::",
|
||||
success: false,
|
||||
testName: "Unspecified IPv6 address",
|
||||
},
|
||||
{
|
||||
nodeIP: "1.2.3.4",
|
||||
success: false,
|
||||
testName: "IPv4 address that doesn't belong to host",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestNetworkHostGetsRuntime(t *testing.T) {
|
||||
testKubelet := newTestKubelet(t, true)
|
||||
defer testKubelet.Cleanup()
|
||||
nh := networkHost{testKubelet.kubelet}
|
||||
|
||||
if nh.GetRuntime() != testKubelet.fakeRuntime {
|
||||
t.Fatalf("NetworkHost runtime does not match testKubelet's runtime")
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
assert.Error(t, err, fmt.Sprintf(
|
||||
"Unable to obtain a list of the node's unicast interface addresses."))
|
||||
}
|
||||
}
|
||||
|
||||
func TestNetworkHostSupportsLegacyFeatures(t *testing.T) {
|
||||
testKubelet := newTestKubelet(t, true)
|
||||
defer testKubelet.Cleanup()
|
||||
nh := networkHost{testKubelet.kubelet}
|
||||
|
||||
if nh.SupportsLegacyFeatures() == false {
|
||||
t.Fatalf("SupportsLegacyFeatures should not be false")
|
||||
for _, addr := range addrs {
|
||||
var ip net.IP
|
||||
switch v := addr.(type) {
|
||||
case *net.IPNet:
|
||||
ip = v.IP
|
||||
case *net.IPAddr:
|
||||
ip = v.IP
|
||||
}
|
||||
if ip.IsLoopback() || ip.IsLinkLocalUnicast() {
|
||||
break
|
||||
}
|
||||
successTest := test{
|
||||
nodeIP: ip.String(),
|
||||
success: true,
|
||||
testName: fmt.Sprintf("Success test case for address %s", ip.String()),
|
||||
}
|
||||
tests = append(tests, successTest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoOpHostGetsName(t *testing.T) {
|
||||
nh := NoOpLegacyHost{}
|
||||
pod, err := nh.GetPodByName("", "")
|
||||
if pod != nil && err != true {
|
||||
t.Fatalf("noOpLegacyHost getpodbyname expected to be nil and true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoOpHostGetsKubeClient(t *testing.T) {
|
||||
nh := NoOpLegacyHost{}
|
||||
if nh.GetKubeClient() != nil {
|
||||
t.Fatalf("noOpLegacyHost client expected to be nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoOpHostGetsRuntime(t *testing.T) {
|
||||
nh := NoOpLegacyHost{}
|
||||
if nh.GetRuntime() != nil {
|
||||
t.Fatalf("noOpLegacyHost runtime expected to be nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoOpHostSupportsLegacyFeatures(t *testing.T) {
|
||||
nh := NoOpLegacyHost{}
|
||||
if nh.SupportsLegacyFeatures() != false {
|
||||
t.Fatalf("noOpLegacyHost legacy features expected to be false")
|
||||
for _, test := range tests {
|
||||
err := validateNodeIP(net.ParseIP(test.nodeIP))
|
||||
if test.success {
|
||||
assert.NoError(t, err, "test %s", test.testName)
|
||||
} else {
|
||||
assert.Error(t, err, fmt.Sprintf("test %s", test.testName))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user