From 1024d62932abfc2ba4ae4e8ac880de583296fe5e Mon Sep 17 00:00:00 2001 From: atheo89 Date: Thu, 31 Oct 2024 13:12:14 +0100 Subject: [PATCH] Skip tests if SET_PIPELINE_RBAC is set to false --- components/odh-notebook-controller/Makefile | 9 ++++++++- .../controllers/notebook_controller_test.go | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/components/odh-notebook-controller/Makefile b/components/odh-notebook-controller/Makefile index 8c223728285..0c68ba2c72c 100644 --- a/components/odh-notebook-controller/Makefile +++ b/components/odh-notebook-controller/Makefile @@ -87,7 +87,14 @@ vet: ## Run go vet against code. go vet ./... .PHONY: test -test: manifests generate fmt vet envtest ## Run tests. +test: test-with-rbac-false test-with-rbac-true +test-with-rbac-false: manifests generate fmt vet envtest ## Run tests. + @export SET_PIPELINE_RBAC=false && \ + ACK_GINKGO_DEPRECATIONS=1.16.5 \ + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" \ + go test ./controllers/... -ginkgo.v -ginkgo.progress -test.v -coverprofile cover.out +test-with-rbac-true: manifests generate fmt vet envtest ## Run tests. + @export SET_PIPELINE_RBAC=true && \ ACK_GINKGO_DEPRECATIONS=1.16.5 \ KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" \ go test ./controllers/... -ginkgo.v -ginkgo.progress -test.v -coverprofile cover.out diff --git a/components/odh-notebook-controller/controllers/notebook_controller_test.go b/components/odh-notebook-controller/controllers/notebook_controller_test.go index 03c982a0fc3..47eadf56674 100644 --- a/components/odh-notebook-controller/controllers/notebook_controller_test.go +++ b/components/odh-notebook-controller/controllers/notebook_controller_test.go @@ -18,6 +18,7 @@ package controllers import ( "context" "io/ioutil" + "os" "strings" "time" @@ -163,7 +164,7 @@ var _ = Describe("The Openshift Notebook controller", func() { }) // New test case for RoleBinding reconciliation - When("ReconcileRoleBindings is called for a Notebook", func() { + When("Reconcile RoleBindings is called for a Notebook", func() { const ( name = "test-notebook-rolebinding" namespace = "default" @@ -174,6 +175,13 @@ var _ = Describe("The Openshift Notebook controller", func() { roleRefName := "ds-pipeline-user-access-dspa" roleBindingName := "elyra-pipelines-" + name + BeforeEach(func() { + // Skip the tests if SET_PIPELINE_RBAC is not set to "true" + if os.Getenv("SET_PIPELINE_RBAC") != "true" { + Skip("Skipping RoleBinding reconciliation tests as SET_PIPELINE_RBAC is not set to 'true'") + } + }) + It("Should create a RoleBinding when the referenced Role exists", func() { ctx := context.Background()