From 06148eda254bc94e08ef80d25160a744ff2499da Mon Sep 17 00:00:00 2001 From: Sai Harsha Kottapalli Date: Sun, 18 Oct 2020 14:18:49 +0530 Subject: [PATCH] check if kubectl version required values are empty --- test/e2e/kubectl/kubectl.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/e2e/kubectl/kubectl.go b/test/e2e/kubectl/kubectl.go index 4dc3ac93b04..eef1cf47288 100644 --- a/test/e2e/kubectl/kubectl.go +++ b/test/e2e/kubectl/kubectl.go @@ -1507,11 +1507,12 @@ metadata: Description: The command 'kubectl version' MUST return the major, minor versions, GitCommit, etc of the Client and the Server that the kubectl is configured to connect to. */ framework.ConformanceIt("should check is all data is printed ", func() { - version := framework.RunKubectlOrDie(ns, "version") - requiredItems := []string{"Client Version:", "Server Version:", "Major:", "Minor:", "GitCommit:"} + versionString := framework.RunKubectlOrDie(ns, "version") + // we expect following values for: Major -> digit, Minor -> numeric followed by an optional '+', GitCommit -> alphanumeric + requiredItems := []string{"Client Version: ", "Server Version: "} for _, item := range requiredItems { - if !strings.Contains(version, item) { - framework.Failf("Required item %s not found in %s", item, version) + if matched, _ := regexp.MatchString(item+`version.Info\{Major:"\d", Minor:"\d+\+?", GitVersion:"v\d\.\d+\.[\d\w\-\.\+]+", GitCommit:"[0-9a-f]+"`, versionString); !matched { + framework.Failf("Item %s value is not valid in %s\n", item, versionString) } } })