operators: properly skip OLM test on arm64
e2e.NodeOSArchIs and friends do not detect the node arch automatically.
package operators
import (
+ "context"
"encoding/json"
"fmt"
"path/filepath"
@@ -11,8 +12,8 @@ import (
o "github.com/onsi/gomega"
exutil "github.com/openshift/origin/test/extended/util"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
e2e "k8s.io/kubernetes/test/e2e/framework"
- e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
)
var _ = g.Describe("[sig-operator] OLM should", func() {
@@ -153,6 +154,25 @@ var _ = g.Describe("[sig-arch] ocp payload should be based on existing source",
})
})
+func archHasDefaultIndex(oc *exutil.CLI) bool {
+ workerNodes, err := oc.AsAdmin().KubeClient().CoreV1().Nodes().List(context.Background(), metav1.ListOptions{LabelSelector: "node-role.kubernetes.io/worker"})
+ if err != nil {
+ e2e.Logf("problem getting nodes for arch check: %s", err)
+ }
+ for _, node := range workerNodes.Items {
+ switch node.Status.NodeInfo.Architecture {
+ case "amd64":
+ return true
+ case "ppc64le":
+ return true
+ case "s390x":
+ return true
+ default:
+ }
+ }
+ return false
+}
+
func hasRedHatOperatorsSource(oc *exutil.CLI) (bool, error) {
spec, err := oc.AsAdmin().Run("get").Args("operatorhub/cluster", "-o=jsonpath={.spec}").Output()
if err != nil {
@@ -172,7 +192,7 @@ func hasRedHatOperatorsSource(oc *exutil.CLI) (bool, error) {
return true, fmt.Errorf("Error unmarshalling operatorhub spec: %s", spec)
}
// Check if default hub sources are used
- if len(parsed.Sources) == 0 && !parsed.DisableAllDefaultSources {
+ if len(parsed.Sources) == 0 && !parsed.DisableAllDefaultSources && archHasDefaultIndex(oc) {
return true, nil
}
@@ -209,11 +229,6 @@ var _ = g.Describe("[sig-operator] an end user can use OLM", func() {
g.Skip("redhat-operators source not found in enabled sources")
}
- // TODO: Come up with an arch agnostic operator to deploy during this test.
- // For now this does not work for arm64
- if e2e.NodeOSArchIs("arm64") {
- e2eskipper.Skipf("Not supported for node OS distro %v (is arm64)", e2e.TestContext.NodeOSDistro)
- }
// configure OperatorGroup before tests
configFile, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", operatorGroup, "-p", "NAME=test-operator", fmt.Sprintf("NAMESPACE=%s", oc.Namespace())).OutputToFile("config.json")
o.Expect(err).NotTo(o.HaveOccurred())
