Skip to content

Commit 811b2f6

Browse files
committed
add test OCP-54887
1 parent ffe4646 commit 811b2f6

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

test/cvo/cvo.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,52 @@ var _ = g.Describe(`[Jira:"Cluster Version Operator"] cluster-version-operator`,
9999
sccAnnotation := cvoPod.Annotations["openshift.io/scc"]
100100
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)
101101
})
102+
103+
/*// Migrated from case NonHyperShiftHOST-Author:dis-High-OCP-33876-Clusterversion status has metadata stored
104+
g.It("Clusterversion status has metadata stored", func() {
105+
ctx := context.Background()
106+
err := util.SkipIfHypershift(ctx, restCfg)
107+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to determine if cluster is HyperShift")
108+
err = util.SkipIfMicroshift(ctx, restCfg)
109+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to determine if cluster is MicroShift")
110+
111+
g.By("Checking that the Clusterversion status has metadata stored")
112+
clusterversion, err := kubeClient.ConfigV1().ClusterVersions().Get(ctx, "version", metav1.GetOptions{})
113+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to get Clusterversion")
114+
})*/
115+
116+
// Migrated from case NonHyperShiftHOST-Author:dis-Medium-OCP-54887-The default channel should be corret
117+
g.It("The default channel should be correct", func() {
118+
ctx := context.Background()
119+
err := util.SkipIfHypershift(ctx, restCfg)
120+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to determine if cluster is HyperShift")
121+
err = util.SkipIfMicroshift(ctx, restCfg)
122+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to determine if cluster is MicroShift")
123+
124+
g.By("Checking that the default channel matches the cluster version")
125+
configClient, err := util.GetConfigClient(restCfg)
126+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to create config client")
127+
clusterversion, err := configClient.ConfigV1().ClusterVersions().Get(ctx, "version", metav1.GetOptions{})
128+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to get Clusterversion")
129+
130+
g.By("Extracting version details from ClusterVersion status")
131+
o.Expect(clusterversion.Status.Desired.Version).NotTo(o.BeEmpty(), "ClusterVersion desired version should not be empty")
132+
version := clusterversion.Status.Desired.Version
133+
logger.Info("Cluster version detected", "version", version)
134+
135+
g.By("Verifying the cluster is using a signed build")
136+
o.Expect(clusterversion.Status.History).NotTo(o.BeEmpty(), "ClusterVersion history should not be empty")
137+
currentUpdate := clusterversion.Status.History[0]
138+
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)
139+
logger.Info("Cluster build is verified", "version", currentUpdate.Version, "image", currentUpdate.Image, "verified", currentUpdate.Verified)
140+
141+
g.By("Validating default channel format matches stable-<major>.<minor>")
142+
channel := clusterversion.Spec.Channel
143+
o.Expect(channel).To(o.MatchRegexp(`^stable-\d+\.\d+$`), "Expected channel to match pattern 'stable-<major>.<minor>', but got %s", channel)
144+
145+
g.By("Verifying channel matches the cluster's major.minor version")
146+
expectedChannelPrefix := util.GetExpectedChannelPrefix(version)
147+
o.Expect(channel).To(o.Equal(expectedChannelPrefix), "Expected channel to be %s based on version %s, but got %s", expectedChannelPrefix, version, channel)
148+
logger.Info("Deafault channel for version is correct", "version:", version, "channel:", channel)
149+
})
102150
})

test/util/util.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package util
22

33
import (
44
"context"
5+
"fmt"
56
"time"
67

78
g "github.com/onsi/ginkgo/v2"
@@ -135,3 +136,18 @@ const (
135136
// fauxinnati mocks Cincinnati Update Graph Server for OpenShift
136137
FauxinnatiAPIURL = "https://fauxinnati-fauxinnati.apps.ota-stage.q2z4.p1.openshiftapps.com/api/upgrades_info/graph"
137138
)
139+
140+
// GetExpectedChannelPrefix extracts the major.minor version from a full version string
141+
// and returns the expected channel prefix in the format "stable-<major>.<minor>"
142+
// Example: "4.22.0-rc.0" -> "stable-4.22"
143+
func GetExpectedChannelPrefix(version string) string {
144+
// Parse semantic version to extract major.minor
145+
// Version format is typically: major.minor.patch or major.minor.patch-prerelease
146+
var major, minor int
147+
_, err := fmt.Sscanf(version, "%d.%d", &major, &minor)
148+
if err != nil {
149+
// If parsing fails, return empty string
150+
return ""
151+
}
152+
return fmt.Sprintf("stable-%d.%d", major, minor)
153+
}

0 commit comments

Comments
 (0)