Skip to content

Commit 43b3bcf

Browse files
author
Per Goncalves da Silva
committed
Add Helm-based test operator
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent 2026ba3 commit 43b3bcf

File tree

52 files changed

+2628
-353
lines changed

Some content is hidden

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

52 files changed

+2628
-353
lines changed

Makefile

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,23 @@ verify: k8s-pin kind-verify-versions fmt generate manifests crd-ref-docs generat
171171

172172
# Renders registry+v1 bundles in test/convert
173173
# Used by CI in verify to catch regressions in the registry+v1 -> plain conversion code
174-
.PHONY: generate-test-data
175-
generate-test-data:
174+
.PHONY: render-regv1-bundle
175+
render-regv1-bundle:
176176
go run test/convert/generate-manifests.go
177177

178+
.PHONY: generate-test-operator-bundles
179+
generate-test-operator-bundles:
180+
BUNDLE_VERSION=1.0.0 BUNDLE_CHANNELS=beta BUNDLE_MANIFEST_PATH=$(ROOT_DIR)/testdata/images/bundles/test-operator/v1.0.0 \
181+
$(MAKE) -C ./testdata/operators/test-operator/v1 bundle
182+
BUNDLE_VERSION=1.3.0 BUNDLE_CHANNELS=beta BUNDLE_MANIFEST_PATH=$(ROOT_DIR)/testdata/images/bundles/test-operator/v1.3.0 \
183+
HELM_OPTS=--set=configmap.shouldNotTemplate=true $(MAKE) -C ./testdata/operators/test-operator/v1 bundle
184+
BUNDLE_VERSION=2.0.0 BUNDLE_CHANNELS=beta BUNDLE_MANIFEST_PATH=$(ROOT_DIR)/testdata/images/bundles/test-operator/v2.0.0 \
185+
$(MAKE) -C ./testdata/operators/test-operator/v2 bundle
186+
187+
.PHONY: generate-test-data
188+
generate-test-data: render-regv1-bundle generate-test-operator-bundles
189+
190+
178191
.PHONY: fix-lint
179192
fix-lint: $(GOLANGCI_LINT) #EXHELP Fix lint issues
180193
$(GOLANGCI_LINT) run --fix --build-tags $(GO_BUILD_TAGS) $(GOLANGCI_LINT_ARGS)
@@ -246,11 +259,21 @@ test-unit: $(SETUP_ENVTEST) envtest-k8s-bins #HELP Run the unit tests
246259
$(UNIT_TEST_DIRS) \
247260
-test.gocoverdir=$(COVERAGE_UNIT_DIR)
248261

262+
.PHONY: test-operator-test-unit
263+
test-operator-test-unit: $(SETUP_ENVTEST) envtest-k8s-bins
264+
$(MAKE) -C ./testdata/operators/test-operator/v1 test-unit
265+
$(MAKE) -C ./testdata/operators/test-operator/v2 test-unit
266+
267+
.PHONY: build-test-operator-controllers
268+
build-test-operator-controllers:
269+
CONTROLLER_BINARY_PATH=$(ROOT_DIR)/testdata/images/controllers/test-operator/v1.0.0 $(MAKE) -C ./testdata/operators/test-operator/v1 build
270+
CONTROLLER_BINARY_PATH=$(ROOT_DIR)/testdata/images/controllers/test-operator/v2.0.0 $(MAKE) -C ./testdata/operators/test-operator/v2 build
271+
249272
.PHONY: image-registry
250273
E2E_REGISTRY_IMAGE=localhost/e2e-test-registry:devel
251274
image-registry: export GOOS=linux
252275
image-registry: export GOARCH=amd64
253-
image-registry: ## Build the testdata catalog used for e2e tests and push it to the image registry
276+
image-registry: build-test-operator-controllers ## Build the testdata catalog used for e2e tests and push it to the image registry
254277
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
255278
$(CONTAINER_RUNTIME) build -f ./testdata/Dockerfile -t $(E2E_REGISTRY_IMAGE) ./testdata
256279
$(CONTAINER_RUNTIME) save $(E2E_REGISTRY_IMAGE) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME)

test/e2e/cluster_extension_install_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) {
732732
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
733733
assert.Equal(ct, ocv1.ReasonSucceeded, cond.Reason)
734734
assert.Contains(ct, cond.Message, "Installed bundle")
735-
assert.Contains(ct, clusterExtension.Status.Install.Bundle.Version, "2.0.0")
735+
assert.Contains(ct, clusterExtension.Status.Install.Bundle.Version, "1.3.0")
736736
}
737737
}, pollDuration, pollInterval)
738738

