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>
  • Loading branch information
yiraeChristineKim authored and openshift-merge-robot committed Jul 13, 2023
1 parent eb10d78 commit 2265299
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
29 changes: 22 additions & 7 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 @@ -87,13 +86,13 @@ build-images:
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
.PHONY: deploy
deploy: generate-operator-yaml
kubectl apply -f deploy/operator.yaml -n $(CONTROLLER_NAMESPACE)
kubectl apply -f deploy/crds/policy.open-cluster-management.io_configurationpolicies.yaml -n $(CONTROLLER_NAMESPACE)
kubectl set env deployment/$(IMG) -n $(CONTROLLER_NAMESPACE) WATCH_NAMESPACE=$(WATCH_NAMESPACE)
kubectl apply -f deploy/operator.yaml -n $(KIND_NAMESPACE)
kubectl apply -f deploy/crds/policy.open-cluster-management.io_configurationpolicies.yaml -n $(KIND_NAMESPACE)
kubectl set env deployment/$(IMG) -n $(KIND_NAMESPACE) WATCH_NAMESPACE=$(WATCH_NAMESPACE)

.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 @@ -153,15 +152,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 @@ -135,15 +135,15 @@ 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. Create the deployment namespaces
```bash
make create-ns
```
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')
```
2. Deploy the controller and related resources
Expand Down

0 comments on commit 2265299

Please sign in to comment.