Skip to content

Commit ae9e67d

Browse files
committed
test/extended/cli/adm_upgrade/recommend: Service account for --version
Avoid [1]: Error running oc --namespace=e2e-oc-adm-upgrade-recommend-393 --kubeconfig=/tmp/kubeconfig-1102618529 adm upgrade recommend --version 4.21.0: StdOut> Failed to check for at least some preconditions: failed to get alerts from Thanos: no token is currently in use for this session Upstream update service: http://172.30.88.84:8000/graph ... by creating a service account so we can use token-based access for the alert-retrieval. [1]: https://prow.ci.openshift.org/view/gs/test-platform-results/pr-logs/pull/30113/pull-ci-openshift-origin-main-e2e-aws-ovn-serial-1of2/1955777594481709056
1 parent f417bb4 commit ae9e67d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

test/extended/cli/adm_upgrade/recommend.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,32 @@ Updates to 4[.][0-9]*:
198198
o.Expect(err).NotTo(o.HaveOccurred())
199199
})
200200

201-
g.It("runs successfully with conditional recommendations to the --version target", func() {
202-
out, err := oc.Run("adm", "upgrade", "recommend", "--version", fmt.Sprintf("4.%d.0", currentVersion.Minor+1)).EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_PRECHECK", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_ACCEPT", "true").Output()
201+
g.It("runs successfully with an accepted conditional recommendations to the --version target", func() {
202+
// alert retrieval requires a token-based kubeconfig to avoid:
203+
// Failed to check for at least some preconditions: failed to get alerts from Thanos: no token is currently in use for this session
204+
o.Expect(oc.Run("create").Args("serviceaccount", "test").Execute()).To(o.Succeed())
205+
o.Expect(oc.Run("create").Args("clusterrolebinding", "test", "--clusterrole=cluster-admin", fmt.Sprintf("--serviceaccount=%s:test", oc.Namespace())).Execute()).To(o.Succeed())
206+
token, err := oc.Run("create").Args("token", "test").Output()
203207
o.Expect(err).NotTo(o.HaveOccurred())
204-
err = matchRegexp(out, `Upstream update service: http://.*
208+
209+
oc.WithKubeConfigCopy(func(oc *exutil.CLI) {
210+
o.Expect(oc.Run("config", "set-credentials").Args("test", "--token", token).Execute()).To(o.Succeed())
211+
o.Expect(oc.Run("config", "set-context").Args("--current", "--user", "test").Execute()).To(o.Succeed())
212+
213+
out, err := oc.Run("adm", "upgrade", "recommend", "--version", fmt.Sprintf("4.%d.0", currentVersion.Minor+1), "--accept", "ConditionalUpdateRisk").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_PRECHECK", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_ACCEPT", "true").Output()
214+
o.Expect(err).To(o.HaveOccurred())
215+
err = matchRegexp(out, `The following conditions found no cause for concern in updating this cluster to later releases.*
216+
217+
Upstream update service: http://.*
205218
Channel: test-channel [(]available channels: other-channel, test-channel[)]
206219
207220
Update to 4[.][0-9]*[.]0 Recommended=False:
208221
Image: example.com/test@sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
209222
Release URL: https://example.com/release/4[.][0-9]*[.]0
210223
Reason: (TestRiskA|MultipleReasons)
211224
Message: (?s:.*)This is a test risk. https://example.com/testRiskA`)
212-
o.Expect(err).NotTo(o.HaveOccurred())
225+
o.Expect(err).NotTo(o.HaveOccurred())
226+
})
213227
})
214228
})
215229
})

0 commit comments

Comments
 (0)