diff --git a/components/odh-notebook-controller/Makefile b/components/odh-notebook-controller/Makefile index 8c223728285..33203c20857 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 b411562f4ac..65e96d66da0 100644 --- a/components/odh-notebook-controller/controllers/notebook_controller_test.go +++ b/components/odh-notebook-controller/controllers/notebook_controller_test.go @@ -19,7 +19,9 @@ import ( "context" "crypto/x509" "encoding/pem" + "fmt" "io/ioutil" + "os" "strings" "time" @@ -165,7 +167,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" @@ -176,6 +178,14 @@ 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" + fmt.Printf("SET_PIPELINE_RBAC is: %s\n", os.Getenv("SET_PIPELINE_RBAC")) + 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()