Skip to content

Commit f00a5b3

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

Some content is hidden

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

47 files changed

+2307
-373
lines changed

Makefile

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,41 @@ test-unit: $(SETUP_ENVTEST) envtest-k8s-bins #HELP Run the unit tests
246246
$(UNIT_TEST_DIRS) \
247247
-test.gocoverdir=$(COVERAGE_UNIT_DIR)
248248

249+
TEST_OPERATOR_DIR=./testdata/operators/test-operator
250+
251+
.PHONY: test-operator-test-unit
252+
test-operator-test-unit: $(SETUP_ENVTEST) envtest-k8s-bins
253+
KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use -p path $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE))" \
254+
CGO_ENABLED=1 go test -tags '$(GO_BUILD_TAGS)' -count=1 -race -short $(TEST_OPERATOR_DIR)/...
255+
256+
.PHONY: test-operator-build-controllers
257+
test-operator-build-controllers:
258+
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
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/v2.0.0/manager $(TEST_OPERATOR_DIR)/v2/cmd/main.go
260+
261+
.PHONY: test-operator-generate-manifests
262+
test-operator-generate-manifests: $(CONTROLLER_GEN)
263+
# generate resources crds
264+
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) crd paths="$(TEST_OPERATOR_DIR)/api/v1/..." output:dir=$(TEST_OPERATOR_DIR)/charts/v1/crds
265+
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) crd paths="$(TEST_OPERATOR_DIR)/api/..." output:dir=$(TEST_OPERATOR_DIR)/charts/v2/crds
266+
267+
# generate other resources
268+
$(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
269+
$(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
270+
271+
.PHONY: test-operator-generate-bundles
272+
test-operator-generate-bundles: test-operator-generate-manifests $(OPERATOR_SDK)
273+
# generate bundles
274+
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
275+
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
276+
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
277+
rm -rf bundle.Dockerfile
278+
249279
.PHONY: image-registry
250280
E2E_REGISTRY_IMAGE=localhost/e2e-test-registry:devel
251281
image-registry: export GOOS=linux
252282
image-registry: export GOARCH=amd64
253-
image-registry: ## Build the testdata catalog used for e2e tests and push it to the image registry
283+
image-registry: test-operator-build-controllers test-operator-generate-bundles ## Build the testdata catalog used for e2e tests and push it to the image registry
254284
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
255285
$(CONTAINER_RUNTIME) build -f ./testdata/Dockerfile -t $(E2E_REGISTRY_IMAGE) ./testdata
256286
$(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/bundles/test-operator/v1.0.0/manifests/bundle.configmap.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

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

Lines changed: 0 additions & 28 deletions
This file was deleted.

testdata/images/bundles/test-operator/v1.0.0/manifests/testoperator.clusterserviceversion.yaml

Lines changed: 0 additions & 141 deletions
This file was deleted.

testdata/images/bundles/test-operator/v1.0.0/metadata/annotations.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

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

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)