Skip to content

Commit

Permalink
Use regexp to check server version
Browse files Browse the repository at this point in the history
  • Loading branch information
heyste committed Jun 30, 2020
1 parent 878bc96 commit 469e22a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/e2e/apimachinery/get_code_version.go
Expand Up @@ -19,6 +19,7 @@ package apimachinery
import (
"k8s.io/apimachinery/pkg/version"
"k8s.io/kubernetes/test/e2e/framework"
"regexp"

"github.com/onsi/ginkgo"
)
Expand All @@ -34,11 +35,18 @@ var _ = SIGDescribe("get-code-version", func() {
framework.ExpectNoError(err, "Fail to access ServerVersion")

ginkgo.By("Confirm major version")
framework.ExpectEqual(version.Major, "1", "unable to find major version")
re := regexp.MustCompile("[1-9]")
framework.ExpectEqual(re.FindString(version.Major), version.Major, "unable to find major version")
framework.Logf("Major version: %v", version.Major)

ginkgo.By("Confirm minor version")
framework.ExpectEqual(version.Minor, "19+", "unable to find minor version")

re = regexp.MustCompile("[^0-9]+")
cleanMinorVersion := re.ReplaceAllString(version.Minor, "")
framework.Logf("cleanMinorVersion: %v", cleanMinorVersion)

re = regexp.MustCompile("[0-9]+")
framework.ExpectEqual(re.FindString(version.Minor), cleanMinorVersion, "unable to find minor version")
framework.Logf("Minor version: %v", version.Minor)
})
})

0 comments on commit 469e22a

Please sign in to comment.