|
| 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