From 83d04034cda415abccf598e651479a48d1a8a5a8 Mon Sep 17 00:00:00 2001 From: Jordan Keister Date: Thu, 6 Jul 2023 09:44:01 -0500 Subject: [PATCH] use env vars for possible e2e test image substitution (#289) Signed-off-by: Jordan Keister --- test/e2e/e2e_suite_test.go | 16 +++++++++++++--- test/e2e/install_test.go | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index c3479e193..d5dc9d4e0 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -2,6 +2,7 @@ package e2e import ( "context" + "os" "testing" "time" @@ -30,10 +31,19 @@ var ( ) const ( - testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e" - testCatalogName = "test-catalog" + testCatalogRefEnvVar = "TEST_CATALOG_IMAGE" + testCatalogRefDefault = "localhost/testdata/catalogs/test-catalog:e2e" + testCatalogName = "test-catalog" ) +// returns the image reference for the test, checking for environment variable substitution, with a default of localhost/testdata/catalogs/test-catalog:e2e +func getCatalogImageRef() string { + if s := os.Getenv(testCatalogRefEnvVar); s != "" { + return s + } + return testCatalogRefDefault +} + func TestE2E(t *testing.T) { RegisterFailHandler(Fail) SetDefaultEventuallyTimeout(1 * time.Minute) @@ -55,7 +65,7 @@ var _ = BeforeSuite(func() { Expect(err).To(Not(HaveOccurred())) ctx := context.Background() - operatorCatalog, err = createTestCatalog(ctx, testCatalogName, testCatalogRef) + operatorCatalog, err = createTestCatalog(ctx, testCatalogName, getCatalogImageRef()) Expect(err).ToNot(HaveOccurred()) Eventually(func(g Gomega) { diff --git a/test/e2e/install_test.go b/test/e2e/install_test.go index 6195b5297..a3a7e07f1 100644 --- a/test/e2e/install_test.go +++ b/test/e2e/install_test.go @@ -147,7 +147,7 @@ var _ = Describe("Operator Install", func() { By("creating an Operator catalog with the desired package") var err error - operatorCatalog, err = createTestCatalog(ctx, testCatalogName, testCatalogRef) + operatorCatalog, err = createTestCatalog(ctx, testCatalogName, getCatalogImageRef()) Expect(err).ToNot(HaveOccurred()) Eventually(func(g Gomega) { g.Expect(c.Get(ctx, types.NamespacedName{Name: operatorCatalog.Name}, operatorCatalog)).To(Succeed())