Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 126 additions & 4 deletions packages/kn-plugin-workflow/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,38 @@ SET_VERSION := $(METADATA_PATH).PluginVersion=$(PLUGIN_VERSION
SET_KOGITO_VERSION := $(METADATA_PATH).KogitoVersion=$(KOGITO_VERSION)
LDFLAGS := "-X $(SET_QUARKUS_PLATFORM_GROUP_ID) -X $(SET_QUARKUS_VERSION) -X $(SET_VERSION) -X $(SET_DEV_MODE_IMAGE) -X $(SET_KOGITO_VERSION) -X $(SET_BUILDER_IMAGE)"

KIND_VERSION ?= v0.20.0
OLM_VERSION = v0.31.0
KIND_VERSION ?= v0.20.0
KIND_CLUSTER ?= kind
OLM_VERSION = v0.31.0

# Optional: set the following variables to install the operator from a custom OLM CatalogSource
# (product/OSL builds) instead of the public operatorhubio-catalog.
# Only CATALOG_INDEX_IMAGE is required to activate the custom-catalog install path.
#
# When CATALOG_INDEX_IMAGE is set, kind-preload-images will also:
# - Pull OPERATOR_IMAGE (proxy ref) and retag it as OPERATOR_IMAGE_RHT (registry.redhat.io ref
# embedded in the CSV), then load it into kind so containerd resolves it locally by digest.
# - Pull OPERATOR_BUNDLE_IMAGE (proxy ref) and load it into kind tagged as OPERATOR_BUNDLE_IMAGE_STAGE
# (registry.stage.redhat.io ref embedded in the IIB catalog), so OLM bundle-unpack jobs resolve
# the image locally without hitting the stage registry.
# - Pull KUBE_RBAC_PROXY_PRODUCT (proxy ref) and retag it as KUBE_RBAC_PROXY_PRODUCT_RHT
# (registry.redhat.io ref embedded in the CSV), then load it into kind.
#
# OPERATOR_IMAGE - proxy-accessible source image (registry-proxy.engineering.redhat.com/...)
# OPERATOR_IMAGE_RHT - registry.redhat.io target ref (must match what the CSV embeds)
# OPERATOR_BUNDLE_IMAGE - proxy-accessible source image (registry-proxy.engineering.redhat.com/...)
# OPERATOR_BUNDLE_IMAGE_STAGE - registry.stage.redhat.io target ref (must match what the IIB catalog embeds)
# KUBE_RBAC_PROXY_PRODUCT - proxy-accessible source image (registry-proxy.engineering.redhat.com/...)
# KUBE_RBAC_PROXY_PRODUCT_RHT - registry.redhat.io target ref (must match what the CSV embeds)
CATALOG_INDEX_IMAGE ?=
OPERATOR_BUNDLE_IMAGE ?=
OPERATOR_BUNDLE_IMAGE_STAGE ?=
OPERATOR_IMAGE ?=
OPERATOR_IMAGE_RHT ?=
KUBE_RBAC_PROXY_PRODUCT ?=
KUBE_RBAC_PROXY_PRODUCT_RHT ?=
KUBE_RBAC_PROXY_SRC := quay.io/brancz/kube-rbac-proxy:v0.13.1
KUBE_RBAC_PROXY_DST := gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1

ARCH := $(shell uname -m)
ifeq ($(ARCH),arm64)
Expand Down Expand Up @@ -72,6 +102,7 @@ test-e2e:
@$(MAKE) install-kind
@$(MAKE) create-cluster
@$(MAKE) install-operator-framework
@$(MAKE) kind-preload-images
@$(MAKE) go-test-e2e
@$(MAKE) go-test-e2e-report

Expand All @@ -80,23 +111,114 @@ test-e2e:
install-kind:
command -v kind >/dev/null || go install sigs.k8s.io/kind@$(KIND_VERSION)

KIND_CLUSTER_CONFIG := e2e-tests/kind-cluster-config.yaml
CONTAINERD_CERTS_SRC := e2e-tests/containerd-certs.d
CONTAINERD_CERTS_DST := /etc/containerd/certs.d

.PHONY: create-cluster
create-cluster: install-kind
kind create cluster
@if [ -n "$(CATALOG_INDEX_IMAGE)" ]; then \
echo "Creating kind cluster with containerd v2 registry config for internal registry..."; \
kind create cluster --config $(KIND_CLUSTER_CONFIG); \
echo "Copying registry TLS/mirror config into kind node..."; \
docker cp $(CONTAINERD_CERTS_SRC)/. $(KIND_CLUSTER)-control-plane:$(CONTAINERD_CERTS_DST)/; \
echo "Copying docker credentials into kind node for authenticated registry pulls..."; \
DOCKER_CFG=$${DOCKER_CONFIG:-$(HOME)/.docker}/config.json; \
docker cp $$DOCKER_CFG $(KIND_CLUSTER)-control-plane:/var/lib/kubelet/config.json; \
docker exec $(KIND_CLUSTER)-control-plane systemctl restart containerd; \
echo "Waiting for containerd to restart..."; \
sleep 5; \
else \
kind create cluster; \
fi

.PHONY: install-operator-framework
install-operator-framework:
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/$(OLM_VERSION)/install.sh | bash -s $(OLM_VERSION)

# Optional: set TEST_SKIP to a regex to skip matching tests, e.g. TEST_SKIP=Quarkus
TEST_SKIP ?=

.PHONY: go-test-e2e
go-test-e2e:
rm -rf dist-tests-e2e
mkdir dist-tests-e2e
go test -v ./e2e-tests/... -tags e2e_tests -timeout 20m 2>&1 | tee ./dist-tests-e2e/go-test-output-e2e.txt
CATALOG_INDEX_IMAGE=$(CATALOG_INDEX_IMAGE) \
OPERATOR_BUNDLE_IMAGE=$(OPERATOR_BUNDLE_IMAGE) \
OPERATOR_IMAGE=$(OPERATOR_IMAGE) \
go test -v ./e2e-tests/... -tags e2e_tests -timeout 20m \
$(if $(TEST_SKIP),-skip $(TEST_SKIP)) \
2>&1 | tee ./dist-tests-e2e/go-test-output-e2e.txt

.PHONY: go-test-e2e-report
go-test-e2e-report:
go run github.com/jstemmer/go-junit-report/v2 \
-set-exit-code \
-in ./dist-tests-e2e/go-test-output-e2e.txt \
-out ./dist-tests-e2e/junit-report-it.xml

.PHONY: kind-preload-images
kind-preload-images:
@if [ -n "$(KUBE_RBAC_PROXY_SRC)" ] && [ -n "$(KUBE_RBAC_PROXY_DST)" ]; then \
echo "Preloading kube-rbac-proxy image $(KUBE_RBAC_PROXY_SRC) -> $(KUBE_RBAC_PROXY_DST) into kind..."; \
docker pull $(KUBE_RBAC_PROXY_SRC); \
docker tag $(KUBE_RBAC_PROXY_SRC) $(KUBE_RBAC_PROXY_DST); \
docker save $(KUBE_RBAC_PROXY_DST) -o /tmp/kube-rbac-proxy.tar; \
docker exec -i $(KIND_CLUSTER)-control-plane ctr --namespace k8s.io images import --digests - < /tmp/kube-rbac-proxy.tar; \
rm -f /tmp/kube-rbac-proxy.tar; \
fi
@if [ -n "$(CATALOG_INDEX_IMAGE)" ]; then \
echo "Preloading index image $(CATALOG_INDEX_IMAGE) into kind..."; \
docker pull $(CATALOG_INDEX_IMAGE); \
docker save $(CATALOG_INDEX_IMAGE) -o /tmp/catalog-index-image.tar; \
docker exec -i $(KIND_CLUSTER)-control-plane ctr --namespace k8s.io images import --digests - < /tmp/catalog-index-image.tar; \
rm -f /tmp/catalog-index-image.tar; \
fi
@if [ -n "$(OPERATOR_IMAGE)" ] && [ -n "$(OPERATOR_IMAGE_RHT)" ]; then \
echo "Preloading operator image $(OPERATOR_IMAGE) -> $(OPERATOR_IMAGE_RHT) into kind..."; \
docker pull $(OPERATOR_IMAGE); \
docker save $(OPERATOR_IMAGE) -o /tmp/operator-image.tar; \
OPERATOR_RHT_BASE=$$(echo "$(OPERATOR_IMAGE_RHT)" | cut -d'@' -f1); \
OPERATOR_RHT_DIGEST=$$(echo "$(OPERATOR_IMAGE_RHT)" | cut -d'@' -f2); \
docker exec -i $(KIND_CLUSTER)-control-plane ctr --namespace k8s.io images import --digests --base-name $$OPERATOR_RHT_BASE - < /tmp/operator-image.tar; \
MANIFEST_DIGEST=$$(docker exec $(KIND_CLUSTER)-control-plane ctr --namespace k8s.io images ls 2>/dev/null | grep "$$OPERATOR_RHT_BASE@" | grep "manifest.v1" | awk '{print $$1}' | head -1 | cut -d'@' -f2); \
if [ -n "$$MANIFEST_DIGEST" ] && [ "$$MANIFEST_DIGEST" != "$$OPERATOR_RHT_DIGEST" ]; then \
echo "Adding digest alias $$OPERATOR_RHT_DIGEST -> $$MANIFEST_DIGEST in containerd..."; \
docker exec $(KIND_CLUSTER)-control-plane ctr --namespace k8s.io images tag \
"$$OPERATOR_RHT_BASE@$$MANIFEST_DIGEST" \
"$$OPERATOR_RHT_BASE@$$OPERATOR_RHT_DIGEST"; \
fi; \
rm -f /tmp/operator-image.tar; \
fi
@if [ -n "$(OPERATOR_BUNDLE_IMAGE)" ] && [ -n "$(OPERATOR_BUNDLE_IMAGE_STAGE)" ]; then \
echo "Preloading bundle image $(OPERATOR_BUNDLE_IMAGE) -> $(OPERATOR_BUNDLE_IMAGE_STAGE) into kind..."; \
docker pull $(OPERATOR_BUNDLE_IMAGE); \
docker save $(OPERATOR_BUNDLE_IMAGE) -o /tmp/bundle-image.tar; \
BUNDLE_STAGE_BASE=$$(echo "$(OPERATOR_BUNDLE_IMAGE_STAGE)" | cut -d'@' -f1); \
BUNDLE_STAGE_DIGEST=$$(echo "$(OPERATOR_BUNDLE_IMAGE_STAGE)" | cut -d'@' -f2); \
docker exec -i $(KIND_CLUSTER)-control-plane ctr --namespace k8s.io images import --digests --base-name $$BUNDLE_STAGE_BASE - < /tmp/bundle-image.tar; \
MANIFEST_DIGEST=$$(docker exec $(KIND_CLUSTER)-control-plane ctr --namespace k8s.io images ls 2>/dev/null | grep "$$BUNDLE_STAGE_BASE@" | grep "manifest.v1" | awk '{print $$1}' | head -1 | cut -d'@' -f2); \
if [ -n "$$MANIFEST_DIGEST" ] && [ "$$MANIFEST_DIGEST" != "$$BUNDLE_STAGE_DIGEST" ]; then \
echo "Adding digest alias $$BUNDLE_STAGE_DIGEST -> $$MANIFEST_DIGEST in containerd..."; \
docker exec $(KIND_CLUSTER)-control-plane ctr --namespace k8s.io images tag \
"$$BUNDLE_STAGE_BASE@$$MANIFEST_DIGEST" \
"$$BUNDLE_STAGE_BASE@$$BUNDLE_STAGE_DIGEST"; \
fi; \
rm -f /tmp/bundle-image.tar; \
fi
@if [ -n "$(KUBE_RBAC_PROXY_PRODUCT)" ] && [ -n "$(KUBE_RBAC_PROXY_PRODUCT_RHT)" ]; then \
echo "Preloading product kube-rbac-proxy $(KUBE_RBAC_PROXY_PRODUCT) -> $(KUBE_RBAC_PROXY_PRODUCT_RHT) into kind..."; \
docker pull $(KUBE_RBAC_PROXY_PRODUCT); \
docker save $(KUBE_RBAC_PROXY_PRODUCT) -o /tmp/kube-rbac-proxy-product.tar; \
KUBE_RBAC_RHT_BASE=$$(echo "$(KUBE_RBAC_PROXY_PRODUCT_RHT)" | cut -d'@' -f1); \
KUBE_RBAC_RHT_DIGEST=$$(echo "$(KUBE_RBAC_PROXY_PRODUCT_RHT)" | cut -d'@' -f2); \
docker exec -i $(KIND_CLUSTER)-control-plane ctr --namespace k8s.io images import --digests --base-name $$KUBE_RBAC_RHT_BASE - < /tmp/kube-rbac-proxy-product.tar; \
MANIFEST_DIGEST=$$(docker exec $(KIND_CLUSTER)-control-plane ctr --namespace k8s.io images ls 2>/dev/null | grep "$$KUBE_RBAC_RHT_BASE@" | grep "manifest.v1" | awk '{print $$1}' | head -1 | cut -d'@' -f2); \
if [ -n "$$MANIFEST_DIGEST" ] && [ "$$MANIFEST_DIGEST" != "$$KUBE_RBAC_RHT_DIGEST" ]; then \
echo "Adding digest alias $$KUBE_RBAC_RHT_DIGEST -> $$MANIFEST_DIGEST in containerd..."; \
docker exec $(KIND_CLUSTER)-control-plane ctr --namespace k8s.io images tag \
"$$KUBE_RBAC_RHT_BASE@$$MANIFEST_DIGEST" \
"$$KUBE_RBAC_RHT_BASE@$$KUBE_RBAC_RHT_DIGEST"; \
fi; \
rm -f /tmp/kube-rbac-proxy-product.tar; \
fi
Loading
Loading