From 1d981f93452935a0cbf4a7d237270a5b79c26d66 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Fri, 30 Jan 2015 15:25:56 -0800 Subject: [PATCH] Convert load of api/examples/pod.json into native Go definition of the api.Pod This is another step in removing external dependencies of the Go e2e tests. Remove references to this file on list of files required to run e2e tests. Also use an unique name for the pod, so that failure in cleanup of a previous run should not break a new run with a name conflict. Tested by running cmd/e2e -t TestPodUpdate against an API server in GCE. --- hack/lib/golang.sh | 1 - test/e2e/pod_update.go | 32 +++++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index e0c30a1b9e..4a6598c8a6 100644 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -51,7 +51,6 @@ readonly KUBE_TEST_TARGETS=( readonly KUBE_TEST_BINARIES=("${KUBE_TEST_TARGETS[@]##*/}") readonly KUBE_TEST_BINARIES_WIN=("${KUBE_TEST_BINARIES[@]/%/.exe}") readonly KUBE_TEST_PORTABLE=( - api/examples/pod.json contrib/for-tests/network-tester/rc.json contrib/for-tests/network-tester/service.json hack/e2e.go diff --git a/test/e2e/pod_update.go b/test/e2e/pod_update.go index 0f231a9d65..4b5666d4dd 100644 --- a/test/e2e/pod_update.go +++ b/test/e2e/pod_update.go @@ -23,6 +23,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" + "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/golang/glog" . "github.com/onsi/ginkgo" @@ -32,10 +33,35 @@ import ( func TestPodUpdate(c *client.Client) bool { podClient := c.Pods(api.NamespaceDefault) - pod := loadPodOrDie(assetPath("api", "examples", "pod.json")) + name := "pod-update-" + string(util.NewUUID()) value := strconv.Itoa(time.Now().Nanosecond()) - pod.Labels["time"] = value - + pod := &api.Pod{ + ObjectMeta: api.ObjectMeta{ + Name: name, + Labels: map[string]string{ + "name": "foo", + "time": value, + }, + }, + Spec: api.PodSpec{ + Containers: []api.Container{ + { + Name: "nginx", + Image: "dockerfile/nginx", + Ports: []api.Port{{ContainerPort: 80, HostPort: 8080}}, + LivenessProbe: &api.Probe{ + Handler: api.Handler{ + HTTPGet: &api.HTTPGetAction{ + Path: "/index.html", + Port: util.NewIntOrStringFromInt(8080), + }, + }, + InitialDelaySeconds: 30, + }, + }, + }, + }, + } _, err := podClient.Create(pod) if err != nil { glog.Errorf("Failed to create pod: %v", err)