From a74fce5bd7347edeec79c06420a7de8eb77745c7 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Fri, 30 Jan 2015 13:15:38 -0800 Subject: [PATCH] Convert load of test/e2e/pod.json into native Go definition of the api.Pod This is another step in removing external dependencies of the Go e2e tests. Also remove other references to this file. Tested by running cmd/e2e -t TestKubeletSendsEvent against an API server in GCE. --- hack/lib/golang.sh | 1 - test/e2e/kubelet_sends_events.go | 23 ++++++++++++++++++++--- test/e2e/pod.json | 23 ----------------------- 3 files changed, 20 insertions(+), 27 deletions(-) delete mode 100644 test/e2e/pod.json diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index d7a9bbb7486..e0c30a1b9ea 100644 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -52,7 +52,6 @@ readonly KUBE_TEST_BINARIES=("${KUBE_TEST_TARGETS[@]##*/}") readonly KUBE_TEST_BINARIES_WIN=("${KUBE_TEST_BINARIES[@]/%/.exe}") readonly KUBE_TEST_PORTABLE=( api/examples/pod.json - test/e2e/pod.json contrib/for-tests/network-tester/rc.json contrib/for-tests/network-tester/service.json hack/e2e.go diff --git a/test/e2e/kubelet_sends_events.go b/test/e2e/kubelet_sends_events.go index 2b9da6b428c..b0eb0c47cab 100644 --- a/test/e2e/kubelet_sends_events.go +++ b/test/e2e/kubelet_sends_events.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" @@ -39,10 +40,26 @@ func TestKubeletSendsEvent(c *client.Client) bool { podClient := c.Pods(api.NamespaceDefault) - pod := loadPodOrDie(assetPath("test", "e2e", "pod.json")) + name := "send-events-" + 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: "p", + Image: "kubernetes/serve_hostname", + Ports: []api.Port{{ContainerPort: 80, HostPort: 8080}}, + }, + }, + }, + } _, err := podClient.Create(pod) if err != nil { glog.Errorf("Failed to create pod: %v", err) diff --git a/test/e2e/pod.json b/test/e2e/pod.json deleted file mode 100644 index d6cc38eac82..00000000000 --- a/test/e2e/pod.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "kind": "Pod", - "apiVersion": "v1beta1", - "id": "p", - "desiredState": { - "manifest": { - "version": "v1beta1", - "id": "p", - "containers": [{ - "name": "p", - "image": "kubernetes/serve_hostname", - "ports": [{ - "containerPort": 80, - "hostPort": 8080 - }], - }] - } - }, - "labels": { - "name": "foo" - } -} -