Skip to content

Commit ce108e3

Browse files
authored
fix(ci): use dynamic API version in upgrade test (#2998)
1 parent 3570b82 commit ce108e3

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

tests/e2e/e2e_upgrade_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ var _ = Describe("Operator upgrade with existing instances", func() {
4949
Expect(err).ShouldNot(HaveOccurred())
5050
EventuallyWithOffset(1, verifyControllerUp, 5*time.Minute, time.Second).WithArguments("app=rhdh-operator").Should(Succeed())
5151

52+
apiVersion, err := helper.GetBackstageCRDStorageVersion()
53+
ExpectWithOffset(1, err).NotTo(HaveOccurred(), "could not determine Backstage CRD storage version")
54+
GinkgoWriter.Printf("Using Backstage CRD API version: %s\n", apiVersion)
55+
5256
cmd = exec.Command(helper.GetPlatformTool(), "-n", ns, "apply", "-f", "-")
5357
stdin, err := cmd.StdinPipe()
5458
ExpectWithOffset(1, err).NotTo(HaveOccurred())
@@ -59,12 +63,12 @@ var _ = Describe("Operator upgrade with existing instances", func() {
5963
}
6064
}()
6165
_, _ = io.WriteString(stdin, fmt.Sprintf(`
62-
apiVersion: rhdh.redhat.com/v1alpha3
66+
apiVersion: rhdh.redhat.com/%s
6367
kind: Backstage
6468
metadata:
6569
name: my-backstage-app
6670
namespace: %s
67-
`, ns))
71+
`, apiVersion, ns))
6872
}()
6973
_, err = helper.Run(cmd)
7074
Expect(err).ShouldNot(HaveOccurred())

tests/helper/helper_backstage.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@ func GuestAuth(baseUrl string) (string, error) {
9090
return authResponse.BackstageIdentity.Token, nil
9191
}
9292

93+
// GetBackstageCRDStorageVersion returns the storage API version from the installed Backstage CRD.
94+
func GetBackstageCRDStorageVersion() (string, error) {
95+
cmd := exec.Command(GetPlatformTool(), "get", "crd", "backstages.rhdh.redhat.com",
96+
"-o", `jsonpath={.spec.versions[?(@.storage==true)].name}`) // #nosec G204
97+
out, err := Run(cmd)
98+
if err != nil {
99+
return "", fmt.Errorf("failed to get Backstage CRD storage version: %w", err)
100+
}
101+
version := strings.TrimSpace(string(out))
102+
if version == "" {
103+
return "", fmt.Errorf("no storage version found in Backstage CRD")
104+
}
105+
return version, nil
106+
}
107+
93108
func VerifyBackstagePodStatus(g Gomega, ns string, crName string, expectedStatus string) {
94109
cmd := exec.Command("kubectl", "get", "pods",
95110
"-l", "rhdh.redhat.com/app=backstage-"+crName,

0 commit comments

Comments
 (0)