Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -815,3 +815,20 @@ func TestNormalizeOCPVersion(t *testing.T) {
})
}
}

func TestSkewsStringIsDeterministic(t *testing.T) {
// The informer cache lists CSVs in map order. The condition message must not
// depend on that order, or every reorder counts as a condition transition.
a := skew{namespace: "openshift-logging", name: "cluster-logging.v6.6.1", maxOpenShiftVersion: "4.23"}
b := skew{namespace: "openshift-cluster-csi-drivers", name: "secrets-store-csi-driver-operator.v4.22.0", maxOpenShiftVersion: "5.0"}
invalid := skew{namespace: "openshift-logging", name: "broken.v1.0.0"}

expected := "ClusterServiceVersions blocking minor version upgrades to 5.1 or higher:\n" +
invalid.String() + "\n" + // error skews first
b.String() + "\n" + // then by namespace/name
a.String()

require.Equal(t, expected, skews{a, b, invalid}.String())
require.Equal(t, expected, skews{invalid, b, a}.String())
require.Equal(t, expected, skews{b, invalid, a}.String())
}
28 changes: 23 additions & 5 deletions tests-extension/pkg/bindata/qe/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion tests-extension/test/qe/specs/olmv0_custom_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ var _ = g.Describe("[sig-operator][Jira:OLM][OCPFeatureGate:OLMLifecycleAndCompa
fbcContent, err := os.ReadFile(exutil.FixturePath("testdata", "custom-schema", "index.json"))
o.Expect(err).NotTo(o.HaveOccurred())

imageRef := olmv0util.BuildCustomCatalogImage(oc, namespace, catalogName, baseImage, fbcContent)
testArch := olmv0util.GetNodeArch(oc)
e2e.Logf("test running on architecture: %s", testArch)

imageRef := olmv0util.BuildCustomCatalogImage(oc, namespace, catalogName, baseImage, testArch, fbcContent)
e2e.Logf("built catalog image: %s", imageRef)

// Register build resources for cleanup
Expand All @@ -67,6 +70,7 @@ var _ = g.Describe("[sig-operator][Jira:OLM][OCPFeatureGate:OLMLifecycleAndCompa
SourceType: "grpc",
Address: imageRef,
Template: exutil.FixturePath("testdata", "olm", "catalogsource-image.yaml"),
Arch: testArch,
}
catsrc.CreateWithCheck(oc, itName, dr)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ objects:
spec:
image: "${ADDRESS}"
grpcPodConfig:
securityContextConfig: restricted
extractContent:
catalogDir: /configs
secrets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ objects:
spec:
image: "${ADDRESS}"
grpcPodConfig:
securityContextConfig: restricted
extractContent:
cacheDir: /tmp/cache
catalogDir: /configs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ objects:
namespace: "${NAMESPACE}"
spec:
image: "${ADDRESS}"
grpcPodConfig:
securityContextConfig: restricted
secrets:
- "${SECRET}"
- "${SECRET}"
displayName: "${DISPLAYNAME}"
icon:
base64data: ""
mediatype: ""
publisher: "${PUBLISHER}"
sourceType: "${SOURCETYPE}"
updateStrategy:
updateStrategy:
registryPoll: {}
parameters:
- name: NAME
Expand All @@ -27,4 +29,4 @@ parameters:
- name: DISPLAYNAME
- name: PUBLISHER
- name: SOURCETYPE
- name: SECRET
- name: SECRET
5 changes: 5 additions & 0 deletions tests-extension/test/qe/testdata/olm/catalogsource-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ objects:
name: "${NAME}"
namespace: "${NAMESPACE}"
spec:
grpcPodConfig:
securityContextConfig: restricted
nodeSelector:
kubernetes.io/arch: "${ARCH}"
image: "${ADDRESS}"
secrets:
- "${SECRET}"
Expand All @@ -31,3 +35,4 @@ parameters:
- name: SECRET
- name: INTERVAL
value: "10m0s"
- name: ARCH
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ objects:
namespace: "${NAMESPACE}"
spec:
grpcPodConfig:
securityContextConfig: restricted
extractContent:
cacheDir: /tmp/cache
catalogDir: /configs
Expand Down
4 changes: 3 additions & 1 deletion tests-extension/test/qe/testdata/olm/cs-image-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ objects:
namespace: "${NAMESPACE}"
spec:
image: "${ADDRESS}"
grpcPodConfig:
securityContextConfig: restricted
secrets:
- "${SECRET}"
- "${SECRET}"
displayName: "${DISPLAYNAME}"
publisher: "${PUBLISHER}"
sourceType: "${SOURCETYPE}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ objects:
namespace: "${NAMESPACE}"
spec:
image: "${ADDRESS}"
grpcPodConfig:
securityContextConfig: restricted
secrets:
- "${SECRET}"
- "${SECRET}"
displayName: "${DISPLAYNAME}"
publisher: "${PUBLISHER}"
sourceType: "${SOURCETYPE}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ objects:
name: "${NAME}"
namespace: "${NAMESPACE}"
spec:
nodeSelector:
kubernetes.io/arch: "${ARCH}"
output:
to:
kind: ImageStreamTag
Expand All @@ -25,3 +27,4 @@ parameters:
- name: NAME
- name: NAMESPACE
- name: BASE_IMAGE
- name: ARCH
27 changes: 26 additions & 1 deletion tests-extension/test/qe/util/olmv0util/catalog_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package olmv0util
import (
"context"
"fmt"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -33,6 +34,25 @@ type CatalogSourceDescription struct {
Interval string // Update interval for the catalog source
ImageTemplate string // Image template for catalog updates
ClusterType string // Target cluster type (e.g., "microshift")
Arch string // Architecture for node selector
}

// Query architecture directly from a worker node's status.
// Use worker nodes specifically since BuildConfig and CatalogSource
// pods are scheduled on worker nodes.
func GetNodeArch(oc *exutil.CLI) string {
arch, err := oc.AsAdmin().WithoutNamespace().Run("get").Args(
"nodes",
"-l", "node-role.kubernetes.io/worker",
"--field-selector", "spec.unschedulable!=true",
"-o", "jsonpath={.items[0].status.nodeInfo.architecture}",
).Output()
if err == nil && len(strings.TrimSpace(arch)) > 0 {
return strings.TrimSpace(arch)
}

e2e.Logf("failed to get node architecture from cluster (%v), falling back to runtime.GOARCH (%s)", err, runtime.GOARCH)
return runtime.GOARCH
}

// Create creates a CatalogSource resource using the provided template and parameters
Expand All @@ -49,6 +69,11 @@ func (catsrc *CatalogSourceDescription) Create(oc *exutil.CLI, itName string, dr
catsrc.Interval = "10m0s"
e2e.Logf("set interval to be 10m0s")
}

if catsrc.Arch == "" {
catsrc.Arch = GetNodeArch(oc)
e2e.Logf("set catalogsource node selector arch to %s", catsrc.Arch)
}
// Choose appropriate template application function based on cluster type
applyFn := ApplyResourceFromTemplate
if strings.Compare(catsrc.ClusterType, "microshift") == 0 {
Expand All @@ -63,7 +88,7 @@ func (catsrc *CatalogSourceDescription) Create(oc *exutil.CLI, itName string, dr
err := applyFn(oc, "--ignore-unknown-parameters=true", "-f", catsrc.Template,
"-p", "NAME="+catsrc.Name, "NAMESPACE="+catsrc.Namespace, "ADDRESS="+catsrc.Address, "SECRET="+catsrc.Secret,
"DISPLAYNAME="+"\""+catsrc.DisplayName+"\"", "PUBLISHER="+"\""+catsrc.Publisher+"\"", "SOURCETYPE="+catsrc.SourceType,
"INTERVAL="+catsrc.Interval, "IMAGETEMPLATE="+imageTemplate)
"INTERVAL="+catsrc.Interval, "IMAGETEMPLATE="+imageTemplate, "ARCH="+catsrc.Arch)
o.Expect(err).NotTo(o.HaveOccurred())
// Configure security context constraints for non-microshift clusters
if strings.Compare(catsrc.ClusterType, "microshift") != 0 {
Expand Down
9 changes: 6 additions & 3 deletions tests-extension/test/qe/util/olmv0util/custom_schema_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func GetOPMBaseImage(oc *exutil.CLI) string {
// BuildConfig. It creates an ImageStream and BuildConfig, starts a binary build
// from the provided FBC content, and waits for completion.
// Returns the internal registry image reference.
func BuildCustomCatalogImage(oc *exutil.CLI, namespace, name, baseImage string, fbcContent []byte) string {
func BuildCustomCatalogImage(oc *exutil.CLI, namespace, name, baseImage, arch string, fbcContent []byte) string {
// Create ImageStream
isTemplate := exutil.FixturePath("testdata", "olm", "custom-schema-imagestream.yaml")
err := ApplyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", isTemplate,
Expand All @@ -132,11 +132,14 @@ func BuildCustomCatalogImage(oc *exutil.CLI, namespace, name, baseImage string,
e2e.Logf("created ImageStream %s/%s", namespace, name)

// Create BuildConfig
if arch == "" {
arch = GetNodeArch(oc)
}
bcTemplate := exutil.FixturePath("testdata", "olm", "custom-schema-buildconfig.yaml")
err = ApplyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", bcTemplate,
"-p", "NAME="+name, "NAMESPACE="+namespace, "BASE_IMAGE="+baseImage)
"-p", "NAME="+name, "NAMESPACE="+namespace, "BASE_IMAGE="+baseImage, "ARCH="+arch)
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("created BuildConfig %s/%s with base image %s", namespace, name, baseImage)
e2e.Logf("created BuildConfig %s/%s with base image %s for arch %s", namespace, name, baseImage, arch)

// Prepare build directory
buildDir, err := os.MkdirTemp("", "custom-schema-build-")
Expand Down
Loading