testdata/images/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
controllers/*

testdata/images/bundles/test-operator/v1.0.0/manifests/olm.operatorframework.com_olme2etest.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.
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: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
apiVersion: operators.coreos.com/v1alpha1
2+
kind: ClusterServiceVersion
3+
metadata:
4+
annotations:
5+
alm-examples: '[]'
6+
capabilities: Basic Install
7+
operators.operatorframework.io/builder: operator-sdk-v1.34.1
8+
operators.operatorframework.io/project_layout: unknown
9+
name: test.v1.0.0
10+
namespace: placeholder
11+
spec:
12+
apiservicedefinitions: {}
13+
customresourcedefinitions:
14+
owned:
15+
- description: TestOperator is the Schema for the testoperators API.
16+
displayName: Test Operator
17+
kind: TestOperator
18+
name: testoperators.testolm.operatorframework.io
19+
version: v1
20+
description: Test OLM Operator
21+
displayName: OLM Test Operator
22+
icon:
23+
- base64data: ""
24+
mediatype: ""
25+
install:
26+
spec:
27+
clusterPermissions:
28+
- rules:
29+
- apiGroups:
30+
- testolm.operatorframework.io
31+
resources:
32+
- testoperators
33+
verbs:
34+
- create
35+
- delete
36+
- get
37+
- list
38+
- patch
39+
- update
40+
- watch
41+
- apiGroups:
42+
- testolm.operatorframework.io
43+
resources:
44+
- testoperators/finalizers
45+
verbs:
46+
- update
47+
- apiGroups:
48+
- testolm.operatorframework.io
49+
resources:
50+
- testoperators/status
51+
verbs:
52+
- get
53+
- patch
54+
- update
55+
serviceAccountName: test-operator-manager
56+
deployments:
57+
- label:
58+
app.kubernetes.io/name: test-operator
59+
control-plane: controller-manager
60+
name: controller-manager
61+
spec:
62+
replicas: 1
63+
selector:
64+
matchLabels:
65+
app.kubernetes.io/name: test-operator
66+
control-plane: controller-manager
67+
strategy: {}
68+
template:
69+
metadata:
70+
annotations:
71+
kubectl.kubernetes.io/default-container: manager
72+
labels:
73+
app.kubernetes.io/name: test-operator
74+
control-plane: controller-manager
75+
spec:
76+
containers:
77+
- args:
78+
- --health-probe-bind-address=:8081
79+
command:
80+
- /manager
81+
env:
82+
- name: WATCH_NAMESPACE
83+
valueFrom:
84+
fieldRef:
85+
fieldPath: metadata.annotations['olm.targetNamespaces']
86+
image: docker-registry.operator-controller-e2e.svc.cluster.local:5000/controllers/test-operator:v1.0.0
87+
livenessProbe:
88+
httpGet:
89+
path: /healthz
90+
port: 8081
91+
initialDelaySeconds: 15
92+
periodSeconds: 20
93+
name: manager
94+
readinessProbe:
95+
httpGet:
96+
path: /readyz
97+
port: 8081
98+
initialDelaySeconds: 5
99+
periodSeconds: 10
100+
resources:
101+
limits:
102+
cpu: 500m
103+
memory: 128Mi
104+
requests:
105+
cpu: 10m
106+
memory: 64Mi
107+
securityContext:
108+
allowPrivilegeEscalation: false
109+
capabilities:
110+
drop:
111+
- ALL
112+
securityContext:
113+
runAsNonRoot: true
114+
seccompProfile:
115+
type: RuntimeDefault
116+
serviceAccountName: test-operator-manager
117+
terminationGracePeriodSeconds: 10
118+
strategy: deployment
119+
installModes:
120+
- supported: true
121+
type: OwnNamespace
122+
- supported: true
123+
type: SingleNamespace
124+
- supported: false
125+
type: MultiNamespace
126+
- supported: true
127+
type: AllNamespaces
128+
keywords:
129+
- test
130+
- operator
131+
links:
132+
- name: V1
133+
url: https://github.com/operator-framework/operator-controller
134+
maintainers:
135+
136+
name: community
137+
maturity: alpha
138+
provider:
139+
name: operator-framework
140+
url: https://github.com/operator-framework/operator-controller
141+
version: 1.0.0
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
annotations:
5+
controller-gen.kubebuilder.io/version: v0.18.0
6+
creationTimestamp: null
7+
name: testoperators.testolm.operatorframework.io
8+
spec:
9+
group: testolm.operatorframework.io
10+
names:
11+
kind: TestOperator
12+
listKind: TestOperatorList
13+
plural: testoperators
14+
singular: testoperator
15+
scope: Namespaced
16+
versions:
17+
- name: v1
18+
schema:
19+
openAPIV3Schema:
20+
description: TestOperator is the Schema for the testoperators API.
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: TestOperatorSpec defines the desired state of TestOperator.
41+
properties:
42+
message:
43+
type: string
44+
type: object
45+
status:
46+
description: TestOperatorStatus defines the observed state of TestOperator.
47+
properties:
48+
echo:
49+
type: string
50+
type: object
51+
type: object
52+
served: true
53+
storage: true
54+
subresources:
55+
status: {}
56+
status:
57+
acceptedNames:
58+
kind: ""
59+
plural: ""
60+
conditions: null
61+
storedVersions: null

0 commit comments

Comments
 (0)