From 33ac3c36ccd8bfd03c4dd6837bf2db94e8d03ea1 Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Sun, 12 Jul 2020 09:13:39 +0300 Subject: [PATCH 1/2] Add new flags for node arch --- test/e2e/framework/skipper/skipper.go | 7 +++++++ test/e2e/framework/test_context.go | 2 ++ test/e2e/framework/util.go | 10 ++++++++++ test/e2e/kubectl/BUILD | 1 + 4 files changed, 20 insertions(+) diff --git a/test/e2e/framework/skipper/skipper.go b/test/e2e/framework/skipper/skipper.go index 01c99f908ae..ff0dec92f77 100644 --- a/test/e2e/framework/skipper/skipper.go +++ b/test/e2e/framework/skipper/skipper.go @@ -213,6 +213,13 @@ func SkipUnlessNodeOSDistroIs(supportedNodeOsDistros ...string) { } } +// SkipUnlessNodeOSArchIs skips if the node OS distro is not included in the supportedNodeOsArchs. +func SkipUnlessNodeOSArchIs(supportedNodeOsArchs ...string) { + if !framework.NodeOSArchIs(supportedNodeOsArchs...) { + skipInternalf(1, "Only supported for node OS arch %v (not %s)", supportedNodeOsArchs, framework.TestContext.NodeOSArch) + } +} + // SkipIfNodeOSDistroIs skips if the node OS distro is included in the unsupportedNodeOsDistros. func SkipIfNodeOSDistroIs(unsupportedNodeOsDistros ...string) { if framework.NodeOSDistroIs(unsupportedNodeOsDistros...) { diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index ddca9d4cc11..b0a8a9f97ab 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -116,6 +116,7 @@ type TestContextType struct { ImageServiceEndpoint string MasterOSDistro string NodeOSDistro string + NodeOSArch string VerifyServiceAccount bool DeleteNamespace bool DeleteNamespaceOnFailure bool @@ -324,6 +325,7 @@ func RegisterClusterFlags(flags *flag.FlagSet) { flags.StringVar(&TestContext.Prefix, "prefix", "e2e", "A prefix to be added to cloud resources created during testing.") flags.StringVar(&TestContext.MasterOSDistro, "master-os-distro", "debian", "The OS distribution of cluster master (debian, ubuntu, gci, coreos, or custom).") flags.StringVar(&TestContext.NodeOSDistro, "node-os-distro", "debian", "The OS distribution of cluster VM instances (debian, ubuntu, gci, coreos, or custom).") + flags.StringVar(&TestContext.NodeOSArch, "node-os-arch", "amd64", "The OS architecture of cluster VM instances (amd64, arm64, or custom).") flags.StringVar(&TestContext.ClusterDNSDomain, "dns-domain", "cluster.local", "The DNS Domain of the cluster.") // TODO: Flags per provider? Rename gce-project/gce-zone? diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 1a777315063..2f8376d8e07 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -203,6 +203,16 @@ func NodeOSDistroIs(supportedNodeOsDistros ...string) bool { return false } +// NodeOSArchIs returns true if the node OS arch is included in the supportedNodeOsArchs. Otherwise false. +func NodeOSArchIs(supportedNodeOsArchs ...string) bool { + for _, arch := range supportedNodeOsArchs { + if strings.EqualFold(arch, TestContext.NodeOSArch) { + return true + } + } + return false +} + // DeleteNamespaces deletes all namespaces that match the given delete and skip filters. // Filter is by simple strings.Contains; first skip filter, then delete filter. // Returns the list of deleted namespaces or an error. diff --git a/test/e2e/kubectl/BUILD b/test/e2e/kubectl/BUILD index 22170f4ef67..362d887da74 100644 --- a/test/e2e/kubectl/BUILD +++ b/test/e2e/kubectl/BUILD @@ -39,6 +39,7 @@ go_library( "//test/e2e/framework/node:go_default_library", "//test/e2e/framework/pod:go_default_library", "//test/e2e/framework/service:go_default_library", + "//test/e2e/framework/skipper:go_default_library", "//test/e2e/framework/testfiles:go_default_library", "//test/e2e/framework/websocket:go_default_library", "//test/e2e/scheduling:go_default_library", From 5d87704ed3bb7d0b435dd55b1b2d1a2ca7cbcf9e Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Sun, 12 Jul 2020 09:15:41 +0300 Subject: [PATCH 2/2] Skip arch dependent kubectl test for non AMD64 nodes --- test/e2e/kubectl/kubectl.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/e2e/kubectl/kubectl.go b/test/e2e/kubectl/kubectl.go index 2b67fcf5ee9..ffb28c59ac1 100644 --- a/test/e2e/kubectl/kubectl.go +++ b/test/e2e/kubectl/kubectl.go @@ -69,6 +69,7 @@ import ( e2enode "k8s.io/kubernetes/test/e2e/framework/node" e2epod "k8s.io/kubernetes/test/e2e/framework/pod" e2eservice "k8s.io/kubernetes/test/e2e/framework/service" + e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper" e2etestfiles "k8s.io/kubernetes/test/e2e/framework/testfiles" "k8s.io/kubernetes/test/e2e/scheduling" testutils "k8s.io/kubernetes/test/utils" @@ -646,6 +647,10 @@ var _ = SIGDescribe("Kubectl client", func() { }) ginkgo.It("should handle in-cluster config", func() { + // TODO: Find a way to download and copy the appropriate kubectl binary, or maybe a multi-arch kubectl image + // for now this only works on amd64 + e2eskipper.SkipUnlessNodeOSArchIs("amd64") + ginkgo.By("adding rbac permissions") // grant the view permission widely to allow inspection of the `invalid` namespace and the default namespace err := e2eauth.BindClusterRole(f.ClientSet.RbacV1(), "view", f.Namespace.Name,