Skip to content

Commit 6d87827

Browse files
author
Per Goncalves da Silva
committed
Move to Helm-based test-operator
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent f486436 commit 6d87827

File tree

53 files changed

+694
-442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+694
-442
lines changed

.github/workflows/testdata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020

2121
- name: Run test-operator unit tests
2222
run: |
23-
make test-test-operator
23+
make test-operator-test-unit

Makefile

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,23 +247,40 @@ test-unit: $(SETUP_ENVTEST) envtest-k8s-bins #HELP Run the unit tests
247247
-test.gocoverdir=$(COVERAGE_UNIT_DIR)
248248

249249

250-
.PHONY: test-test-operator
251-
test-test-operator: $(SETUP_ENVTEST) envtest-k8s-bins
252-
KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use -p path $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE))" \
253-
CGO_ENABLED=1 go test -tags '$(GO_BUILD_TAGS)' -count=1 -race -short ./testdata/images/bundles/test-operator/...
254-
255-
TEST_OPERATOR_CONTROLLERS_HOME=./testdata/images/controllers
256-
TEST_OPERATOR_CONTROLLERS=v1.0.0 v2.0.0
250+
TEST_OPERATOR_DIR=./testdata/operators/test-operator
257251

258-
.PHONY: $(TEST_OPERATOR_CONTROLLERS)
259-
$(TEST_OPERATOR_CONTROLLERS):
260-
go build $(GO_BUILD_FLAGS) $(GO_BUILD_EXTRA_FLAGS) -tags '$(GO_BUILD_TAGS)' -ldflags '$(GO_BUILD_LDFLAGS)' -gcflags '$(GO_BUILD_GCFLAGS)' -asmflags '$(GO_BUILD_ASMFLAGS)' -o $(TEST_OPERATOR_CONTROLLERS_HOME)/test-operator/$@/manager ./testdata/images/bundles/test-operator/$@/cmd/main.go
252+
.PHONY: test-operator-test-unit
253+
test-operator-test-unit: $(SETUP_ENVTEST) envtest-k8s-bins
254+
KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use -p path $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE))" \
255+
CGO_ENABLED=1 go test -tags '$(GO_BUILD_TAGS)' -count=1 -race -short $(TEST_OPERATOR_DIR)/...
256+
257+
.PHONY: build-test-operator-controllers
258+
build-test-operator-controllers:
259+
go build $(GO_BUILD_FLAGS) $(GO_BUILD_EXTRA_FLAGS) -tags '$(GO_BUILD_TAGS)' -ldflags '$(GO_BUILD_LDFLAGS)' -gcflags '$(GO_BUILD_GCFLAGS)' -asmflags '$(GO_BUILD_ASMFLAGS)' -o ./testdata/images/controllers/test-operator/v1.0.0/manager $(TEST_OPERATOR_DIR)/v1/cmd/main.go
260+
go build $(GO_BUILD_FLAGS) $(GO_BUILD_EXTRA_FLAGS) -tags '$(GO_BUILD_TAGS)' -ldflags '$(GO_BUILD_LDFLAGS)' -gcflags '$(GO_BUILD_GCFLAGS)' -asmflags '$(GO_BUILD_ASMFLAGS)' -o ./testdata/images/controllers/test-operator/v2.0.0/manager $(TEST_OPERATOR_DIR)/v2/cmd/main.go
261+
262+
.PHONY: test-operator-manifests
263+
test-operator-manifests: $(CONTROLLER_GEN)
264+
# generate resources crds
265+
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) crd paths="$(TEST_OPERATOR_DIR)/api/v1/..." output:dir=$(TEST_OPERATOR_DIR)/charts/v1/crds
266+
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) crd paths="$(TEST_OPERATOR_DIR)/api/..." output:dir=$(TEST_OPERATOR_DIR)/charts/v2/crds
267+
268+
# generate other resources
269+
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) rbac:roleName=test-operator-manager-role paths="$(TEST_OPERATOR_DIR)/v1/..." output:dir=$(TEST_OPERATOR_DIR)/charts/v1/templates
270+
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) rbac:roleName=test-operator-manager-role webhook paths=".$(TEST_OPERATOR_DIR)/v2/..." output:dir=$(TEST_OPERATOR_DIR)/charts/v2/templates
271+
272+
.PHONY: generate-test-operator-bundles
273+
generate-test-operator-bundles: build-test-operator-controllers test-operator-manifests $(OPERATOR_SDK)
274+
# generate bundles
275+
helm template --include-crds $(TEST_OPERATOR_DIR)/charts/v1 | $(OPERATOR_SDK) generate bundle -q --channels beta --version 1.0.0 --package test --output-dir ./testdata/images/bundles/test-operator/v1.0.0
276+
helm template --include-crds --set=configmap.shouldNotTemplate=true $(TEST_OPERATOR_DIR)/charts/v1 | $(OPERATOR_SDK) generate bundle -q --channels beta --version 1.3.0 --package test --output-dir ./testdata/images/bundles/test-operator/v1.3.0
277+
helm template --include-crds $(TEST_OPERATOR_DIR)/charts/v2 | $(OPERATOR_SDK) generate bundle -q --channels beta --version 2.0.0 --package test --output-dir ./testdata/images/bundles/test-operator/v2.0.0
261278

