Merge pull request #92532 from ii/heyste-get-code-version-test

Create checkServerVersion Test - 1 Endpoint Coverage
This commit is contained in:
Kubernetes Prow Robot 2020-07-01 23:13:17 -07:00 committed by GitHub
commit 343995e8e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 0 deletions

View File

@ -24,6 +24,7 @@ go_library(
"namespace.go",
"protocol.go",
"resource_quota.go",
"server_version.go",
"table_conversion.go",
"watch.go",
"webhook.go",
@ -64,6 +65,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/version:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/version:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/endpoints/discovery:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/features:go_default_library",

View File

@ -0,0 +1,52 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package apimachinery
import (
"k8s.io/apimachinery/pkg/version"
"k8s.io/kubernetes/test/e2e/framework"
"regexp"
"github.com/onsi/ginkgo"
)
var _ = SIGDescribe("server version", func() {
f := framework.NewDefaultFramework("server-version")
ginkgo.It("should find the server version", func() {
ginkgo.By("Request ServerVersion")
var version *version.Info
version, err := f.ClientSet.Discovery().ServerVersion()
framework.ExpectNoError(err, "Fail to access ServerVersion")
ginkgo.By("Confirm 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")
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)
})
})