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
48 changes: 48 additions & 0 deletions test/cvo/cvo.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,52 @@ var _ = g.Describe(`[Jira:"Cluster Version Operator"] cluster-version-operator`,
sccAnnotation := cvoPod.Annotations["openshift.io/scc"]
o.Expect(sccAnnotation).To(o.Equal("hostaccess"), "Expected the annotation 'openshift.io/scc annotation' on pod %s to have the value 'hostaccess', but got %s", cvoPod.Name, sccAnnotation)
})

/*// Migrated from case NonHyperShiftHOST-Author:dis-High-OCP-33876-Clusterversion status has metadata stored
g.It("Clusterversion status has metadata stored", func() {
ctx := context.Background()
err := util.SkipIfHypershift(ctx, restCfg)
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to determine if cluster is HyperShift")
err = util.SkipIfMicroshift(ctx, restCfg)
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to determine if cluster is MicroShift")

g.By("Checking that the Clusterversion status has metadata stored")
clusterversion, err := kubeClient.ConfigV1().ClusterVersions().Get(ctx, "version", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to get Clusterversion")
})*/

// Migrated from case NonHyperShiftHOST-Author:dis-Medium-OCP-54887-The default channel should be corret
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix typos in migrated case text and log message.

Line 116 has “corret”, and Line 148 has “Deafault”; these should be corrected for clarity in test output/logs.

✏️ Proposed wording fix
-	// Migrated from case NonHyperShiftHOST-Author:dis-Medium-OCP-54887-The default channel should be corret
+	// Migrated from case NonHyperShiftHOST-Author:dis-Medium-OCP-54887-The default channel should be correct
...
-		logger.Info("Deafault channel for version is correct", "version:", version, "channel:", channel)
+		logger.Info("Default channel for version is correct", "version:", version, "channel:", channel)

Also applies to: 148-148

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/cvo/cvo.go` at line 116, Fix the typos in the migrated test text and log
message: locate the comment/string containing
"NonHyperShiftHOST-Author:dis-Medium-OCP-54887-The default channel should be
corret" and change "corret" to "correct", and locate the log/test message
containing the misspelled "Deafault" and change it to "Default" so the test
output and logs read correctly.

g.It("The default channel should be correct", func() {
ctx := context.Background()
err := util.SkipIfHypershift(ctx, restCfg)
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to determine if cluster is HyperShift")
err = util.SkipIfMicroshift(ctx, restCfg)
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to determine if cluster is MicroShift")

g.By("Checking that the default channel matches the cluster version")
configClient, err := util.GetConfigClient(restCfg)
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to create config client")
clusterversion, err := configClient.ConfigV1().ClusterVersions().Get(ctx, "version", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to get Clusterversion")

g.By("Extracting version details from ClusterVersion status")
o.Expect(clusterversion.Status.Desired.Version).NotTo(o.BeEmpty(), "ClusterVersion desired version should not be empty")
version := clusterversion.Status.Desired.Version
logger.Info("Cluster version detected", "version", version)

g.By("Verifying the cluster is using a signed build")
o.Expect(clusterversion.Status.History).NotTo(o.BeEmpty(), "ClusterVersion history should not be empty")
currentUpdate := clusterversion.Status.History[0]
o.Expect(currentUpdate.Verified).To(o.BeTrue(), "Expected the cluster build to be signed and verified, but Verified is false. Version: %s, Image: %s", currentUpdate.Version, currentUpdate.Image)
logger.Info("Cluster build is verified", "version", currentUpdate.Version, "image", currentUpdate.Image, "verified", currentUpdate.Verified)

g.By("Validating default channel format matches stable-<major>.<minor>")
channel := clusterversion.Spec.Channel
o.Expect(channel).To(o.MatchRegexp(`^stable-\d+\.\d+$`), "Expected channel to match pattern 'stable-<major>.<minor>', but got %s", channel)

g.By("Verifying channel matches the cluster's major.minor version")
expectedChannelPrefix := util.GetExpectedChannelPrefix(version)
o.Expect(channel).To(o.Equal(expectedChannelPrefix), "Expected channel to be %s based on version %s, but got %s", expectedChannelPrefix, version, channel)
logger.Info("Deafault channel for version is correct", "version:", version, "channel:", channel)
})
})
16 changes: 16 additions & 0 deletions test/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,20 @@ func SkipIfNetworkRestricted(ctx context.Context, restConfig *rest.Config, urls
g.Skip("This test is skipped because the network is restricted")
}
return nil

}

// GetExpectedChannelPrefix extracts the major.minor version from a full version string
// and returns the expected channel prefix in the format "stable-<major>.<minor>"
// Example: "4.22.0-rc.0" -> "stable-4.22"
func GetExpectedChannelPrefix(version string) string {
// Parse semantic version to extract major.minor
// Version format is typically: major.minor.patch or major.minor.patch-prerelease
var major, minor int
_, err := fmt.Sscanf(version, "%d.%d", &major, &minor)
if err != nil {
// If parsing fails, return empty string
return ""
}
return fmt.Sprintf("stable-%d.%d", major, minor)
}