Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,16 @@
"lifecycle": "blocking",
"environmentSelector": {}
},
{
"name": "[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 operator installation should not block cluster upgrades if the operator's maxOCPVersion exceeds the current cluster version",
"labels": {},
"resources": {
"isolation": {}
},
"source": "openshift:payload:olmv1",
"lifecycle": "blocking",
"environmentSelector": {}
},
{
"name": "[sig-olmv1][OCPFeatureGate:NewOLMPreflightPermissionChecks][Skipped:Disconnected] OLMv1 operator preflight checks should report error when {services} are not specified",
"labels": {},
Expand Down
56 changes: 56 additions & 0 deletions openshift/tests-extension/test/olmv1-incompatible.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package test

import (
"context"
"fmt"

//nolint:staticcheck // ST1001: dot-imports for readability
. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -63,6 +64,61 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 operator installation
})
})

// nextMinorVersion returns the next OCP minor version after the current cluster version.
// OCP 4.23 and 5.0 are co-released equivalents whose only upgrade target is 5.1, so
// a cluster at 4.23 returns "5.1" rather than the naive "4.24".
func nextMinorVersion() string {
v := env.Get().OpenShiftVersion // "MAJOR.MINOR", e.g. "5.0"
var major, minor int
if _, err := fmt.Sscanf(v, "%d.%d", &major, &minor); err != nil {
Fail(fmt.Sprintf("failed to parse OpenShift version %q: %v", v, err))
}
if major == 4 && minor == 23 {
return "5.1"
}
return fmt.Sprintf("%d.%d", major, minor+1)
}

var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 operator installation", func() {
var unique, nsName, ccName, opName string
BeforeEach(func(ctx SpecContext) {
replacements := map[string]string{
"{{ TEST-BUNDLE }}": "", // Auto-filled
"{{ NAMESPACE }}": "", // Auto-filled
"{{ VERSION }}": nextMinorVersion(),

// Using the shell image provided by origin as the controller image.
// The image is mirrored into disconnected environments for testing.
"{{ TEST-CONTROLLER }}": image.ShellImage(),
}
unique, nsName, ccName, opName = helpers.NewCatalogAndClusterBundles(ctx, replacements,
catalogdata.AssetNames, catalogdata.Asset,
operatordata.AssetNames, operatordata.Asset,
)
})

AfterEach(func(ctx SpecContext) {
if CurrentSpecReport().Failed() {
By("dumping for debugging")
helpers.DescribeAllClusterCatalogs(context.Background())
helpers.DescribeAllClusterExtensions(context.Background(), nsName)
}
})

It("should not block cluster upgrades if the operator's maxOCPVersion exceeds the current cluster version", func(ctx SpecContext) {
By("waiting for InstalledOLMOperatorUpgradable to be true")
waitForOlmUpgradeStatus(ctx, operatorv1.ConditionTrue, "")

By("creating the ClusterExtension")
ceName, ceCleanup := helpers.CreateClusterExtension(opName, "", nsName, unique, helpers.WithCatalogNameSelector(ccName))
DeferCleanup(ceCleanup)
helpers.ExpectClusterExtensionToBeInstalled(ctx, ceName)

By("verifying InstalledOLMOperatorUpgradable remains true after installing the operator")
waitForOlmUpgradeStatus(ctx, operatorv1.ConditionTrue, "")
Comment on lines +108 to +118

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use the asserted condition name in progress output.

Line 109 and Line 117 say InstalledOLMOperatorUpgradable, but waitForOlmUpgradeStatus checks InstalledOLMOperatorsUpgradeable. Correcting this keeps CI timelines and failure diagnostics unambiguous.

Proposed fix
- By("waiting for InstalledOLMOperatorUpgradable to be true")
+ By("waiting for InstalledOLMOperatorsUpgradeable to be true")
...
- By("verifying InstalledOLMOperatorUpgradable remains true after installing the operator")
+ By("verifying InstalledOLMOperatorsUpgradeable remains true after installing the operator")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
It("should not block cluster upgrades if the operator's maxOCPVersion exceeds the current cluster version", func(ctx SpecContext) {
By("waiting for InstalledOLMOperatorUpgradable to be true")
waitForOlmUpgradeStatus(ctx, operatorv1.ConditionTrue, "")
By("creating the ClusterExtension")
ceName, ceCleanup := helpers.CreateClusterExtension(opName, "", nsName, unique, helpers.WithCatalogNameSelector(ccName))
DeferCleanup(ceCleanup)
helpers.ExpectClusterExtensionToBeInstalled(ctx, ceName)
By("verifying InstalledOLMOperatorUpgradable remains true after installing the operator")
waitForOlmUpgradeStatus(ctx, operatorv1.ConditionTrue, "")
It("should not block cluster upgrades if the operator's maxOCPVersion exceeds the current cluster version", func(ctx SpecContext) {
By("waiting for InstalledOLMOperatorsUpgradeable to be true")
waitForOlmUpgradeStatus(ctx, operatorv1.ConditionTrue, "")
By("creating the ClusterExtension")
ceName, ceCleanup := helpers.CreateClusterExtension(opName, "", nsName, unique, helpers.WithCatalogNameSelector(ccName))
DeferCleanup(ceCleanup)
helpers.ExpectClusterExtensionToBeInstalled(ctx, ceName)
By("verifying InstalledOLMOperatorsUpgradeable remains true after installing the operator")
waitForOlmUpgradeStatus(ctx, operatorv1.ConditionTrue, "")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openshift/tests-extension/test/olmv1-incompatible.go` around lines 108 - 118,
Update the two By progress messages in the test around waitForOlmUpgradeStatus
to use the asserted condition name, InstalledOLMOperatorsUpgradeable, matching
the condition checked by waitForOlmUpgradeStatus.

})
})

func waitForOlmUpgradeStatus(ctx SpecContext, status operatorv1.ConditionStatus, name string) {
const reasonIncompatibleOperatorsInstalled = "IncompatibleOperatorsInstalled"
const typeInstalledOLMOperatorsUpgradeable = "InstalledOLMOperatorsUpgradeable"
Expand Down