From 14e691036420a16e8bfbe1715624fc572849cf4b Mon Sep 17 00:00:00 2001 From: Isaac Hollander McCreery Date: Wed, 13 Jan 2016 11:27:40 -0800 Subject: [PATCH] Skip kubectl tests that don't work before v1.1 when running against a pre-v1.1 cluster; fixes #18581 --- test/e2e/kubectl.go | 37 ++++++++++++++++++++++++++++++++++++- test/e2e/util.go | 10 ++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/test/e2e/kubectl.go b/test/e2e/kubectl.go index 4e3976b63a..b2b7b7f1e3 100644 --- a/test/e2e/kubectl.go +++ b/test/e2e/kubectl.go @@ -46,6 +46,7 @@ import ( "k8s.io/kubernetes/pkg/kubectl/cmd/util" "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/util/wait" + "k8s.io/kubernetes/pkg/version" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -73,7 +74,27 @@ const ( runJobTimeout = 5 * time.Minute ) -var proxyRegexp = regexp.MustCompile("Starting to serve on 127.0.0.1:([0-9]+)") +var ( + proxyRegexp = regexp.MustCompile("Starting to serve on 127.0.0.1:([0-9]+)") + + // Extended pod logging options were introduced in #13780 (v1.1.0) so we don't expect tests + // that rely on extended pod logging options to work on clusters before that. + // + // TODO(ihmccreery): remove once we don't care about v1.0 anymore, (tentatively in v1.3). + extendedPodLogFilterVersion = version.MustParse("v1.1.0") + + // NodePorts were made optional in #12831 (v1.1.0) so we don't expect tests that used to + // require NodePorts but no longer include them to work on clusters before that. + // + // TODO(ihmccreery): remove once we don't care about v1.0 anymore, (tentatively in v1.3). + nodePortsOptionalVersion = version.MustParse("v1.1.0") + + // Jobs were introduced in v1.1, so we don't expect tests that rely on jobs to work on + // clusters before that. + // + // TODO(ihmccreery): remove once we don't care about v1.0 anymore, (tentatively in v1.3). + jobsVersion = version.MustParse("v1.1.0") +) var _ = Describe("Kubectl client", func() { defer GinkgoRecover() @@ -133,6 +154,8 @@ var _ = Describe("Kubectl client", func() { }) It("should create and stop a working application [Conformance]", func() { + SkipUnlessServerVersionGTE(nodePortsOptionalVersion, c) + defer cleanup(guestbookPath, ns, frontendSelector, redisMasterSelector, redisSlaveSelector) By("creating all guestbook components") @@ -409,6 +432,8 @@ var _ = Describe("Kubectl client", func() { }) It("should support inline execution and attach", func() { + SkipUnlessServerVersionGTE(jobsVersion, c) + nsFlag := fmt.Sprintf("--namespace=%v", ns) By("executing a command with run and attach with stdin") @@ -524,6 +549,8 @@ var _ = Describe("Kubectl client", func() { Describe("Kubectl describe", func() { It("should check if kubectl describe prints relevant information for rc and pods [Conformance]", func() { + SkipUnlessServerVersionGTE(nodePortsOptionalVersion, c) + mkpath := func(file string) string { return filepath.Join(testContext.RepoRoot, "examples/guestbook-go", file) } @@ -742,6 +769,8 @@ var _ = Describe("Kubectl client", func() { }) It("should be able to retrieve and filter logs [Conformance]", func() { + SkipUnlessServerVersionGTE(extendedPodLogFilterVersion, c) + forEachPod(c, ns, "app", "redis", func(pod api.Pod) { By("checking for a matching strings") _, err := lookForStringInLog(ns, pod.Name, containerName, "The server is now ready to accept connections", podStartTimeout) @@ -881,6 +910,8 @@ var _ = Describe("Kubectl client", func() { }) It("should create a job from an image when restart is OnFailure [Conformance]", func() { + SkipUnlessServerVersionGTE(jobsVersion, c) + image := "nginx" By("running the image " + image) @@ -900,6 +931,8 @@ var _ = Describe("Kubectl client", func() { }) It("should create a job from an image when restart is Never [Conformance]", func() { + SkipUnlessServerVersionGTE(jobsVersion, c) + image := "nginx" By("running the image " + image) @@ -925,6 +958,8 @@ var _ = Describe("Kubectl client", func() { jobName := "e2e-test-rm-busybox-job" It("should create a job from an image, then delete the job [Conformance]", func() { + SkipUnlessServerVersionGTE(jobsVersion, c) + By("executing a command with run --rm and attach with stdin") t := time.NewTimer(runJobTimeout) defer t.Stop() diff --git a/test/e2e/util.go b/test/e2e/util.go index 9f46f5cd23..16ae9fbdf7 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -290,6 +290,16 @@ func providerIs(providers ...string) bool { return false } +func SkipUnlessServerVersionGTE(v semver.Version, c client.ServerVersionInterface) { + gte, err := serverVersionGTE(v, c) + if err != nil { + Failf("Failed to get server version: %v", err) + } + if !gte { + Skipf("Not supported for server versions before %q", v) + } +} + // providersWithSSH are those providers where each node is accessible with SSH var providersWithSSH = []string{"gce", "gke", "aws"}