Skip to content

Commit

Permalink
Update uptest to v1.1.2 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaessert authored Oct 7, 2024
1 parent 6b3cdda commit cff6335
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "build"]
path = build
url = https://github.com/upbound/build
url = https://github.com/crossplane/build.git
76 changes: 64 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ PLATFORMS ?= linux_amd64
# ====================================================================================
# Setup Kubernetes tools

UP_VERSION = v0.31.0
UP_VERSION = v0.32.1
UP_CHANNEL = stable
UPTEST_VERSION = v0.11.1
UPTEST_VERSION = v1.1.2
UPTEST_CLAIMS ?= examples/app-claim.yaml
CROSSPLANE_CLI_VERSION = v1.17.1

-include build/makelib/k8s_tools.mk
# ====================================================================================
Expand All @@ -27,8 +29,13 @@ XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/upbound
XPKGS = $(PROJECT_NAME)
-include build/makelib/xpkg.mk

CROSSPLANE_VERSION = v1.17.1-up.1
CROSSPLANE_CHART_REPO = https://charts.upbound.io/stable
CROSSPLANE_CHART_NAME = universal-crossplane
CROSSPLANE_NAMESPACE = upbound-system
CROSSPLANE_ARGS = "--enable-usages"
KIND_CLUSTER_NAME ?= uptest-$(PROJECT_NAME)

-include build/makelib/local.xpkg.mk
-include build/makelib/controlplane.mk

Expand Down Expand Up @@ -58,21 +65,66 @@ build.init: $(UP)
# ====================================================================================
# End to End Testing

uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
@$(INFO) running automated tests
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e examples/app-claim.yaml --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL)
@$(OK) running automated tests
UPTEST_EXTRA_ARGS ?=

UPTEST_COMMAND = SKIP_DEPLOY_ARGO=$(SKIP_DEPLOY_ARGO) \
KUBECTL=$(KUBECTL) \
CHAINSAW=$(CHAINSAW) \
CROSSPLANE_CLI=$(CROSSPLANE_CLI) \
CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) \
YQ=$(YQ) \
$(UPTEST) e2e $(UPTEST_CLAIMS) \
--data-source="${UPTEST_DATASOURCE_PATH}" \
--setup-script=$(SETUP_SCRIPT) \
--default-timeout=2400s \
--skip-update \
--skip-import \
$(UPTEST_EXTRA_ARGS)

# This target requires the following environment variables to be set:
# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials)
e2e: build controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest

render:
crossplane beta render examples/app-claim.yaml apis/composition.yaml examples/functions.yaml -r
# - To ensure the proper functioning of the end-to-end test resource pre-deletion hook, it is crucial to arrange your resources appropriately.
# You can check the basic implementation here: https://github.com/upbound/uptest/blob/main/internal/templates/01-delete.yaml.tmpl.
# - UPTEST_DATASOURCE_PATH (optional), see https://github.com/upbound/uptest#injecting-dynamic-values-and-datasource
SETUP_SCRIPT ?= test/setup.sh
uptest: $(UPTEST) $(KUBECTL) $(CHAINSAW) $(CROSSPLANE_CLI) $(YQ)
@$(INFO) running automated tests
$(UPTEST_COMMAND) || $(FAIL)
@$(OK) running automated tests

yamllint:
# Run uptest together with all dependencies. Use `make e2e UPTEST_EXTRA_ARGS=--skip-delete` to skip deletion of resources.
e2e: build controlplane.down controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest #

render: $(CROSSPLANE_CLI) ${YQ}
@indir="./examples"; \
for file in $$(find $$indir -type f -name '*.yaml' ); do \
doc_count=$$(grep -c '^---' "$$file"); \
if [[ $$doc_count -gt 0 ]]; then \
continue; \
fi; \
COMPOSITION=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/composition-path"' $$file); \
FUNCTION=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/function-path"' $$file); \
ENVIRONMENT=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/environment-path"' $$file); \
OBSERVE=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/observe-path"' $$file); \
if [[ "$$ENVIRONMENT" == "null" ]]; then \
ENVIRONMENT=""; \
fi; \
if [[ "$$OBSERVE" == "null" ]]; then \
OBSERVE=""; \
fi; \
if [[ "$$COMPOSITION" == "null" || "$$FUNCTION" == "null" ]]; then \
continue; \
fi; \
ENVIRONMENT=$${ENVIRONMENT=="null" ? "" : $$ENVIRONMENT}; \
OBSERVE=$${OBSERVE=="null" ? "" : $$OBSERVE}; \
$(CROSSPLANE_CLI) render $$file $$COMPOSITION $$FUNCTION $${ENVIRONMENT:+-e $$ENVIRONMENT} $${OBSERVE:+-o $$OBSERVE} -x; \
done

yamllint: ## Static yamllint check
@$(INFO) running yamllint
@yamllint ./apis || $(FAIL)
@$(OK) running yamllint

.PHONY: uptest e2e render yamllint

help.local:
@grep -E '^[a-zA-Z_-]+.*:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
3 changes: 3 additions & 0 deletions examples/app-claim.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
apiVersion: platform.upbound.io/v1alpha1
kind: App
metadata:
annotations:
render.crossplane.io/composition-path: apis/composition.yaml
render.crossplane.io/function-path: examples/functions.yaml
name: configuration-app
namespace: default
spec:
Expand Down

0 comments on commit cff6335

Please sign in to comment.