mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 11:18:16 +00:00
Merge pull request #5975 from yifan-gu/refactor_runContainer
kubelet: Refactor kubelet.runContainer.
This commit is contained in:
@@ -1201,70 +1201,6 @@ func TestMakeVolumesAndBinds(t *testing.T) {
|
||||
verifyStringArrayEquals(t, binds, expectedBinds)
|
||||
}
|
||||
|
||||
func TestMakePortsAndBindings(t *testing.T) {
|
||||
container := api.Container{
|
||||
Ports: []api.ContainerPort{
|
||||
{
|
||||
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",
|
||||
},
|
||||
},
|
||||
}
|
||||
exposedPorts, bindings := makePortsAndBindings(&container)
|
||||
if len(container.Ports) != len(exposedPorts) ||
|
||||
len(container.Ports) != len(bindings) {
|
||||
t.Errorf("Unexpected ports and bindings, %#v %#v %#v", container, exposedPorts, bindings)
|
||||
}
|
||||
for key, value := range bindings {
|
||||
switch value[0].HostPort {
|
||||
case "8080":
|
||||
if !reflect.DeepEqual(docker.Port("80/tcp"), key) {
|
||||
t.Errorf("Unexpected docker port: %#v", key)
|
||||
}
|
||||
if value[0].HostIP != "127.0.0.1" {
|
||||
t.Errorf("Unexpected host IP: %s", value[0].HostIP)
|
||||
}
|
||||
case "443":
|
||||
if !reflect.DeepEqual(docker.Port("443/tcp"), key) {
|
||||
t.Errorf("Unexpected docker port: %#v", key)
|
||||
}
|
||||
if value[0].HostIP != "" {
|
||||
t.Errorf("Unexpected host IP: %s", value[0].HostIP)
|
||||
}
|
||||
case "444":
|
||||
if !reflect.DeepEqual(docker.Port("444/udp"), key) {
|
||||
t.Errorf("Unexpected docker port: %#v", key)
|
||||
}
|
||||
if value[0].HostIP != "" {
|
||||
t.Errorf("Unexpected host IP: %s", value[0].HostIP)
|
||||
}
|
||||
case "445":
|
||||
if !reflect.DeepEqual(docker.Port("445/tcp"), key) {
|
||||
t.Errorf("Unexpected docker port: %#v", key)
|
||||
}
|
||||
if value[0].HostIP != "" {
|
||||
t.Errorf("Unexpected host IP: %s", value[0].HostIP)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type errorTestingDockerClient struct {
|
||||
dockertools.FakeDockerClient
|
||||
listContainersError error
|
||||
|
||||
Reference in New Issue
Block a user