Skip to content

Commit 26183b7

Browse files
committed
test/extended/cli/admin: Add 'oc adm upgrade recommend' smoke test
I hear that folks want something similar to the OpenShift API conditions [1]: 1. Tests must contain either [OCPFeatureGate:<FeatureGateName>] or the standard upstream [FeatureGate:<FeatureGateName>]. 2. There must be at least five tests for each FeatureGate. 3. Every test must be run on every TechPreview platform we have jobs for. (Ask for an exception if your feature doesn't support a variant.) ... before promoting command-line features to GA. Or maybe that is a condition before shifting them from alpha to beta, like [2] moving an upstream gate from IsEnabled to !IsDisabled? Anyhow, I like testing, and while in the origin suite we don't really know what, if anything, we'll find in the ClusterVersion status properties the 'recommend' command is reporting on, this commit at least runs the command to confirm it doesn't fail to execute. [1]: https://github.com/openshift/api/blob/9cbdb71c92bbae8d5939379844b8f84904806453/README.md#defining-featuregate-e2e-tests [2]: https://github.com/kubernetes/kubernetes/pull/131818/files#diff-7e82ada63a2e6664b803ac3ccdb84759ac97338ce807df63be2f81e3c9e0ba9cR362
1 parent 89c53ef commit 26183b7

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

test/extended/cli/admin.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,21 @@ var _ = g.Describe("[sig-cli] oc adm", func() {
620620
// os::test::junit::declare_suite_end
621621
})
622622

623+
var _ = g.Describe("[sig-cli][OCPFeatureGate:OCAdminUpgradeRecommend] oc adm upgrade recommend", func() {
624+
defer g.GinkgoRecover()
625+
626+
f := framework.NewDefaultFramework("oc-adm-upgrade-recommend")
627+
f.SkipNamespaceCreation = true
628+
629+
oc := exutil.NewCLIWithoutNamespace("oc-adm-upgrade-recommend").AsAdmin()
630+
631+
g.It("runs successfully, even without upstream OpenShift Update Service customization", func() {
632+
out, err := oc.Run("adm", "upgrade", "recommend").EnvironmentVariables("OC_ENABLE_CMD_UPGRADE_RECOMMEND=true").Output()
633+
o.Expect(err).NotTo(o.HaveOccurred())
634+
o.Expect(out).To(o.MatchRegexp(`FIXME: not sure what to expect so fail`))
635+
})
636+
})
637+
623638
func randomNode(oc *exutil.CLI) string {
624639
nodes, err := oc.AdminKubeClient().CoreV1().Nodes().List(context.Background(), metav1.ListOptions{})
625640
o.Expect(err).NotTo(o.HaveOccurred())

test/extended/util/annotate/generated/zz_generated.annotations.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/extended/util/client.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ type CLI struct {
9696
globalArgs []string
9797
commandArgs []string
9898
finalArgs []string
99+
environmentVariables []string
99100
namespacesToDelete []string
100101
stdin *bytes.Buffer
101102
stdout io.Writer
@@ -908,6 +909,15 @@ func (c *CLI) Args(args ...string) *CLI {
908909
return c
909910
}
910911

912+
// EnvironmentVariables sets environment variables for the OpenShift CLI command.
913+
//
914+
// With the same semantics as exec.Cmd's Env property.
915+
// https://pkg.go.dev/os/exec#Cmd
916+
func (c *CLI) EnvironmentVariables(env ...string) *CLI {
917+
c.environmentVariables = env
918+
return c
919+
}
920+
911921
func (c *CLI) printCmd() string {
912922
return strings.Join(c.finalArgs, " ")
913923
}
@@ -947,6 +957,7 @@ func (c *CLI) start(stdOutBuff, stdErrBuff *bytes.Buffer) (*exec.Cmd, error) {
947957
fmt.Printf("DEBUG: oc %s\n", c.printCmd())
948958
}
949959
cmd := exec.Command(c.execPath, c.finalArgs...)
960+
cmd.Env = c.environmentVariables
950961
cmd.Stdin = c.stdin
951962
// Redact any bearer token information from the log.
952963
framework.Logf("Running '%s %s'", c.execPath, RedactBearerToken(strings.Join(c.finalArgs, " ")))

0 commit comments

Comments
 (0)