From 64955959e644789de248f8963dfdadf1bbaa462c Mon Sep 17 00:00:00 2001 From: Jing Xu Date: Tue, 15 Nov 2016 14:46:35 -0800 Subject: [PATCH 1/2] Enable NFSv4 and GlusterFS tests on cluster e2e tests Enable NFSv4 and GlusterFS tests on cluster e2e tests for GCI images only. --- test/e2e/common/volumes.go | 40 +++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/test/e2e/common/volumes.go b/test/e2e/common/volumes.go index 9a503b2bd8..510124b322 100644 --- a/test/e2e/common/volumes.go +++ b/test/e2e/common/volumes.go @@ -353,7 +353,7 @@ var _ = framework.KubeDescribe("GCP Volumes", func() { var namespace *api.Namespace BeforeEach(func() { - if !isTestEnabled() { + if !isTestEnabled(f.ClientSet) { framework.Skipf("NFS tests are not supported for this distro") } namespace = f.Namespace @@ -468,24 +468,32 @@ var _ = framework.KubeDescribe("GCP Volumes", func() { }) }) -func isTestEnabled() bool { - // TODO(timstclair): Pass this through the image setup rather than hardcoding. - if strings.Contains(framework.TestContext.NodeName, "-gci-dev-") { - gciVersionRe := regexp.MustCompile("-gci-dev-([0-9]+)-") - matches := gciVersionRe.FindStringSubmatch(framework.TestContext.NodeName) - if len(matches) == 2 { - version, err := strconv.Atoi(matches[1]) - if err != nil { - glog.Errorf("Error parsing GCI version from NodeName %q: %v", framework.TestContext.NodeName, err) - return false +func isTestEnabled(c clientset.Interface) bool { + // Enable the test If the node image is GCI. (this check only works for node e2e test) + nodeName := framework.TestContext.NodeName + if nodeName != "" { + if strings.Contains(nodeName, "-gci-dev-") { + gciVersionRe := regexp.MustCompile("-gci-dev-([0-9]+)-") + matches := gciVersionRe.FindStringSubmatch(framework.TestContext.NodeName) + if len(matches) == 2 { + version, err := strconv.Atoi(matches[1]) + if err != nil { + glog.Errorf("Error parsing GCI version from NodeName %q: %v", nodeName, err) + return false + } + return version >= 54 } - return version >= 54 } return false } - // Disable tests for containvm - if strings.Contains(framework.TestContext.NodeName, "-containervm-") { - //return true + + // For cluster e2e test, because nodeName is empty, retrieve the node objects from api server + // and check their images. Only run NFSv4 and GlusterFS if nodes are using GCI image for now. + nodes := framework.GetReadySchedulableNodesOrDie(c) + for _, node := range nodes.Items { + if !strings.Contains(node.Status.NodeInfo.OSImage, "Google Container-VM") { + return false + } } - return false + return true } From afbf5f52e5191db6ba8795d83237aba0ee433b9a Mon Sep 17 00:00:00 2001 From: Jing Xu Date: Wed, 16 Nov 2016 10:04:12 -0800 Subject: [PATCH 2/2] Update volumes.go --- test/e2e/common/volumes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/common/volumes.go b/test/e2e/common/volumes.go index 510124b322..57ebe961dd 100644 --- a/test/e2e/common/volumes.go +++ b/test/e2e/common/volumes.go @@ -469,7 +469,7 @@ var _ = framework.KubeDescribe("GCP Volumes", func() { }) func isTestEnabled(c clientset.Interface) bool { - // Enable the test If the node image is GCI. (this check only works for node e2e test) + // Enable the test on node e2e if the node image is GCI. nodeName := framework.TestContext.NodeName if nodeName != "" { if strings.Contains(nodeName, "-gci-dev-") {