Skip to content

Commit 7b19170

Browse files
committed
Skip tests temporarily for the new output of the recommend cmd
We are changing the output for the cmd when CVO handles the risks from alerts OTA-1814. It will break the tests [1] that expects the old output. So we skip the tests temporarily to allow the implementation to get in and plan to re-enable them afterwords for the new output. [1]. https://prow.ci.openshift.org/view/gs/test-platform-results/logs/periodic-ci-openshift-release-main-ci-5.0-e2e-aws-ovn-techpreview-serial-2of3/2079871952771616768
1 parent c367745 commit 7b19170

1 file changed

Lines changed: 41 additions & 5 deletions

File tree

test/extended/cli/adm_upgrade/recommend.go

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
g "github.com/onsi/ginkgo/v2"
1616
o "github.com/onsi/gomega"
1717
configv1 "github.com/openshift/api/config/v1"
18+
"github.com/openshift/api/features"
19+
configv1client "github.com/openshift/client-go/config/clientset/versioned"
1820
exutil "github.com/openshift/origin/test/extended/util"
1921
"github.com/openshift/origin/test/extended/util/image"
2022
appsv1 "k8s.io/api/apps/v1"
@@ -31,7 +33,7 @@ var _ = g.Describe("[Serial][sig-cli] oc adm upgrade recommend", g.Ordered, func
3133
f := framework.NewDefaultFramework("oc-adm-upgrade-recommend")
3234
oc := exutil.NewCLIWithFramework(f).AsAdmin()
3335
var cv *configv1.ClusterVersion
34-
var restoreChannel, restoreUpstream bool
36+
var restoreChannel, restoreUpstream, alertsByCVO, isHyperShift bool
3537
var caBundleFilePath string
3638

3739
g.BeforeAll(func() {
@@ -43,6 +45,12 @@ var _ = g.Describe("[Serial][sig-cli] oc adm upgrade recommend", g.Ordered, func
4345

4446
cv, err = oc.AdminConfigClient().ConfigV1().ClusterVersions().Get(ctx, "version", metav1.GetOptions{})
4547
o.Expect(err).NotTo(o.HaveOccurred())
48+
49+
isHyperShift, err = exutil.IsHypershift(ctx, oc.AdminConfigClient())
50+
o.Expect(err).NotTo(o.HaveOccurred())
51+
52+
alertsByCVO, err = alertsEvaluatedByCVO(ctx, cv, isHyperShift, oc.AdminConfigClient())
53+
o.Expect(err).NotTo(o.HaveOccurred())
4654
})
4755

4856
g.AfterAll(func() {
@@ -121,20 +129,22 @@ No updates available. You may still upgrade to a specific release image.*`)
121129
var token string
122130

123131
g.BeforeAll(func() {
124-
isHyperShift, err := exutil.IsHypershift(ctx, oc.AdminConfigClient())
125-
o.Expect(err).NotTo(o.HaveOccurred())
126132
if isHyperShift {
127133
g.Skip("HyperShift does not support configuring the upstream OpenShift Update Service directoly via ClusterVersion (it must be configured via HostedCluster on the management cluster)")
128134
}
129135

136+
if alertsByCVO {
137+
g.Skip("Skip temporarily until the implementation lands")
138+
}
139+
130140
if curVer, err := semver.Parse(cv.Status.Desired.Version); err != nil {
131141
o.Expect(err).NotTo(o.HaveOccurred())
132142
} else {
133143
currentVersion = &curVer
134144
}
135145

136146
var buf strings.Builder
137-
err = template.Must(template.New("letter").Parse(`{
147+
err := template.Must(template.New("letter").Parse(`{
138148
"nodes": [
139149
{"version": "{{.CurrentVersion}}","payload": "{{.CurrentImage}}", "metadata": {"io.openshift.upgrades.graph.release.channels": "test-channel,other-channel"}},
140150
{"version": "4.{{.CurrentMinor}}.998","payload": "example.com/test@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
@@ -217,6 +227,8 @@ No updates available. You may still upgrade to a specific release image.*`)
217227

218228
out, err := oc.Run("--certificate-authority", caBundleFilePath, "adm", "upgrade", "recommend").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_PRECHECK", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_ACCEPT", "true").Output()
219229
o.Expect(err).NotTo(o.HaveOccurred())
230+
231+
// TODO: define the new pattern for the implementation if alertsByCVO
220232
err = matchRegexp(out, `The following conditions found no cause for concern in updating this cluster to later releases.*
221233
222234
Upstream update service: http://.*
@@ -243,7 +255,7 @@ Updates to 4[.][0-9]*:
243255
o.Expect(oc.Run("config", "set-context").Args("--current", "--user", "test").Execute()).To(o.Succeed())
244256

245257
out, err := oc.Run("--certificate-authority", caBundleFilePath, "adm", "upgrade", "recommend", "--version", fmt.Sprintf("4.%d.0", currentVersion.Minor+1), "--accept", "ConditionalUpdateRisk,Failing").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_PRECHECK", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_ACCEPT", "true").Output()
246-
258+
// TODO: expect an error to occur if alertsByCVO; the error directs the user to use `oc adm upgrade accept command`.
247259
o.Expect(err).NotTo(o.HaveOccurred())
248260
err = matchRegexp(out, `The following conditions found no cause for concern in updating this cluster to later releases.*
249261
@@ -262,6 +274,30 @@ Update to 4[.][0-9]*[.]0 has no known issues relevant to this cluster other than
262274
})
263275
})
264276

277+
// alertsEvaluatedByCVO returns true if features.FeatureGateClusterUpdateAcceptRisks is enabled, and it is not a hosted cluster
278+
// ref. https://github.com/openshift/cluster-version-operator/blob/97a5bd23f73a649f1ca8d0364eca57318f3ed274/pkg/cvo/cvo.go#L1235
279+
func alertsEvaluatedByCVO(ctx context.Context, cv *configv1.ClusterVersion, isHyperShift bool, client configv1client.Interface) (bool, error) {
280+
if isHyperShift {
281+
return false, nil
282+
}
283+
featureGate, err := client.ConfigV1().FeatureGates().Get(ctx, "cluster", metav1.GetOptions{})
284+
if err != nil {
285+
return false, err
286+
}
287+
288+
for _, fg := range featureGate.Status.FeatureGates {
289+
if fg.Version == cv.Status.Desired.Version {
290+
for _, enabledGate := range fg.Enabled {
291+
if enabledGate.Name == features.FeatureGateClusterUpdateAcceptRisks {
292+
return true, nil
293+
}
294+
}
295+
}
296+
}
297+
298+
return false, nil
299+
}
300+
265301
func runUpdateService(ctx context.Context, oc *exutil.CLI, graph string) (*url.URL, error) {
266302
deployment, err := oc.AdminKubeClient().AppsV1().Deployments(oc.Namespace()).Create(ctx,
267303
&appsv1.Deployment{

0 commit comments

Comments
 (0)