Skip to content

Commit

Permalink
Skip tests if SET_PIPELINE_RBAC is set to false
Browse files Browse the repository at this point in the history
  • Loading branch information
atheo89 committed Oct 31, 2024
1 parent 39773cc commit 595bcfe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 9 additions & 2 deletions components/odh-notebook-controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -105,7 +112,7 @@ run: manifests generate fmt vet certificates ktunnel ## Run a controller from yo
go run ./main.go

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker-build: ## Build docker image with the manager.
cd ../ && ${CONTAINER_ENGINE} build . -t ${IMG}:${TAG} -f odh-notebook-controller/Dockerfile

.PHONY: docker-push
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers
import (
"context"
"io/ioutil"
"os"
"strings"
"time"

Expand Down Expand Up @@ -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"
Expand All @@ -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()

Expand Down

0 comments on commit 595bcfe

Please sign in to comment.