diff --git a/workspaces/controller/Makefile b/workspaces/controller/Makefile index 6032c8c9..b30fc6ff 100644 --- a/workspaces/controller/Makefile +++ b/workspaces/controller/Makefile @@ -1,5 +1,6 @@ # Image URL to use all building/pushing image targets IMG ?= controller:latest + # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. ENVTEST_K8S_VERSION = 1.31.0 @@ -77,7 +78,7 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \ exit 1; \ } - go test ./test/e2e/ -v -ginkgo.v + go test ./test/e2e/ -v -ginkgo.v -args -controller-image=${IMG} .PHONY: lint lint: golangci-lint ## Run golangci-lint linter diff --git a/workspaces/controller/README.md b/workspaces/controller/README.md index b4c97ce2..38e8ead0 100644 --- a/workspaces/controller/README.md +++ b/workspaces/controller/README.md @@ -49,6 +49,18 @@ kubectl apply -k config/samples/ >**NOTE**: Ensure that the samples has default values to test it out. +**Run the e2e tests** + +```sh +make test-e2e +``` + +If you would like to run the tests with a given image, use the IMG parameter: + +```sh +make test-e2e IMG=/workspace-controller:tag +``` + ### To Uninstall **Delete the instances (CRs) from the cluster:** diff --git a/workspaces/controller/test/e2e/e2e_test.go b/workspaces/controller/test/e2e/e2e_test.go index 9d075f31..707bb5b5 100644 --- a/workspaces/controller/test/e2e/e2e_test.go +++ b/workspaces/controller/test/e2e/e2e_test.go @@ -17,6 +17,7 @@ limitations under the License. package e2e import ( + "flag" "fmt" "os/exec" "path/filepath" @@ -34,8 +35,8 @@ import ( const ( // controller configs - controllerNamespace = "workspace-controller-system" - controllerImage = "ghcr.io/kubeflow/notebooks/workspace-controller:latest" + controllerNamespace = "workspace-controller-system" + defaultControllerImage = "ghcr.io/kubeflow/notebooks/workspace-controller:latest" // workspace configs workspaceNamespace = "workspace-test" @@ -60,13 +61,23 @@ const ( ) var ( - projectDir = "" + projectDir = "" + controllerImage = "" ) +func init() { + flag.StringVar(&controllerImage, "controller-image", + defaultControllerImage, "Workspace controller image to use for the test") +} + var _ = Describe("controller", Ordered, func() { BeforeAll(func() { projectDir, _ = utils.GetProjectDir() + // This ensures flags are parsed before tests run + if !flag.Parsed() { + flag.Parse() + } By("creating the controller namespace") cmd := exec.Command("kubectl", "create", "ns", controllerNamespace)