262279
.PHONY: image-registry
263280
E2E_REGISTRY_IMAGE=localhost/e2e-test-registry:devel
264281
image-registry: export GOOS=linux
265282
image-registry: export GOARCH=amd64
266-
image-registry: $(TEST_OPERATOR_CONTROLLERS) ## Build the testdata catalog used for e2e tests and push it to the image registry
283+
image-registry: generate-test-operator-bundles ## Build the testdata catalog used for e2e tests and push it to the image registry
267284
go build $(GO_BUILD_FLAGS) $(GO_BUILD_EXTRA_FLAGS) -tags '$(GO_BUILD_TAGS)' -ldflags '$(GO_BUILD_LDFLAGS)' -gcflags '$(GO_BUILD_GCFLAGS)' -asmflags '$(GO_BUILD_ASMFLAGS)' -o ./testdata/push/bin/push ./testdata/push/push.go
268285
$(CONTAINER_RUNTIME) build -f ./testdata/Dockerfile -t $(E2E_REGISTRY_IMAGE) ./testdata
269286
$(CONTAINER_RUNTIME) save $(E2E_REGISTRY_IMAGE) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME)
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
2+
data:
3+
name: test-configmap
4+
version: v1.0.0
25
kind: ConfigMap
36
metadata:
47
name: test-configmap
5-
data:
6-
version: "v1.0.0"
7-
name: "test-configmap"
Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ metadata:
44
annotations:
55
alm-examples: '[]'
66
capabilities: Basic Install
7-
createdAt: "2025-07-03T15:15:31Z"
8-
operators.operatorframework.io/builder: operator-sdk-v1.40.0+git
7+
createdAt: "2025-07-09T18:30:36Z"
8+
operators.operatorframework.io/builder: operator-sdk-v1.34.1
99
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4
10-
name: test-operator.v1.0.0
10+
name: test.v1.0.0
1111
namespace: placeholder
1212
spec:
1313
apiservicedefinitions: {}
@@ -53,25 +53,12 @@ spec:
5353
- get
5454
- patch
5555
- update
56-
- apiGroups:
57-
- authentication.k8s.io
58-
resources:
59-
- tokenreviews
60-
verbs:
61-
- create
62-
- apiGroups:
63-
- authorization.k8s.io
64-
resources:
65-
- subjectaccessreviews
66-
verbs:
67-
- create
68-
serviceAccountName: test-operator-controller-manager
56+
serviceAccountName: test-operator-manager
6957
deployments:
7058
- label:
71-
app.kubernetes.io/managed-by: kustomize
7259
app.kubernetes.io/name: test-operator
7360
control-plane: controller-manager
74-
name: test-operator-controller-manager
61+
name: controller-manager
7562
spec:
7663
replicas: 1
7764
selector:
@@ -89,7 +76,6 @@ spec:
8976
spec:
9077
containers:
9178
- args:
92-
- --leader-elect
9379
- --health-probe-bind-address=:8081
9480
command:
9581
- /manager
@@ -128,42 +114,8 @@ spec:
128114
runAsNonRoot: true
129115
seccompProfile:
130116
type: RuntimeDefault
131-
serviceAccountName: test-operator-controller-manager
117+
serviceAccountName: test-operator-manager
132118
terminationGracePeriodSeconds: 10
133-
permissions:
134-
- rules:
135-
- apiGroups:
136-
- ""
137-
resources:
138-
- configmaps
139-
verbs:
140-
- get
141-
- list
142-
- watch
143-
- create
144-
- update
145-
- patch
146-
- delete
147-
- apiGroups:
148-
- coordination.k8s.io
149-
resources:
150-
- leases
151-
verbs:
152-
- get
153-
- list
154-
- watch
155-
- create
156-
- update
157-
- patch
158-
- delete
159-
- apiGroups:
160-
- ""
161-
resources:
162-
- events
163-
verbs:
164-
- create
165-
- patch
166-
serviceAccountName: test-operator-controller-manager
167119
strategy: deployment
168120
installModes:
169121
- supported: true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
annotations:
2+
# Core bundle annotations.
23
operators.operatorframework.io.bundle.mediatype.v1: registry+v1
34
operators.operatorframework.io.bundle.manifests.v1: manifests/
45
operators.operatorframework.io.bundle.metadata.v1: metadata/
56
operators.operatorframework.io.bundle.package.v1: test
67
operators.operatorframework.io.bundle.channels.v1: beta
8+
operators.operatorframework.io.metrics.builder: operator-sdk-v1.34.1
9+
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
10+
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v4
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
data:
3+
name: test-configmap
4+
version: v1.0.0
5+
kind: ConfigMap
6+
metadata:
7+
annotations:
8+
shouldNotTemplate: |
9+
'The namespace is {{ $labels.namespace }}. The templated $labels.namespace is NOT expected to be processed by OLM's rendering engine for registry+v1 bundles.
10+
name: test-configmap
Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ metadata:
44
annotations:
55
alm-examples: '[]'
66
capabilities: Basic Install
7-
createdAt: "2025-07-03T15:15:31Z"
8-
operators.operatorframework.io/builder: operator-sdk-v1.40.0+git
7+
createdAt: "2025-07-09T18:30:36Z"
8+
operators.operatorframework.io/builder: operator-sdk-v1.34.1
99
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4
10-
name: test-operator.v1.0.0
10+
name: test.v1.3.0
1111
namespace: placeholder
1212
spec:
1313
apiservicedefinitions: {}
@@ -53,25 +53,12 @@ spec:
5353
- get
5454
- patch
5555
- update
56-
- apiGroups:
57-
- authentication.k8s.io
58-
resources:
59-
- tokenreviews
60-
verbs:
61-
- create
62-
- apiGroups:
63-
- authorization.k8s.io
64-
resources:
65-
- subjectaccessreviews
66-
verbs:
67-
- create
68-
serviceAccountName: test-operator-controller-manager
56+
serviceAccountName: test-operator-manager
6957
deployments:
7058
- label:
71-
app.kubernetes.io/managed-by: kustomize
7259
app.kubernetes.io/name: test-operator
7360
control-plane: controller-manager
74-
name: test-operator-controller-manager
61+
name: controller-manager
7562
spec:
7663
replicas: 1
7764
selector:
@@ -89,7 +76,6 @@ spec:
8976
spec:
9077
containers:
9178
- args:
92-
- --leader-elect
9379
- --health-probe-bind-address=:8081
9480
command:
9581
- /manager
@@ -128,42 +114,8 @@ spec:
128114
runAsNonRoot: true
129115
seccompProfile:
130116
type: RuntimeDefault
131-
serviceAccountName: test-operator-controller-manager
117+
serviceAccountName: test-operator-manager
132118
terminationGracePeriodSeconds: 10
133-
permissions:
134-
- rules:
135-
- apiGroups:
136-
- ""
137-
resources:
138-
- configmaps
139-
verbs:
140-
- get
141-
- list
142-
- watch
143-
- create
144-
- update
145-
- patch
146-
- delete
147-
- apiGroups:
148-
- coordination.k8s.io
149-
resources:
150-
- leases
151-
verbs:
152-
- get
153-
- list
154-
- watch
155-
- create
156-
- update
157-
- patch
158-
- delete
159-
- apiGroups:
160-
- ""
161-
resources:
162-
- events
163-
verbs:
164-
- create
165-
- patch
166-
serviceAccountName: test-operator-controller-manager
167119
strategy: deployment
168120
installModes:
169121
- supported: true
@@ -187,4 +139,4 @@ spec:
187139
provider:
188140
name: operator-framework
189141
url: https://github.com/operator-framework/operator-controller
190-
version: 1.0.0
142+
version: 1.3.0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
annotations:
2+
# Core bundle annotations.
23
operators.operatorframework.io.bundle.mediatype.v1: registry+v1
34
operators.operatorframework.io.bundle.manifests.v1: manifests/
45
operators.operatorframework.io.bundle.metadata.v1: metadata/
56
operators.operatorframework.io.bundle.package.v1: test
67
operators.operatorframework.io.bundle.channels.v1: beta
8+
operators.operatorframework.io.metrics.builder: operator-sdk-v1.34.1
9+
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
10+
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v4

0 commit comments

Comments
 (0)