From 11087d13b4207a3305c64ce51850c0954650990d Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Fri, 22 May 2015 13:03:01 -0700 Subject: [PATCH] dns test uses framework --- test/e2e/dns.go | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/test/e2e/dns.go b/test/e2e/dns.go index 61be7c030e1..0ece4af69f8 100644 --- a/test/e2e/dns.go +++ b/test/e2e/dns.go @@ -22,7 +22,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" - "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" @@ -38,25 +37,15 @@ var dnsServiceLableSelector = labels.Set{ }.AsSelector() var _ = Describe("DNS", func() { - var c *client.Client - // Use this in tests. They're unique for each test to prevent name collisions. - var testNamespace string + f := NewFramework("dns") - BeforeEach(func() { - var err error - c, err = loadClient() - Expect(err).NotTo(HaveOccurred()) - ns, err := createTestingNS("dns", c) - Expect(err).NotTo(HaveOccurred()) - testNamespace = ns.Name - }) It("should provide DNS for the cluster", func() { if providerIs("vagrant") { By("Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)") return } - podClient := c.Pods(api.NamespaceDefault) + podClient := f.Client.Pods(api.NamespaceDefault) By("Waiting for DNS Service to be Running") dnsPods, err := podClient.List(dnsServiceLableSelector, fields.Everything()) @@ -66,7 +55,7 @@ var _ = Describe("DNS", func() { if len(dnsPods.Items) != 1 { Failf("Unexpected number of pods (%d) matches the label selector %v", len(dnsPods.Items), dnsServiceLableSelector.String()) } - expectNoError(waitForPodRunning(c, dnsPods.Items[0].Name)) + expectNoError(waitForPodRunning(f.Client, dnsPods.Items[0].Name)) // All the names we need to be able to resolve. // TODO: Spin up a separate test service and test that dns works for that service. @@ -99,7 +88,7 @@ var _ = Describe("DNS", func() { }, ObjectMeta: api.ObjectMeta{ Name: "dns-test-" + string(util.NewUUID()), - Namespace: testNamespace, + Namespace: f.Namespace.Name, }, Spec: api.PodSpec{ Volumes: []api.Volume{ @@ -138,7 +127,7 @@ var _ = Describe("DNS", func() { } By("submitting the pod to kubernetes") - podClient = c.Pods(testNamespace) + podClient = f.Client.Pods(f.Namespace.Name) defer func() { By("deleting the pod") defer GinkgoRecover() @@ -148,7 +137,7 @@ var _ = Describe("DNS", func() { Failf("Failed to create %s pod: %v", pod.Name, err) } - expectNoError(waitForPodRunningInNamespace(c, pod.Name, testNamespace)) + expectNoError(f.WaitForPodRunning(pod.Name)) By("retrieving the pod") pod, err = podClient.Get(pod.Name) @@ -165,10 +154,10 @@ var _ = Describe("DNS", func() { for _, name := range namesToResolve { for _, proto := range []string{"udp", "tcp"} { testCase := fmt.Sprintf("%s@%s", proto, name) - _, err := c.Get(). + _, err := f.Client.Get(). Prefix("proxy"). Resource("pods"). - Namespace(testNamespace). + Namespace(f.Namespace.Name). Name(pod.Name). Suffix("results", testCase). Do().Raw()