Skip to content

Commit

Permalink
Hosted mode e2e tests fix on GRC PRs
Browse files Browse the repository at this point in the history
reusable GitHub workflow for running the Kind E2E tests in hosted mode was added. We need to now trigger these tests from the component repos as part of the PR CI in releases 2.7+.

Modify the governance-policy-framework release-2.7, release-2.8, and main branches to consolidate this as a new job in the existing reusable workflow file.

Ref: https://issues.redhat.com/browse/ACM-5211

Signed-off-by: Yi Rae Kim <yikim@redhat.com>
(cherry picked from commit 2265299)
  • Loading branch information
yiraeChristineKim authored and openshift-merge-bot[bot] committed Mar 21, 2024
1 parent 5f35bc3 commit 96526b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
23 changes: 19 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ GOOS = $(shell go env GOOS)
TESTARGS_DEFAULT := -v
TESTARGS ?= $(TESTARGS_DEFAULT)
CONTROLLER_NAME = $(shell cat COMPONENT_NAME 2> /dev/null)
CONTROLLER_NAMESPACE ?= open-cluster-management-agent-addon
# Handle KinD configuration
MANAGED_CLUSTER_SUFFIX ?=
MANAGED_CLUSTER_NAME ?= managed$(MANAGED_CLUSTER_SUFFIX)
WATCH_NAMESPACE ?= $(MANAGED_CLUSTER_NAME)
KIND_NAME ?= test-$(MANAGED_CLUSTER_NAME)
KIND_CLUSTER_NAME ?= kind-$(KIND_NAME)
KIND_NAMESPACE ?= $(CONTROLLER_NAMESPACE)
KIND_NAMESPACE ?= open-cluster-management-agent-addon
# Test coverage threshold
export COVERAGE_MIN ?= 75
COVERAGE_E2E_OUT ?= coverage_e2e.out
Expand Down Expand Up @@ -101,7 +100,7 @@ deploy: generate-operator-yaml create-ns

.PHONY: create-ns
create-ns:
-@kubectl create namespace $(CONTROLLER_NAMESPACE)
-@kubectl create namespace $(KIND_NAMESPACE)
-@kubectl create namespace $(WATCH_NAMESPACE)

# Run against the current locally configured Kubernetes cluster
Expand Down Expand Up @@ -162,15 +161,31 @@ kind-deploy-controller: generate-operator-yaml install-resources deploy
.PHONY: deploy-controller
deploy-controller: kind-deploy-controller

HOSTED ?= none

.PHONY: kind-deploy-controller-dev
kind-deploy-controller-dev: kind-deploy-controller build-images
kind-deploy-controller-dev:
if [ "$(HOSTED)" = "hosted" ]; then\
$(MAKE) kind-deploy-controller-dev-addon ;\
else\
$(MAKE) kind-deploy-controller-dev-normal ;\
fi

.PHONY: kind-deploy-controller-dev-normal
kind-deploy-controller-dev-normal: kind-deploy-controller
@echo Pushing image to KinD cluster
kind load docker-image $(REGISTRY)/$(IMG):$(TAG) --name $(KIND_NAME)
@echo "Patch deployment image"
kubectl patch deployment $(IMG) -n $(KIND_NAMESPACE) -p "{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"$(IMG)\",\"imagePullPolicy\":\"Never\"}]}}}}"
kubectl patch deployment $(IMG) -n $(KIND_NAMESPACE) -p "{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"$(IMG)\",\"image\":\"$(REGISTRY)/$(IMG):$(TAG)\"}]}}}}"
kubectl rollout status -n $(KIND_NAMESPACE) deployment $(IMG) --timeout=180s

.PHONY: kind-deploy-controller-dev-addon
kind-deploy-controller-dev-addon:
kind load docker-image $(REGISTRY)/$(IMG):$(TAG) --name $(KIND_NAME)
kubectl annotate -n $(subst -hosted,,$(KIND_NAMESPACE)) --overwrite managedclusteraddon config-policy-controller\
addon.open-cluster-management.io/values='{"global":{"imagePullPolicy": "Never", "imageOverrides":{"config_policy_controller": "$(REGISTRY)/$(IMG):$(TAG)"}}}'

# Specify KIND_VERSION to indicate the version tag of the KinD image
.PHONY: kind-create-cluster
kind-create-cluster:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ to learn how to get involved.
```
- Deploy controller to a cluster

The controller is deployed to a namespace defined in `CONTROLLER_NAMESPACE` and monitors the namepace defined in `WATCH_NAMESPACE` for `ConfigurationPolicy` resources.
The controller is deployed to a namespace defined in `KIND_NAMESPACE` and monitors the namepace defined in `WATCH_NAMESPACE` for `ConfigurationPolicy` resources.

1. Deploy the controller and related resources
```bash
Expand All @@ -143,7 +143,7 @@ to learn how to get involved.

The deployment namespaces are configurable with:
```bash
export CONTROLLER_NAMESPACE='' # (defaults to 'open-cluster-management-agent-addon')
export KIND_NAMESPACE='' # (defaults to 'open-cluster-management-agent-addon')
export WATCH_NAMESPACE='' # (defaults to 'managed')
```
**NOTE:** Please be aware of the community's [deployment images](https://github.com/open-cluster-management-io/community#deployment-images) special note.
Expand Down

0 comments on commit 96526b1

Please sign in to comment.