Skip to content

Commit 90d6d16

Browse files
author
Mikalai Radchuk
committed
WIP
Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent 1df456a commit 90d6d16

File tree

6 files changed

+60
-7
lines changed

6 files changed

+60
-7
lines changed

.github/workflows/e2e.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,10 @@ jobs:
2222

2323
- name: Run e2e tests
2424
run: |
25-
make e2e
25+
make e2e GO_BUILD_FLAGS=-cover
26+
27+
- uses: codecov/codecov-action@v3
28+
with:
29+
files: e2e-cover.out
30+
fail_ci_if_error: true
31+
functionalities: fixes

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ Dockerfile.cross
1414
# Test binary, build with `go test -c`
1515
*.test
1616

17-
# Output of the go coverage tool, specifically when used with LiteIDE
17+
# Output of the go coverage tools
1818
*.out
19+
coverage
1920

2021
# Release output
2122
dist/**
@@ -33,4 +34,3 @@ install.sh
3334
*~
3435
\#*\#
3536
.\#*
36-

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ KIND_CLUSTER_NAME ?= operator-controller
2424

2525
CONTAINER_RUNTIME ?= docker
2626

27+
KUSTOMIZE_BUILD_DIR ?= config/default
28+
2729
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
2830
ifeq (,$(shell go env GOBIN))
2931
GOBIN=$(shell go env GOPATH)/bin
@@ -103,7 +105,13 @@ test-unit: $(SETUP_ENVTEST) ## Run the unit tests
103105
eval $$($(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION)) && go test -tags $(GO_BUILD_TAGS) -count=1 -short $(UNIT_TEST_DIRS) -coverprofile cover.out
104106

105107
e2e: KIND_CLUSTER_NAME=operator-controller-e2e
108+
e2e: KUSTOMIZE_BUILD_DIR=config/e2e
106109
e2e: run kind-load-test-artifacts test-e2e kind-cluster-cleanup ## Run e2e test suite on local kind cluster
110+
kubectl -n $(OPERATOR_CONTROLLER_NAMESPACE) scale deployment/operator-controller-controller-manager --replicas=0
111+
kubectl -n $(OPERATOR_CONTROLLER_NAMESPACE) run pvc-copy --image busybox --restart=Never --override-type strategic --overrides='{"spec": {"volumes": [{"name": "data", "persistentVolumeClaim": {"claimName": "e2e-coverage"}}], "containers": [{"name": "pvc-copy", "volumeMounts": [{"name": "data", "mountPath": "/data"}]}]}}' -- sleep infinity
112+
kubectl -n $(OPERATOR_CONTROLLER_NAMESPACE) wait --for=condition=ready pod pvc-copy
113+
kubectl -n $(OPERATOR_CONTROLLER_NAMESPACE) cp pvc-copy:/data/ ./coverage/
114+
go tool covdata textfmt -i=./coverage/ -o e2e-cover.out
107115

108116
kind-load: $(KIND) ## Loads the currently constructed image onto the cluster
109117
$(KIND) load docker-image $(IMG) --name $(KIND_CLUSTER_NAME)
@@ -174,7 +182,7 @@ release: $(GORELEASER) ## Runs goreleaser for the operator-controller. By defaul
174182

175183
quickstart: export MANIFEST="https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/operator-controller.yaml"
176184
quickstart: $(KUSTOMIZE) generate ## Generate the installation release manifests and scripts
177-
$(KUSTOMIZE) build config/default | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml
185+
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml
178186
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
179187

180188
##@ Deployment
@@ -186,7 +194,7 @@ endif
186194
.PHONY: install
187195
install: export MANIFEST="./operator-controller.yaml"
188196
install: manifests $(KUSTOMIZE) generate ## Install CRDs into the K8s cluster specified in ~/.kube/config.
189-
$(KUSTOMIZE) build config/default > operator-controller.yaml
197+
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) > operator-controller.yaml
190198
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
191199

192200
.PHONY: uninstall
@@ -196,8 +204,8 @@ uninstall: manifests $(KUSTOMIZE) ## Uninstall CRDs from the K8s cluster specifi
196204
.PHONY: deploy
197205
deploy: manifests $(KUSTOMIZE) ## Deploy controller to the K8s cluster specified in ~/.kube/config.
198206
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
199-
$(KUSTOMIZE) build config/default | kubectl apply -f -
207+
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) | kubectl apply -f -
200208

201209
.PHONY: undeploy
202210
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
203-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
211+
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

config/e2e/kustomization.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace: operator-controller-system
2+
3+
resources:
4+
- ../default
5+
- manager_e2e_coverage_pvc.yaml
6+
7+
patches:
8+
- path: manager_e2e_coverage_patch.yaml
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: controller-manager
5+
namespace: system
6+
spec:
7+
template:
8+
spec:
9+
containers:
10+
- name: kube-rbac-proxy
11+
- name: manager
12+
env:
13+
- name: GOCOVERDIR
14+
value: /e2e-coverage
15+
volumeMounts:
16+
- name: e2e-coverage-volume
17+
mountPath: /e2e-coverage
18+
volumes:
19+
- name: e2e-coverage-volume
20+
persistentVolumeClaim:
21+
claimName: e2e-coverage
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: e2e-coverage
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
resources:
9+
requests:
10+
storage: 64Mi

0 commit comments

Comments
 (0)