mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
commit
54d1e7e86d
@ -23,7 +23,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@ -91,8 +91,8 @@ func api_server() {
|
|||||||
Client: http.DefaultClient,
|
Client: http.DefaultClient,
|
||||||
Port: *kubelet_port,
|
Port: *kubelet_port,
|
||||||
}
|
}
|
||||||
random := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
|
random := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
|
||||||
|
|
||||||
storage := map[string]apiserver.RESTStorage{
|
storage := map[string]apiserver.RESTStorage{
|
||||||
"pods": registry.MakePodRegistryStorage(podRegistry, containerInfo, registry.MakeFirstFitScheduler(machineList, podRegistry, random)),
|
"pods": registry.MakePodRegistryStorage(podRegistry, containerInfo, registry.MakeFirstFitScheduler(machineList, podRegistry, random)),
|
||||||
"replicationControllers": registry.MakeControllerRegistryStorage(controllerRegistry),
|
"replicationControllers": registry.MakeControllerRegistryStorage(controllerRegistry),
|
||||||
|
@ -127,7 +127,7 @@ func TestNonEmptyList(t *testing.T) {
|
|||||||
storage := map[string]RESTStorage{}
|
storage := map[string]RESTStorage{}
|
||||||
simpleStorage := SimpleRESTStorage{
|
simpleStorage := SimpleRESTStorage{
|
||||||
list: []Simple{
|
list: []Simple{
|
||||||
Simple{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -63,7 +63,7 @@ func TestListEmptyPods(t *testing.T) {
|
|||||||
func TestListPods(t *testing.T) {
|
func TestListPods(t *testing.T) {
|
||||||
expectedPodList := api.PodList{
|
expectedPodList := api.PodList{
|
||||||
Items: []api.Pod{
|
Items: []api.Pod{
|
||||||
api.Pod{
|
{
|
||||||
CurrentState: api.PodState{
|
CurrentState: api.PodState{
|
||||||
Status: "Foobar",
|
Status: "Foobar",
|
||||||
},
|
},
|
||||||
@ -97,7 +97,7 @@ func TestListPods(t *testing.T) {
|
|||||||
func TestListPodsLabels(t *testing.T) {
|
func TestListPodsLabels(t *testing.T) {
|
||||||
expectedPodList := api.PodList{
|
expectedPodList := api.PodList{
|
||||||
Items: []api.Pod{
|
Items: []api.Pod{
|
||||||
api.Pod{
|
{
|
||||||
CurrentState: api.PodState{
|
CurrentState: api.PodState{
|
||||||
Status: "Foobar",
|
Status: "Foobar",
|
||||||
},
|
},
|
||||||
|
@ -189,7 +189,7 @@ func RunController(image, name string, replicas int, client client.ClientInterfa
|
|||||||
DesiredState: api.PodState{
|
DesiredState: api.PodState{
|
||||||
Manifest: api.ContainerManifest{
|
Manifest: api.ContainerManifest{
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
api.Container{
|
{
|
||||||
Image: image,
|
Image: image,
|
||||||
Ports: makePorts(portSpec),
|
Ports: makePorts(portSpec),
|
||||||
},
|
},
|
||||||
|
@ -120,8 +120,8 @@ func TestUpdateWithPods(t *testing.T) {
|
|||||||
client := FakeKubeClient{
|
client := FakeKubeClient{
|
||||||
pods: PodList{
|
pods: PodList{
|
||||||
Items: []Pod{
|
Items: []Pod{
|
||||||
Pod{JSONBase: JSONBase{ID: "pod-1"}},
|
{JSONBase: JSONBase{ID: "pod-1"}},
|
||||||
Pod{JSONBase: JSONBase{ID: "pod-2"}},
|
{JSONBase: JSONBase{ID: "pod-2"}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ func (h *HumanReadablePrinter) printHeader(columnNames []string, w io.Writer) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var lines []string
|
var lines []string
|
||||||
for _, _ = range columnNames {
|
for _ = range columnNames {
|
||||||
lines = append(lines, "----------")
|
lines = append(lines, "----------")
|
||||||
}
|
}
|
||||||
_, err := fmt.Fprintf(w, "%s\n", strings.Join(lines, "\t"))
|
_, err := fmt.Fprintf(w, "%s\n", strings.Join(lines, "\t"))
|
||||||
|
@ -270,7 +270,7 @@ func (kl *Kubelet) RunContainer(manifest *api.ContainerManifest, container *api.
|
|||||||
dockerPort := docker.Port(strconv.Itoa(interiorPort) + "/tcp")
|
dockerPort := docker.Port(strconv.Itoa(interiorPort) + "/tcp")
|
||||||
exposedPorts[dockerPort] = struct{}{}
|
exposedPorts[dockerPort] = struct{}{}
|
||||||
portBindings[dockerPort] = []docker.PortBinding{
|
portBindings[dockerPort] = []docker.PortBinding{
|
||||||
docker.PortBinding{
|
{
|
||||||
HostPort: strconv.Itoa(exteriorPort),
|
HostPort: strconv.Itoa(exteriorPort),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -172,10 +172,10 @@ func TestContainerExists(t *testing.T) {
|
|||||||
Name: "foo",
|
Name: "foo",
|
||||||
}
|
}
|
||||||
fakeDocker.containerList = []docker.APIContainers{
|
fakeDocker.containerList = []docker.APIContainers{
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"foo--qux--1234"},
|
Names: []string{"foo--qux--1234"},
|
||||||
},
|
},
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"bar--qux--1234"},
|
Names: []string{"bar--qux--1234"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -201,11 +201,11 @@ func TestGetContainerID(t *testing.T) {
|
|||||||
DockerClient: &fakeDocker,
|
DockerClient: &fakeDocker,
|
||||||
}
|
}
|
||||||
fakeDocker.containerList = []docker.APIContainers{
|
fakeDocker.containerList = []docker.APIContainers{
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"foo"},
|
Names: []string{"foo"},
|
||||||
ID: "1234",
|
ID: "1234",
|
||||||
},
|
},
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"bar"},
|
Names: []string{"bar"},
|
||||||
ID: "4567",
|
ID: "4567",
|
||||||
},
|
},
|
||||||
@ -236,10 +236,10 @@ func TestGetContainerByName(t *testing.T) {
|
|||||||
DockerClient: &fakeDocker,
|
DockerClient: &fakeDocker,
|
||||||
}
|
}
|
||||||
fakeDocker.containerList = []docker.APIContainers{
|
fakeDocker.containerList = []docker.APIContainers{
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"foo"},
|
Names: []string{"foo"},
|
||||||
},
|
},
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"bar"},
|
Names: []string{"bar"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -264,10 +264,10 @@ func TestListContainers(t *testing.T) {
|
|||||||
DockerClient: &fakeDocker,
|
DockerClient: &fakeDocker,
|
||||||
}
|
}
|
||||||
fakeDocker.containerList = []docker.APIContainers{
|
fakeDocker.containerList = []docker.APIContainers{
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"foo"},
|
Names: []string{"foo"},
|
||||||
},
|
},
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"bar"},
|
Names: []string{"bar"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -282,10 +282,10 @@ func TestKillContainerWithError(t *testing.T) {
|
|||||||
fakeDocker := FakeDockerClient{
|
fakeDocker := FakeDockerClient{
|
||||||
err: fmt.Errorf("Sample Error"),
|
err: fmt.Errorf("Sample Error"),
|
||||||
containerList: []docker.APIContainers{
|
containerList: []docker.APIContainers{
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"foo"},
|
Names: []string{"foo"},
|
||||||
},
|
},
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"bar"},
|
Names: []string{"bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -306,10 +306,10 @@ func TestKillContainer(t *testing.T) {
|
|||||||
DockerClient: &fakeDocker,
|
DockerClient: &fakeDocker,
|
||||||
}
|
}
|
||||||
fakeDocker.containerList = []docker.APIContainers{
|
fakeDocker.containerList = []docker.APIContainers{
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"foo"},
|
Names: []string{"foo"},
|
||||||
},
|
},
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"bar"},
|
Names: []string{"bar"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -325,11 +325,11 @@ func TestKillContainer(t *testing.T) {
|
|||||||
func TestSyncHTTP(t *testing.T) {
|
func TestSyncHTTP(t *testing.T) {
|
||||||
containers := api.ContainerManifest{
|
containers := api.ContainerManifest{
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
api.Container{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Image: "dockerfile/foo",
|
Image: "dockerfile/foo",
|
||||||
},
|
},
|
||||||
api.Container{
|
{
|
||||||
Name: "bar",
|
Name: "bar",
|
||||||
Image: "dockerfile/bar",
|
Image: "dockerfile/bar",
|
||||||
},
|
},
|
||||||
@ -374,8 +374,8 @@ func TestResponseToManifests(t *testing.T) {
|
|||||||
list, err := kubelet.ResponseToManifests(&etcd.Response{
|
list, err := kubelet.ResponseToManifests(&etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: util.MakeJSONString([]api.ContainerManifest{
|
Value: util.MakeJSONString([]api.ContainerManifest{
|
||||||
api.ContainerManifest{Id: "foo"},
|
{Id: "foo"},
|
||||||
api.ContainerManifest{Id: "bar"},
|
{Id: "bar"},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -508,7 +508,7 @@ func TestSyncManifestsDoesNothing(t *testing.T) {
|
|||||||
err: nil,
|
err: nil,
|
||||||
}
|
}
|
||||||
fakeDocker.containerList = []docker.APIContainers{
|
fakeDocker.containerList = []docker.APIContainers{
|
||||||
docker.APIContainers{
|
{
|
||||||
// format is <container-id>--<manifest-id>
|
// format is <container-id>--<manifest-id>
|
||||||
Names: []string{"bar--foo"},
|
Names: []string{"bar--foo"},
|
||||||
ID: "1234",
|
ID: "1234",
|
||||||
@ -521,10 +521,10 @@ func TestSyncManifestsDoesNothing(t *testing.T) {
|
|||||||
DockerClient: &fakeDocker,
|
DockerClient: &fakeDocker,
|
||||||
}
|
}
|
||||||
err := kubelet.SyncManifests([]api.ContainerManifest{
|
err := kubelet.SyncManifests([]api.ContainerManifest{
|
||||||
api.ContainerManifest{
|
{
|
||||||
Id: "foo",
|
Id: "foo",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
api.Container{Name: "bar"},
|
{Name: "bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -543,7 +543,7 @@ func TestSyncManifestsDeletes(t *testing.T) {
|
|||||||
err: nil,
|
err: nil,
|
||||||
}
|
}
|
||||||
fakeDocker.containerList = []docker.APIContainers{
|
fakeDocker.containerList = []docker.APIContainers{
|
||||||
docker.APIContainers{
|
{
|
||||||
Names: []string{"foo"},
|
Names: []string{"foo"},
|
||||||
ID: "1234",
|
ID: "1234",
|
||||||
},
|
},
|
||||||
|
@ -205,7 +205,7 @@ func (impl ConfigSourceEtcd) ProcessChange(response *etcd.Response) {
|
|||||||
parts := strings.Split(response.Node.Key[1:], "/")
|
parts := strings.Split(response.Node.Key[1:], "/")
|
||||||
if len(parts) == 4 {
|
if len(parts) == 4 {
|
||||||
log.Printf("Deleting service: %s", parts[3])
|
log.Printf("Deleting service: %s", parts[3])
|
||||||
serviceUpdate := ServiceUpdate{Op: REMOVE, Services: []api.Service{api.Service{JSONBase: api.JSONBase{ID: parts[3]}}}}
|
serviceUpdate := ServiceUpdate{Op: REMOVE, Services: []api.Service{{JSONBase: api.JSONBase{ID: parts[3]}}}}
|
||||||
impl.serviceChannel <- serviceUpdate
|
impl.serviceChannel <- serviceUpdate
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
@ -81,12 +81,12 @@ func TestListEmptyControllerList(t *testing.T) {
|
|||||||
func TestListControllerList(t *testing.T) {
|
func TestListControllerList(t *testing.T) {
|
||||||
mockRegistry := MockControllerRegistry{
|
mockRegistry := MockControllerRegistry{
|
||||||
controllers: []ReplicationController{
|
controllers: []ReplicationController{
|
||||||
ReplicationController{
|
{
|
||||||
JSONBase: JSONBase{
|
JSONBase: JSONBase{
|
||||||
ID: "foo",
|
ID: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ReplicationController{
|
{
|
||||||
JSONBase: JSONBase{
|
JSONBase: JSONBase{
|
||||||
ID: "bar",
|
ID: "bar",
|
||||||
},
|
},
|
||||||
@ -145,10 +145,10 @@ func TestControllerParsing(t *testing.T) {
|
|||||||
DesiredState: PodState{
|
DesiredState: PodState{
|
||||||
Manifest: ContainerManifest{
|
Manifest: ContainerManifest{
|
||||||
Containers: []Container{
|
Containers: []Container{
|
||||||
Container{
|
{
|
||||||
Image: "dockerfile/nginx",
|
Image: "dockerfile/nginx",
|
||||||
Ports: []Port{
|
Ports: []Port{
|
||||||
Port{
|
{
|
||||||
ContainerPort: 80,
|
ContainerPort: 80,
|
||||||
HostPort: 8080,
|
HostPort: 8080,
|
||||||
},
|
},
|
||||||
|
@ -48,7 +48,7 @@ func TestSyncEndpointsItems(t *testing.T) {
|
|||||||
serviceRegistry := MockServiceRegistry{
|
serviceRegistry := MockServiceRegistry{
|
||||||
list: ServiceList{
|
list: ServiceList{
|
||||||
Items: []Service{
|
Items: []Service{
|
||||||
Service{
|
{
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
},
|
},
|
||||||
@ -58,13 +58,13 @@ func TestSyncEndpointsItems(t *testing.T) {
|
|||||||
}
|
}
|
||||||
podRegistry := MockPodRegistry{
|
podRegistry := MockPodRegistry{
|
||||||
pods: []Pod{
|
pods: []Pod{
|
||||||
Pod{
|
{
|
||||||
DesiredState: PodState{
|
DesiredState: PodState{
|
||||||
Manifest: ContainerManifest{
|
Manifest: ContainerManifest{
|
||||||
Containers: []Container{
|
Containers: []Container{
|
||||||
Container{
|
{
|
||||||
Ports: []Port{
|
Ports: []Port{
|
||||||
Port{
|
{
|
||||||
HostPort: 8080,
|
HostPort: 8080,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -88,7 +88,7 @@ func TestSyncEndpointsPodError(t *testing.T) {
|
|||||||
serviceRegistry := MockServiceRegistry{
|
serviceRegistry := MockServiceRegistry{
|
||||||
list: ServiceList{
|
list: ServiceList{
|
||||||
Items: []Service{
|
Items: []Service{
|
||||||
Service{
|
{
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
},
|
},
|
||||||
|
@ -70,7 +70,7 @@ func TestEtcdCreatePod(t *testing.T) {
|
|||||||
DesiredState: PodState{
|
DesiredState: PodState{
|
||||||
Manifest: ContainerManifest{
|
Manifest: ContainerManifest{
|
||||||
Containers: []Container{
|
Containers: []Container{
|
||||||
Container{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -171,7 +171,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
|
|||||||
Manifest: ContainerManifest{
|
Manifest: ContainerManifest{
|
||||||
Id: "foo",
|
Id: "foo",
|
||||||
Containers: []Container{
|
Containers: []Container{
|
||||||
Container{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -205,7 +205,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
|
|||||||
E: &etcd.EtcdError{ErrorCode: 100},
|
E: &etcd.EtcdError{ErrorCode: 100},
|
||||||
}
|
}
|
||||||
fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]ContainerManifest{
|
fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]ContainerManifest{
|
||||||
ContainerManifest{
|
{
|
||||||
Id: "bar",
|
Id: "bar",
|
||||||
},
|
},
|
||||||
}), 0)
|
}), 0)
|
||||||
@ -218,7 +218,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
|
|||||||
Manifest: ContainerManifest{
|
Manifest: ContainerManifest{
|
||||||
Id: "foo",
|
Id: "foo",
|
||||||
Containers: []Container{
|
Containers: []Container{
|
||||||
Container{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -248,7 +248,7 @@ func TestEtcdDeletePod(t *testing.T) {
|
|||||||
key := "/registry/hosts/machine/pods/foo"
|
key := "/registry/hosts/machine/pods/foo"
|
||||||
fakeClient.Set(key, util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set(key, util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "foo"}}), 0)
|
||||||
fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]ContainerManifest{
|
fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]ContainerManifest{
|
||||||
ContainerManifest{
|
{
|
||||||
Id: "foo",
|
Id: "foo",
|
||||||
},
|
},
|
||||||
}), 0)
|
}), 0)
|
||||||
@ -272,8 +272,8 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
|
|||||||
key := "/registry/hosts/machine/pods/foo"
|
key := "/registry/hosts/machine/pods/foo"
|
||||||
fakeClient.Set(key, util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set(key, util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "foo"}}), 0)
|
||||||
fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]ContainerManifest{
|
fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]ContainerManifest{
|
||||||
ContainerManifest{Id: "foo"},
|
{Id: "foo"},
|
||||||
ContainerManifest{Id: "bar"},
|
{Id: "bar"},
|
||||||
}), 0)
|
}), 0)
|
||||||
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
|
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
|
||||||
err := registry.DeletePod("foo")
|
err := registry.DeletePod("foo")
|
||||||
@ -336,10 +336,10 @@ func TestEtcdListPods(t *testing.T) {
|
|||||||
R: &etcd.Response{
|
R: &etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Nodes: []*etcd.Node{
|
Nodes: []*etcd.Node{
|
||||||
&etcd.Node{
|
{
|
||||||
Value: util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "foo"}}),
|
Value: util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "foo"}}),
|
||||||
},
|
},
|
||||||
&etcd.Node{
|
{
|
||||||
Value: util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "bar"}}),
|
Value: util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "bar"}}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -392,10 +392,10 @@ func TestEtcdListControllers(t *testing.T) {
|
|||||||
R: &etcd.Response{
|
R: &etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Nodes: []*etcd.Node{
|
Nodes: []*etcd.Node{
|
||||||
&etcd.Node{
|
{
|
||||||
Value: util.MakeJSONString(ReplicationController{JSONBase: JSONBase{ID: "foo"}}),
|
Value: util.MakeJSONString(ReplicationController{JSONBase: JSONBase{ID: "foo"}}),
|
||||||
},
|
},
|
||||||
&etcd.Node{
|
{
|
||||||
Value: util.MakeJSONString(ReplicationController{JSONBase: JSONBase{ID: "bar"}}),
|
Value: util.MakeJSONString(ReplicationController{JSONBase: JSONBase{ID: "bar"}}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -499,10 +499,10 @@ func TestEtcdListServices(t *testing.T) {
|
|||||||
R: &etcd.Response{
|
R: &etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Nodes: []*etcd.Node{
|
Nodes: []*etcd.Node{
|
||||||
&etcd.Node{
|
{
|
||||||
Value: util.MakeJSONString(Service{JSONBase: JSONBase{ID: "foo"}}),
|
Value: util.MakeJSONString(Service{JSONBase: JSONBase{ID: "foo"}}),
|
||||||
},
|
},
|
||||||
&etcd.Node{
|
{
|
||||||
Value: util.MakeJSONString(Service{JSONBase: JSONBase{ID: "bar"}}),
|
Value: util.MakeJSONString(Service{JSONBase: JSONBase{ID: "bar"}}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -32,7 +32,7 @@ func TestMakeManifestNoServices(t *testing.T) {
|
|||||||
DesiredState: PodState{
|
DesiredState: PodState{
|
||||||
Manifest: ContainerManifest{
|
Manifest: ContainerManifest{
|
||||||
Containers: []Container{
|
Containers: []Container{
|
||||||
Container{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -55,7 +55,7 @@ func TestMakeManifestServices(t *testing.T) {
|
|||||||
registry := MockServiceRegistry{
|
registry := MockServiceRegistry{
|
||||||
list: ServiceList{
|
list: ServiceList{
|
||||||
Items: []Service{
|
Items: []Service{
|
||||||
Service{
|
{
|
||||||
JSONBase: JSONBase{ID: "test"},
|
JSONBase: JSONBase{ID: "test"},
|
||||||
Port: 8080,
|
Port: 8080,
|
||||||
},
|
},
|
||||||
@ -70,7 +70,7 @@ func TestMakeManifestServices(t *testing.T) {
|
|||||||
DesiredState: PodState{
|
DesiredState: PodState{
|
||||||
Manifest: ContainerManifest{
|
Manifest: ContainerManifest{
|
||||||
Containers: []Container{
|
Containers: []Container{
|
||||||
Container{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -92,7 +92,7 @@ func TestMakeManifestServicesExistingEnvVar(t *testing.T) {
|
|||||||
registry := MockServiceRegistry{
|
registry := MockServiceRegistry{
|
||||||
list: ServiceList{
|
list: ServiceList{
|
||||||
Items: []Service{
|
Items: []Service{
|
||||||
Service{
|
{
|
||||||
JSONBase: JSONBase{ID: "test"},
|
JSONBase: JSONBase{ID: "test"},
|
||||||
Port: 8080,
|
Port: 8080,
|
||||||
},
|
},
|
||||||
@ -107,9 +107,9 @@ func TestMakeManifestServicesExistingEnvVar(t *testing.T) {
|
|||||||
DesiredState: PodState{
|
DesiredState: PodState{
|
||||||
Manifest: ContainerManifest{
|
Manifest: ContainerManifest{
|
||||||
Containers: []Container{
|
Containers: []Container{
|
||||||
Container{
|
{
|
||||||
Env: []EnvVar{
|
Env: []EnvVar{
|
||||||
EnvVar{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Value: "bar",
|
Value: "bar",
|
||||||
},
|
},
|
||||||
|
@ -22,14 +22,14 @@ import (
|
|||||||
// An implementation of PodRegistry and ControllerRegistry that is backed by memory
|
// An implementation of PodRegistry and ControllerRegistry that is backed by memory
|
||||||
// Mainly used for testing.
|
// Mainly used for testing.
|
||||||
type MemoryRegistry struct {
|
type MemoryRegistry struct {
|
||||||
podData map[string]Pod
|
podData map[string]Pod
|
||||||
controllerData map[string]ReplicationController
|
controllerData map[string]ReplicationController
|
||||||
serviceData map[string]Service
|
serviceData map[string]Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeMemoryRegistry() *MemoryRegistry {
|
func MakeMemoryRegistry() *MemoryRegistry {
|
||||||
return &MemoryRegistry{
|
return &MemoryRegistry{
|
||||||
podData: map[string]Pod{},
|
podData: map[string]Pod{},
|
||||||
controllerData: map[string]ReplicationController{},
|
controllerData: map[string]ReplicationController{},
|
||||||
serviceData: map[string]Service{},
|
serviceData: map[string]Service{},
|
||||||
}
|
}
|
||||||
|
@ -85,12 +85,12 @@ func TestListEmptyPodList(t *testing.T) {
|
|||||||
func TestListPodList(t *testing.T) {
|
func TestListPodList(t *testing.T) {
|
||||||
mockRegistry := MockPodRegistry{
|
mockRegistry := MockPodRegistry{
|
||||||
pods: []Pod{
|
pods: []Pod{
|
||||||
Pod{
|
{
|
||||||
JSONBase: JSONBase{
|
JSONBase: JSONBase{
|
||||||
ID: "foo",
|
ID: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Pod{
|
{
|
||||||
JSONBase: JSONBase{
|
JSONBase: JSONBase{
|
||||||
ID: "bar",
|
ID: "bar",
|
||||||
},
|
},
|
||||||
|
@ -37,7 +37,7 @@ func makeUrl(suffix string) string {
|
|||||||
|
|
||||||
type FakePodControl struct {
|
type FakePodControl struct {
|
||||||
controllerSpec []ReplicationController
|
controllerSpec []ReplicationController
|
||||||
deletePodID []string
|
deletePodID []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakePodControl) createReplica(spec ReplicationController) {
|
func (f *FakePodControl) createReplica(spec ReplicationController) {
|
||||||
@ -57,7 +57,7 @@ func makeReplicationController(replicas int) ReplicationController {
|
|||||||
DesiredState: PodState{
|
DesiredState: PodState{
|
||||||
Manifest: ContainerManifest{
|
Manifest: ContainerManifest{
|
||||||
Containers: []Container{
|
Containers: []Container{
|
||||||
Container{
|
{
|
||||||
Image: "foo/bar",
|
Image: "foo/bar",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -182,7 +182,7 @@ func TestCreateReplica(t *testing.T) {
|
|||||||
DesiredState: PodState{
|
DesiredState: PodState{
|
||||||
Manifest: ContainerManifest{
|
Manifest: ContainerManifest{
|
||||||
Containers: []Container{
|
Containers: []Container{
|
||||||
Container{
|
{
|
||||||
Image: "foo/bar",
|
Image: "foo/bar",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -73,7 +73,7 @@ func MakeFirstFitScheduler(machines []string, registry PodRegistry, random *rand
|
|||||||
return &FirstFitScheduler{
|
return &FirstFitScheduler{
|
||||||
machines: machines,
|
machines: machines,
|
||||||
registry: registry,
|
registry: registry,
|
||||||
random: random,
|
random: random,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ func makePod(host string, hostPorts ...int) Pod {
|
|||||||
DesiredState: PodState{
|
DesiredState: PodState{
|
||||||
Manifest: ContainerManifest{
|
Manifest: ContainerManifest{
|
||||||
Containers: []Container{
|
Containers: []Container{
|
||||||
Container{
|
{
|
||||||
Ports: networkPorts,
|
Ports: networkPorts,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user