Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip kubectl tests that don't work before v1.1 when running against a pre-v1.1 cluster #19608

Merged
merged 1 commit into from Feb 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 36 additions & 1 deletion test/e2e/kubectl.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/util.go
Expand Up @@ -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"}

Expand Down