From 220b5e3e8e728671bb42e374f7a8e23dd0af9937 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Tue, 9 Feb 2016 15:50:07 -0800 Subject: [PATCH] Make all e2e tests use Framework --- test/e2e/cadvisor.go | 9 ++------- test/e2e/monitoring.go | 8 ++------ test/e2e/namespace.go | 16 +++------------- test/e2e/restart.go | 25 ++++++++----------------- test/e2e/ssh.go | 12 +++--------- 5 files changed, 18 insertions(+), 52 deletions(-) diff --git a/test/e2e/cadvisor.go b/test/e2e/cadvisor.go index 2553d7f31b7..df83a9b8200 100644 --- a/test/e2e/cadvisor.go +++ b/test/e2e/cadvisor.go @@ -32,16 +32,11 @@ const ( ) var _ = Describe("Cadvisor", func() { - var c *client.Client - BeforeEach(func() { - var err error - c, err = loadClient() - expectNoError(err) - }) + f := NewFramework("cadvisor") It("should be healthy on every node.", func() { - CheckCadvisorHealthOnAllNodes(c, 5*time.Minute) + CheckCadvisorHealthOnAllNodes(f.Client, 5*time.Minute) }) }) diff --git a/test/e2e/monitoring.go b/test/e2e/monitoring.go index 43f49531383..5d0e2457816 100644 --- a/test/e2e/monitoring.go +++ b/test/e2e/monitoring.go @@ -33,18 +33,14 @@ import ( // TODO: quinton: debug issue #6541 and then remove Pending flag here. var _ = Describe("[Flaky] Monitoring", func() { - var c *client.Client + f := NewFramework("monitoring") BeforeEach(func() { - var err error - c, err = loadClient() - expectNoError(err) - SkipUnlessProviderIs("gce") }) It("should verify monitoring pods and all cluster nodes are available on influxdb using heapster.", func() { - testMonitoringUsingHeapsterInfluxdb(c) + testMonitoringUsingHeapsterInfluxdb(f.Client) }) }) diff --git a/test/e2e/namespace.go b/test/e2e/namespace.go index bf8cf87b831..fd4b995e524 100644 --- a/test/e2e/namespace.go +++ b/test/e2e/namespace.go @@ -105,22 +105,12 @@ func extinguish(c *client.Client, totalNS int, maxAllowedAfterDel int, maxSecond // rate of approximately 1 per second. var _ = Describe("Namespaces [Serial]", func() { - //This namespace is modified throughout the course of the test. - var c *client.Client - var err error = nil - BeforeEach(func() { - By("Creating a kubernetes client") - c, err = loadClient() - Expect(err).NotTo(HaveOccurred()) - }) - - AfterEach(func() { - }) + f := NewFramework("namespaces") It("should delete fast enough (90 percent of 100 namespaces in 150 seconds)", - func() { extinguish(c, 100, 10, 150) }) + func() { extinguish(f.Client, 100, 10, 150) }) // On hold until etcd3; see #7372 It("should always delete fast (ALL of 100 namespaces in 150 seconds) [Feature:ComprehensiveNamespaceDraining]", - func() { extinguish(c, 100, 0, 150) }) + func() { extinguish(f.Client, 100, 0, 150) }) }) diff --git a/test/e2e/restart.go b/test/e2e/restart.go index d5e7ecbfbd4..7d88cf29453 100644 --- a/test/e2e/restart.go +++ b/test/e2e/restart.go @@ -49,37 +49,28 @@ const ( ) var _ = Describe("Restart [Disruptive]", func() { - var c *client.Client + f := NewFramework("restart") var ps *podStore - var skipped bool BeforeEach(func() { - var err error - c, err = loadClient() - Expect(err).NotTo(HaveOccurred()) - // This test requires the ability to restart all nodes, so the provider // check must be identical to that call. - skipped = true SkipUnlessProviderIs("gce", "gke") - skipped = false - ps = newPodStore(c, api.NamespaceSystem, labels.Everything(), fields.Everything()) + ps = newPodStore(f.Client, api.NamespaceSystem, labels.Everything(), fields.Everything()) }) AfterEach(func() { - if skipped { - return + if ps != nil { + ps.Stop() } - - ps.Stop() }) It("should restart all nodes and ensure all nodes and pods recover", func() { nn := testContext.CloudConfig.NumNodes By("ensuring all nodes are ready") - nodeNamesBefore, err := checkNodesReady(c, nodeReadyInitialTimeout, nn) + nodeNamesBefore, err := checkNodesReady(f.Client, nodeReadyInitialTimeout, nn) Expect(err).NotTo(HaveOccurred()) Logf("Got the following nodes before restart: %v", nodeNamesBefore) @@ -90,7 +81,7 @@ var _ = Describe("Restart [Disruptive]", func() { podNamesBefore[i] = p.ObjectMeta.Name } ns := api.NamespaceSystem - if !checkPodsRunningReady(c, ns, podNamesBefore, podReadyBeforeTimeout) { + if !checkPodsRunningReady(f.Client, ns, podNamesBefore, podReadyBeforeTimeout) { Failf("At least one pod wasn't running and ready at test start.") } @@ -99,7 +90,7 @@ var _ = Describe("Restart [Disruptive]", func() { Expect(err).NotTo(HaveOccurred()) By("ensuring all nodes are ready after the restart") - nodeNamesAfter, err := checkNodesReady(c, restartNodeReadyAgainTimeout, nn) + nodeNamesAfter, err := checkNodesReady(f.Client, restartNodeReadyAgainTimeout, nn) Expect(err).NotTo(HaveOccurred()) Logf("Got the following nodes after restart: %v", nodeNamesAfter) @@ -119,7 +110,7 @@ var _ = Describe("Restart [Disruptive]", func() { podNamesAfter, err := waitForNPods(ps, len(podNamesBefore), restartPodReadyAgainTimeout) Expect(err).NotTo(HaveOccurred()) remaining := restartPodReadyAgainTimeout - time.Since(podCheckStart) - if !checkPodsRunningReady(c, ns, podNamesAfter, remaining) { + if !checkPodsRunningReady(f.Client, ns, podNamesAfter, remaining) { Failf("At least one pod wasn't running and ready after the restart.") } }) diff --git a/test/e2e/ssh.go b/test/e2e/ssh.go index 6697a4041b5..19c665b6462 100644 --- a/test/e2e/ssh.go +++ b/test/e2e/ssh.go @@ -20,20 +20,14 @@ import ( "fmt" "strings" - client "k8s.io/kubernetes/pkg/client/unversioned" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" ) var _ = Describe("SSH", func() { - var c *client.Client + + f := NewFramework("ssh") BeforeEach(func() { - var err error - c, err = loadClient() - Expect(err).NotTo(HaveOccurred()) - // When adding more providers here, also implement their functionality in util.go's getSigner(...). SkipUnlessProviderIs(providersWithSSH...) }) @@ -41,7 +35,7 @@ var _ = Describe("SSH", func() { It("should SSH to all nodes and run commands", func() { // Get all nodes' external IPs. By("Getting all nodes' SSH-able IP addresses") - hosts, err := NodeSSHHosts(c) + hosts, err := NodeSSHHosts(f.Client) if err != nil { Failf("Error getting node hostnames: %v", err) }