Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/e2e/e2e_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ var _ = Describe("Operator upgrade with existing instances", func() {
Expect(err).ShouldNot(HaveOccurred())
EventuallyWithOffset(1, verifyControllerUp, 5*time.Minute, time.Second).WithArguments("app=rhdh-operator").Should(Succeed())

apiVersion, err := helper.GetBackstageCRDStorageVersion()
ExpectWithOffset(1, err).NotTo(HaveOccurred(), "could not determine Backstage CRD storage version")
GinkgoWriter.Printf("Using Backstage CRD API version: %s\n", apiVersion)

cmd = exec.Command(helper.GetPlatformTool(), "-n", ns, "apply", "-f", "-")
stdin, err := cmd.StdinPipe()
ExpectWithOffset(1, err).NotTo(HaveOccurred())
Expand All @@ -59,12 +63,12 @@ var _ = Describe("Operator upgrade with existing instances", func() {
}
}()
_, _ = io.WriteString(stdin, fmt.Sprintf(`
apiVersion: rhdh.redhat.com/v1alpha3
apiVersion: rhdh.redhat.com/%s
kind: Backstage
metadata:
name: my-backstage-app
namespace: %s
`, ns))
`, apiVersion, ns))
}()
_, err = helper.Run(cmd)
Expect(err).ShouldNot(HaveOccurred())
Expand Down
15 changes: 15 additions & 0 deletions tests/helper/helper_backstage.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ func GuestAuth(baseUrl string) (string, error) {
return authResponse.BackstageIdentity.Token, nil
}

// GetBackstageCRDStorageVersion returns the storage API version from the installed Backstage CRD.
func GetBackstageCRDStorageVersion() (string, error) {
cmd := exec.Command(GetPlatformTool(), "get", "crd", "backstages.rhdh.redhat.com",
"-o", `jsonpath={.spec.versions[?(@.storage==true)].name}`) // #nosec G204
out, err := Run(cmd)
if err != nil {
return "", fmt.Errorf("failed to get Backstage CRD storage version: %w", err)
}
version := strings.TrimSpace(string(out))
if version == "" {
return "", fmt.Errorf("no storage version found in Backstage CRD")
}
return version, nil
}

func VerifyBackstagePodStatus(g Gomega, ns string, crName string, expectedStatus string) {
cmd := exec.Command("kubectl", "get", "pods",
"-l", "rhdh.redhat.com/app=backstage-"+crName,
Expand Down
Loading