Skip to content

Commit 343995e

Browse files
authored
Merge pull request kubernetes#92532 from ii/heyste-get-code-version-test
Create checkServerVersion Test - 1 Endpoint Coverage
2 parents 2585d78 + e7f603c commit 343995e

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

test/e2e/apimachinery/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ go_library(
2424
"namespace.go",
2525
"protocol.go",
2626
"resource_quota.go",
27+
"server_version.go",
2728
"table_conversion.go",
2829
"watch.go",
2930
"webhook.go",
@@ -64,6 +65,7 @@ go_library(
6465
"//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
6566
"//staging/src/k8s.io/apimachinery/pkg/util/version:go_default_library",
6667
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
68+
"//staging/src/k8s.io/apimachinery/pkg/version:go_default_library",
6769
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
6870
"//staging/src/k8s.io/apiserver/pkg/endpoints/discovery:go_default_library",
6971
"//staging/src/k8s.io/apiserver/pkg/features:go_default_library",
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package apimachinery
18+
19+
import (
20+
"k8s.io/apimachinery/pkg/version"
21+
"k8s.io/kubernetes/test/e2e/framework"
22+
"regexp"
23+
24+
"github.com/onsi/ginkgo"
25+
)
26+
27+
var _ = SIGDescribe("server version", func() {
28+
f := framework.NewDefaultFramework("server-version")
29+
ginkgo.It("should find the server version", func() {
30+
31+
ginkgo.By("Request ServerVersion")
32+
33+
var version *version.Info
34+
version, err := f.ClientSet.Discovery().ServerVersion()
35+
framework.ExpectNoError(err, "Fail to access ServerVersion")
36+
37+
ginkgo.By("Confirm major version")
38+
re := regexp.MustCompile("[1-9]")
39+
framework.ExpectEqual(re.FindString(version.Major), version.Major, "unable to find major version")
40+
framework.Logf("Major version: %v", version.Major)
41+
42+
ginkgo.By("Confirm minor version")
43+
44+
re = regexp.MustCompile("[^0-9]+")
45+
cleanMinorVersion := re.ReplaceAllString(version.Minor, "")
46+
framework.Logf("cleanMinorVersion: %v", cleanMinorVersion)
47+
48+
re = regexp.MustCompile("[0-9]+")
49+
framework.ExpectEqual(re.FindString(version.Minor), cleanMinorVersion, "unable to find minor version")
50+
framework.Logf("Minor version: %v", version.Minor)
51+
})
52+
})

0 commit comments

Comments
 (0)