diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index ff1a3f945..101cda729 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -1,6 +1,7 @@ package e2e import ( + "fmt" "os" "testing" @@ -23,20 +24,30 @@ func TestE2E(t *testing.T) { } var ( - hubClient kubernetes.Interface - hubDynamicClient dynamic.Interface - clusterClient clusterv1client.Interface - imageRegistry string + hubClient kubernetes.Interface + hubDynamicClient dynamic.Interface + clusterClient clusterv1client.Interface + registrationImage string ) +// This suite is sensitive to the following environment variables: +// +// - IMAGE_NAME sets the exact image to deploy for the registration agent +// - IMAGE_REGISTRY sets the image registry to use to build the IMAGE_NAME if +// IMAGE_NAME is unset: IMAGE_REGISTRY/registration:latest +// - KUBECONFIG is the location of the kubeconfig file to use var _ = ginkgo.BeforeSuite(func() { logf.SetLogger(zap.LoggerTo(ginkgo.GinkgoWriter, true)) - kubeconfig := os.Getenv("KUBECONFIG") - imageRegistry = os.Getenv("IMAGE_REGISTRY") - if imageRegistry == "" { - imageRegistry = "quay.io/open-cluster-management" + registrationImage = os.Getenv("IMAGE_NAME") + if registrationImage == "" { + imageRegistry := os.Getenv("IMAGE_REGISTRY") + if imageRegistry == "" { + imageRegistry = "quay.io/open-cluster-management" + } + registrationImage = fmt.Sprintf("%v/registration:latest", imageRegistry) } + kubeconfig := os.Getenv("KUBECONFIG") err := func() error { config, err := clientcmd.BuildConfigFromFlags("", kubeconfig) if err != nil { diff --git a/test/e2e/loopback_test.go b/test/e2e/loopback_test.go index 48178f2cb..6af06d447 100644 --- a/test/e2e/loopback_test.go +++ b/test/e2e/loopback_test.go @@ -108,7 +108,7 @@ var _ = ginkgo.Describe("Loopback registration [development]", func() { } ) clusterName := fmt.Sprintf("loopback-e2e-%v", suffix) - deployment, err = spokeDeployment(nsName, clusterName, imageRegistry) + deployment, err = spokeDeployment(nsName, clusterName, registrationImage) gomega.Expect(err).ToNot(gomega.HaveOccurred()) err = wait.Poll(1*time.Second, 5*time.Second, func() (bool, error) { var err error @@ -303,7 +303,7 @@ func spokeCRB(nsName, suffix string) (*unstructured.Unstructured, error) { return crb, nil } -func spokeDeployment(nsName, clusterName, imageRegistry string) (*unstructured.Unstructured, error) { +func spokeDeployment(nsName, clusterName, image string) (*unstructured.Unstructured, error) { deployment, err := assetToUnstructured("deploy/spoke/deployment.yaml") if err != nil { return nil, err @@ -318,7 +318,6 @@ func spokeDeployment(nsName, clusterName, imageRegistry string) (*unstructured.U return nil, fmt.Errorf("deployment containers not found or error in spec: %v", err) } - image := fmt.Sprintf("%v/registration:latest", imageRegistry) if err := unstructured.SetNestedField(containers[0].(map[string]interface{}), image, "image"); err != nil { return nil, err }