Commit 25f37007 authored by Saad Ali's avatar Saad Ali

Merge pull request #24846 from pmorie/kubelet-test-loc

Reduce LOC in kubelet tests
parents 19169889 d1e0e726
......@@ -674,37 +674,29 @@ func TestFindContainersByPod(t *testing.T) {
}
func TestMakePortsAndBindings(t *testing.T) {
portMapping := func(container, host int, protocol api.Protocol, ip string) kubecontainer.PortMapping {
return kubecontainer.PortMapping{
ContainerPort: container,
HostPort: host,
Protocol: protocol,
HostIP: ip,
}
}
portBinding := func(port, ip string) dockernat.PortBinding {
return dockernat.PortBinding{
HostPort: port,
HostIP: ip,
}
}
ports := []kubecontainer.PortMapping{
{
ContainerPort: 80,
HostPort: 8080,
HostIP: "127.0.0.1",
},
{
ContainerPort: 443,
HostPort: 443,
Protocol: "tcp",
},
{
ContainerPort: 444,
HostPort: 444,
Protocol: "udp",
},
{
ContainerPort: 445,
HostPort: 445,
Protocol: "foobar",
},
{
ContainerPort: 443,
HostPort: 446,
Protocol: "tcp",
},
{
ContainerPort: 443,
HostPort: 446,
Protocol: "udp",
},
portMapping(80, 8080, "", "127.0.0.1"),
portMapping(443, 443, "tcp", ""),
portMapping(444, 444, "udp", ""),
portMapping(445, 445, "foobar", ""),
portMapping(443, 446, "tcp", ""),
portMapping(443, 446, "udp", ""),
}
exposedPorts, bindings := makePortsAndBindings(ports)
......@@ -725,38 +717,20 @@ func TestMakePortsAndBindings(t *testing.T) {
// Construct expected bindings
expectPortBindings := map[string][]dockernat.PortBinding{
"80/tcp": {
dockernat.PortBinding{
HostPort: "8080",
HostIP: "127.0.0.1",
},
portBinding("8080", "127.0.0.1"),
},
"443/tcp": {
dockernat.PortBinding{
HostPort: "443",
HostIP: "",
},
dockernat.PortBinding{
HostPort: "446",
HostIP: "",
},
portBinding("443", ""),
portBinding("446", ""),
},
"443/udp": {
dockernat.PortBinding{
HostPort: "446",
HostIP: "",
},
portBinding("446", ""),
},
"444/udp": {
dockernat.PortBinding{
HostPort: "444",
HostIP: "",
},
portBinding("444", ""),
},
"445/tcp": {
dockernat.PortBinding{
HostPort: "445",
HostIP: "",
},
portBinding("445", ""),
},
}
......
......@@ -229,36 +229,12 @@ func TestFakePodWorkers(t *testing.T) {
&api.Pod{},
},
{
&api.Pod{
ObjectMeta: api.ObjectMeta{
UID: "12345678",
Name: "foo",
Namespace: "new",
},
},
&api.Pod{
ObjectMeta: api.ObjectMeta{
UID: "12345678",
Name: "fooMirror",
Namespace: "new",
},
},
podWithUidNameNs("12345678", "foo", "new"),
podWithUidNameNs("12345678", "fooMirror", "new"),
},
{
&api.Pod{
ObjectMeta: api.ObjectMeta{
UID: "98765",
Name: "bar",
Namespace: "new",
},
},
&api.Pod{
ObjectMeta: api.ObjectMeta{
UID: "98765",
Name: "barMirror",
Namespace: "new",
},
},
podWithUidNameNs("98765", "bar", "new"),
podWithUidNameNs("98765", "barMirror", "new"),
},
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment