k8s.io/kubernetes@v1.29.3/test/e2e/apimachinery/server_version.go (about) 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 "context" 21 "regexp" 22 23 "k8s.io/apimachinery/pkg/version" 24 "k8s.io/kubernetes/test/e2e/framework" 25 admissionapi "k8s.io/pod-security-admission/api" 26 27 "github.com/onsi/ginkgo/v2" 28 "github.com/onsi/gomega" 29 ) 30 31 var _ = SIGDescribe("server version", func() { 32 f := framework.NewDefaultFramework("server-version") 33 f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged 34 35 /* 36 Release: v1.19 37 Testname: Confirm a server version 38 Description: Ensure that an API server version can be retrieved. 39 Both the major and minor versions MUST only be an integer. 40 */ 41 framework.ConformanceIt("should find the server version", func(ctx context.Context) { 42 43 ginkgo.By("Request ServerVersion") 44 45 var version *version.Info 46 version, err := f.ClientSet.Discovery().ServerVersion() 47 framework.ExpectNoError(err, "Fail to access ServerVersion") 48 49 ginkgo.By("Confirm major version") 50 re := regexp.MustCompile("[1-9]") 51 gomega.Expect(re.FindString(version.Major)).To(gomega.Equal(version.Major), "unable to find major version") 52 framework.Logf("Major version: %v", version.Major) 53 54 ginkgo.By("Confirm minor version") 55 56 re = regexp.MustCompile("[^0-9]+") 57 cleanMinorVersion := re.ReplaceAllString(version.Minor, "") 58 framework.Logf("cleanMinorVersion: %v", cleanMinorVersion) 59 60 re = regexp.MustCompile("[0-9]+") 61 gomega.Expect(re.FindString(version.Minor)).To(gomega.Equal(cleanMinorVersion), "unable to find minor version") 62 framework.Logf("Minor version: %v", version.Minor) 63 }) 64 })