Skip to content

Commit

Permalink
improve(ws): add controller-image parameter to e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
etirelli committed Feb 23, 2025
1 parent b981275 commit edebbec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion workspaces/controller/Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions workspaces/controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<some-registry>/workspace-controller:tag
```

### To Uninstall
**Delete the instances (CRs) from the cluster:**

Expand Down
17 changes: 14 additions & 3 deletions workspaces/controller/test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package e2e

import (
"flag"
"fmt"
"os/exec"
"path/filepath"
Expand All @@ -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"
Expand All @@ -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)
Expand Down

0 comments on commit edebbec

Please # to comment.