Skip to content

Commit

Permalink
Add skip for channel entry loop
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrandon1 committed Dec 5, 2024
1 parent d6edc27 commit d8b0307
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/operator/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"strconv"
"strings"

"github.com/Masterminds/semver"
"github.com/redhat-best-practices-for-k8s/certsuite/tests/common"
"github.com/redhat-best-practices-for-k8s/certsuite/tests/identifiers"
"github.com/redhat-best-practices-for-k8s/certsuite/tests/operator/catalogsource"
Expand Down Expand Up @@ -456,8 +457,32 @@ func testOperatorCatalogSourceBundleCount(check *checksdb.Check, env *provider.T

const (
bundleCountLimit = 1000

// If the OCP version is <= 4.12, we need to use the probe container to get the bundle count.
// This means we cannot use the package manifests to skip based on channel.
ocpMajorVersion = 4
ocpMinorVersion = 12
)

ocp412Skip := false
// Check if the cluster is running an OCP version <= 4.12
if env.OpenshiftVersion != "" {
log.Info("Cluster is determined to be running Openshift version %q.", env.OpenshiftVersion)
version, err := semver.NewVersion(env.OpenshiftVersion)
if err != nil {
log.Error("Failed to parse Openshift version %q.", env.OpenshiftVersion)
check.LogError("Failed to parse Openshift version %q.", env.OpenshiftVersion)
return
}

if version.Major() < ocpMajorVersion || (version.Major() == ocpMajorVersion && version.Minor() <= ocpMinorVersion) {
log.Info("Cluster is running an OCP version <= 4.12.")
ocp412Skip = true
} else {
log.Info("Cluster is running an OCP version > 4.12.")
}
}

bundleCountLimitStr := strconv.Itoa(bundleCountLimit)

// Loop through all labeled operators and check if they have more than 1000 referenced images.
Expand All @@ -469,7 +494,8 @@ func testOperatorCatalogSourceBundleCount(check *checksdb.Check, env *provider.T
// Search through packagemanifests to match the name of the CSV.
for _, pm := range env.AllPackageManifests {
// Skip package manifests based on channel entries.
if catalogsource.SkipPMBasedOnChannel(pm.Status.Channels, op.Csv.Name) {
// Note: This only works for OCP versions > 4.12 due to channel entries existence.
if !ocp412Skip && catalogsource.SkipPMBasedOnChannel(pm.Status.Channels, op.Csv.Name) {
log.Debug("Skipping package manifest %q based on channel", pm.Name)
continue
}
Expand Down

0 comments on commit d8b0307

Please sign in to comment.