mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Ensure that e2e tests run on gce|gke and are appropriately
skipped for other cloud providers.
This commit is contained in:
		@@ -32,7 +32,7 @@ var _ = Describe("MasterCerts", func() {
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	It("should have all expected certs on the master", func() {
 | 
						It("should have all expected certs on the master", func() {
 | 
				
			||||||
		if testContext.Provider != "gce" && testContext.Provider != "gke" {
 | 
							if !providerIs("gce", "gke") {
 | 
				
			||||||
			By(fmt.Sprintf("Skipping MasterCerts test for cloud provider %s (only supported for gce and gke)", testContext.Provider))
 | 
								By(fmt.Sprintf("Skipping MasterCerts test for cloud provider %s (only supported for gce and gke)", testContext.Provider))
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,11 +57,10 @@ func bodyToJSON(body []byte) (map[string]interface{}, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// ClusterLevelLoggingWithElasticsearch is an end to end test for cluster level logging.
 | 
					// ClusterLevelLoggingWithElasticsearch is an end to end test for cluster level logging.
 | 
				
			||||||
func ClusterLevelLoggingWithElasticsearch(c *client.Client) {
 | 
					func ClusterLevelLoggingWithElasticsearch(c *client.Client) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	// TODO: For now assume we are only testing cluster logging with Elasticsearch
 | 
						// TODO: For now assume we are only testing cluster logging with Elasticsearch
 | 
				
			||||||
	// on GCE. Once we are sure that Elasticsearch cluster level logging
 | 
						// on GCE. Once we are sure that Elasticsearch cluster level logging
 | 
				
			||||||
	// works for other providers we should widen this scope of this test.
 | 
						// works for other providers we should widen this scope of this test.
 | 
				
			||||||
	if testContext.Provider != "gce" {
 | 
						if !providerIs("gce") {
 | 
				
			||||||
		Logf("Skipping cluster level logging test for provider %s", testContext.Provider)
 | 
							Logf("Skipping cluster level logging test for provider %s", testContext.Provider)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -97,11 +97,12 @@ var _ = Describe("kubectl", func() {
 | 
				
			|||||||
	Describe("guestbook", func() {
 | 
						Describe("guestbook", func() {
 | 
				
			||||||
		var guestbookPath = filepath.Join(testContext.RepoRoot, "examples/guestbook")
 | 
							var guestbookPath = filepath.Join(testContext.RepoRoot, "examples/guestbook")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if testContext.Provider != "gce" && testContext.Provider != "gke" {
 | 
					 | 
				
			||||||
			By(fmt.Sprintf("Skipping guestbook, uses createExternalLoadBalancer, a (gce|gke) feature"))
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		It("should create and stop a working application", func() {
 | 
							It("should create and stop a working application", func() {
 | 
				
			||||||
 | 
								if !providerIs("gce", "gke") {
 | 
				
			||||||
 | 
									By(fmt.Sprintf("Skipping guestbook, uses createExternalLoadBalancer, a (gce|gke) feature"))
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			defer cleanup(guestbookPath, frontendSelector, redisMasterSelector, redisSlaveSelector)
 | 
								defer cleanup(guestbookPath, frontendSelector, redisMasterSelector, redisSlaveSelector)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			By("creating all guestbook components")
 | 
								By("creating all guestbook components")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,7 +42,7 @@ var _ = Describe("Monitoring", func() {
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	It("verify monitoring pods and all cluster nodes are available on influxdb using heapster.", func() {
 | 
						It("verify monitoring pods and all cluster nodes are available on influxdb using heapster.", func() {
 | 
				
			||||||
		if testContext.Provider != "gce" {
 | 
							if !providerIs("gce") {
 | 
				
			||||||
			By(fmt.Sprintf("Skipping Monitoring test, which is only supported for provider gce (not %s)",
 | 
								By(fmt.Sprintf("Skipping Monitoring test, which is only supported for provider gce (not %s)",
 | 
				
			||||||
				testContext.Provider))
 | 
									testContext.Provider))
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,7 +57,7 @@ var _ = Describe("PD", func() {
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	It("should schedule a pod w/ a RW PD, remove it, then schedule it on another host", func() {
 | 
						It("should schedule a pod w/ a RW PD, remove it, then schedule it on another host", func() {
 | 
				
			||||||
		if testContext.Provider != "gce" && testContext.Provider != "aws" {
 | 
							if !providerIs("gce", "aws") {
 | 
				
			||||||
			By(fmt.Sprintf("Skipping PD test, which is only supported for providers gce & aws (not %s)",
 | 
								By(fmt.Sprintf("Skipping PD test, which is only supported for providers gce & aws (not %s)",
 | 
				
			||||||
				testContext.Provider))
 | 
									testContext.Provider))
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,13 +46,12 @@ var _ = Describe("ReplicationController", func() {
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	It("should serve a basic image on each replica with a private image", func() {
 | 
						It("should serve a basic image on each replica with a private image", func() {
 | 
				
			||||||
		switch testContext.Provider {
 | 
							if !providerIs("gce", "gke") {
 | 
				
			||||||
		case "gce", "gke":
 | 
					 | 
				
			||||||
			ServeImageOrFail(c, "private", "gcr.io/_b_k8s_authenticated_test/serve_hostname:1.1")
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			By(fmt.Sprintf("Skipping private variant, which is only supported for providers gce and gke (not %s)",
 | 
								By(fmt.Sprintf("Skipping private variant, which is only supported for providers gce and gke (not %s)",
 | 
				
			||||||
				testContext.Provider))
 | 
									testContext.Provider))
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							ServeImageOrFail(c, "private", "gcr.io/_b_k8s_authenticated_test/serve_hostname:1.1")
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,7 +47,7 @@ var _ = Describe("Services", func() {
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	It("should provide DNS for the cluster", func() {
 | 
						It("should provide DNS for the cluster", func() {
 | 
				
			||||||
		if testContext.Provider == "vagrant" {
 | 
							if providerIs("vagrant") {
 | 
				
			||||||
			By("Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)")
 | 
								By("Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)")
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,14 +35,6 @@ var (
 | 
				
			|||||||
var _ = Describe("Shell", func() {
 | 
					var _ = Describe("Shell", func() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	defer GinkgoRecover()
 | 
						defer GinkgoRecover()
 | 
				
			||||||
 | 
					 | 
				
			||||||
	// A number of scripts only work on gce
 | 
					 | 
				
			||||||
	if testContext.Provider != "gce" && testContext.Provider != "gke" {
 | 
					 | 
				
			||||||
		By(fmt.Sprintf("Skipping Shell test, which is only supported for provider gce and gke (not %s)",
 | 
					 | 
				
			||||||
			testContext.Provider))
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Slurp up all the tests in hack/e2e-suite
 | 
						// Slurp up all the tests in hack/e2e-suite
 | 
				
			||||||
	bashE2ERoot := filepath.Join(root, "hack/e2e-suite")
 | 
						bashE2ERoot := filepath.Join(root, "hack/e2e-suite")
 | 
				
			||||||
	files, err := ioutil.ReadDir(bashE2ERoot)
 | 
						files, err := ioutil.ReadDir(bashE2ERoot)
 | 
				
			||||||
@@ -53,6 +45,12 @@ var _ = Describe("Shell", func() {
 | 
				
			|||||||
	for _, file := range files {
 | 
						for _, file := range files {
 | 
				
			||||||
		fileName := file.Name() // Make a copy
 | 
							fileName := file.Name() // Make a copy
 | 
				
			||||||
		It(fmt.Sprintf("tests that %v passes", fileName), func() {
 | 
							It(fmt.Sprintf("tests that %v passes", fileName), func() {
 | 
				
			||||||
 | 
								// A number of scripts only work on gce
 | 
				
			||||||
 | 
								if !providerIs("gce", "gke") {
 | 
				
			||||||
 | 
									By(fmt.Sprintf("Skipping Shell test %s, which is only supported for provider gce and gke (not %s)",
 | 
				
			||||||
 | 
										fileName, testContext.Provider))
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			runCmdTest(filepath.Join(bashE2ERoot, fileName))
 | 
								runCmdTest(filepath.Join(bashE2ERoot, fileName))
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,6 +62,18 @@ func Failf(format string, a ...interface{}) {
 | 
				
			|||||||
	Fail(fmt.Sprintf(format, a...), 1)
 | 
						Fail(fmt.Sprintf(format, a...), 1)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func providerIs(providers ...string) bool {
 | 
				
			||||||
 | 
						if testContext.Provider == "" {
 | 
				
			||||||
 | 
							Fail("testContext.Provider is not defined")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						for _, provider := range providers {
 | 
				
			||||||
 | 
							if strings.ToLower(provider) == strings.ToLower(testContext.Provider) {
 | 
				
			||||||
 | 
								return true
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return false
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type podCondition func(pod *api.Pod) (bool, error)
 | 
					type podCondition func(pod *api.Pod) (bool, error)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func waitForPodCondition(c *client.Client, ns, podName, desc string, condition podCondition) error {
 | 
					func waitForPodCondition(c *client.Client, ns, podName, desc string, condition podCondition) error {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user