Skip to content

Commit

Permalink
Merge pull request #426 from sergenyalcin/use-ssop-in-uptest
Browse files Browse the repository at this point in the history
Use family providers in uptest instead of monolith
  • Loading branch information
sergenyalcin authored Nov 21, 2023
2 parents 0137247 + 3be0bef commit 8c62362
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 20 deletions.
53 changes: 43 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ export SUBPACKAGES := $(SUBPACKAGES)
# Setup Kubernetes tools

KIND_VERSION = v0.15.0
UPTEST_VERSION = v0.5.0
UPTEST_VERSION = v0.6.1
# dependency for up
UP_VERSION = v0.19.2
UP_VERSION = v0.20.0
UP_CHANNEL = stable

export UP_VERSION := $(UP_VERSION)
Expand Down Expand Up @@ -188,20 +188,53 @@ uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
uptest-local:
@$(WARN) "this target is deprecated, please use 'make uptest' instead"

build-monolith:
@$(MAKE) build SUBPACKAGES=monolith LOAD_MONOLITH=true
build-provider.%:
@$(MAKE) build SUBPACKAGES="$$(tr ',' ' ' <<< $*)" LOAD_PACKAGES=true

local-deploy: build-monolith controlplane.up local.xpkg.deploy.provider.$(PROJECT_NAME)-monolith
@$(INFO) running locally built provider
@$(KUBECTL) wait provider.pkg $(PROJECT_NAME)-monolith --for condition=Healthy --timeout 5m
@$(KUBECTL) -n upbound-system wait --for=condition=Available deployment --all --timeout=5m
@$(OK) running locally built provider
XPKG_SKIP_DEP_RESOLUTION := true

local-deploy.%: controlplane.up
@for api in $$(tr ',' ' ' <<< $*); do \
$(MAKE) local.xpkg.deploy.provider.$(PROJECT_NAME)-$${api}; \
$(INFO) running locally built $(PROJECT_NAME)-$${api}; \
$(KUBECTL) wait provider.pkg $(PROJECT_NAME)-$${api} --for condition=Healthy --timeout 5m; \
$(KUBECTL) -n upbound-system wait --for=condition=Available deployment --all --timeout=5m; \
$(OK) running locally built $(PROJECT_NAME)-$${api}; \
done || $(FAIL)

local-deploy: build-provider.monolith local-deploy.monolith

# 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 ~/gcp-sa.json)
# - UPTEST_EXAMPLE_LIST, a comma-separated list of examples to test
# - UPTEST_DATASOURCE_PATH, see https://github.com/upbound/uptest#injecting-dynamic-values-and-datasource
e2e: local-deploy uptest
family-e2e:
@$(INFO) Removing everything under $(XPKG_OUTPUT_DIR) and $(OUTPUT_DIR)/cache...
@rm -fR $(XPKG_OUTPUT_DIR)
@rm -fR $(OUTPUT_DIR)/cache
@(INSTALL_APIS=""; \
for m in $$(tr ',' ' ' <<< $${UPTEST_EXAMPLE_LIST}); do \
$(INFO) Processing the example manifest "$${m}"; \
for api in $$(sed -nE 's/^apiVersion: *(.+)/\1/p' "$${m}" | cut -d. -f1); do \
if [[ $${api} == "v1" ]]; then \
$(INFO) v1 is not a valid provider. Skipping...; \
continue; \
fi; \
if [[ $${INSTALL_APIS} =~ " $${api} " ]]; then \
$(INFO) Resource provider $(PROJECT_NAME)-$${api} is already installed. Skipping...; \
continue; \
fi; \
$(INFO) Installing the family resource $(PROJECT_NAME)-$${api} for the test file: $${m}; \
INSTALL_APIS="$${INSTALL_APIS} $${api} "; \
done; \
done; \
INSTALL_APIS="config,$$(tr ' ' ',' <<< $${INSTALL_APIS})"; \
INSTALL_APIS="$$(tr -s ',' <<< "$${INSTALL_APIS}")"; \
$(INFO) Building and deploying resource providers for the short API groups: $${INSTALL_APIS}; \
$(MAKE) build-provider.$${INSTALL_APIS} local-deploy.$${INSTALL_APIS}) || $(FAIL)
$(MAKE) uptest

e2e: family-e2e

# TODO: please move this to the common build submodule
# once the use cases mature
Expand Down
22 changes: 12 additions & 10 deletions cluster/images/provider-gcp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ img.build:
@$(INFO) Family base image to build: $(IMAGE)
@$(INFO) Building image $${IMAGE}; \
$(MAKE) BUILD_ARGS="--load ${BUILD_ARGS}" IMAGE=$${IMAGE} XPKG_REG_ORGS=$(XPKG_REG_ORGS) img.build.shared; \
if [[ "$${LOAD_MONOLITH}" == "true" ]]; then \
$(MAKE) batch-process SUBPACKAGES=monolith BATCH_PLATFORMS=$(PLATFORM) BUILD_ONLY=true STORE_PACKAGE=monolith && \
export t=$$(docker load -qi "$(XPKG_OUTPUT_DIR)/$(PLATFORM)/$(PROJECT_NAME)-monolith-$(VERSION).xpkg") && \
docker tag $${t##*:} $(BUILD_REGISTRY)/$(PROJECT_NAME)-monolith-$(ARCH); \
if [[ "$${LOAD_PACKAGES}" == "true" ]]; then \
$(MAKE) batch-process SUBPACKAGES="$(SUBPACKAGES)" BATCH_PLATFORMS=$(PLATFORM) BUILD_ONLY=true STORE_PACKAGES="$$(tr ' ' ',' <<< "$(SUBPACKAGES)")" && \
for s in $(SUBPACKAGES); do \
export t=$$(docker load -qi "$(XPKG_OUTPUT_DIR)/$(PLATFORM)/$(PROJECT_NAME)-$${s}-$(VERSION).xpkg") && \
docker tag $${t##*:} $(BUILD_REGISTRY)/$(PROJECT_NAME)-$${s}-$(ARCH); \
done; \
fi || $(FAIL)
@$(OK) docker build $${IMAGE};
@$(OK) docker build $${IMAGE}

img.build.shared:
@cp Dockerfile $(IMAGE_TEMP_DIR) || $(FAIL)
Expand Down Expand Up @@ -59,19 +61,19 @@ ifeq (-,$(findstring -,$(VERSION)))
DEP_CONSTRAINT = >= 0.0.0-0
endif
BUILD_ONLY ?= false
STORE_PACKAGE ?= ""
STORE_PACKAGES ?= ""
batch-process: $(UP)
@$(INFO) Batch processing smaller provider packages for: $(SUBPACKAGES)
@$(INFO) Batch processing smaller provider packages for: "$(SUBPACKAGES)"
@mkdir -p "$(XPKG_OUTPUT_DIR)/$(PLATFORM)" && \
$(UP) xpkg batch --smaller-providers $$(echo -n $(SUBPACKAGES) | tr ' ' ',') \
$(UP) xpkg batch --smaller-providers "$$(tr ' ' ',' <<< "$(SUBPACKAGES)")" \
--family-base-image $(BUILD_REGISTRY)/$(PROJECT_NAME) \
--platform $(BATCH_PLATFORMS) \
--provider-name $(PROJECT_NAME) \
--family-package-url-format $(XPKG_REG_ORGS)/%s:$(VERSION) \
--package-repo-override monolith=$(PROJECT_NAME) --package-repo-override config=provider-family-$(PROVIDER_NAME) \
--provider-bin-root $(OUTPUT_DIR)/bin \
--output-dir $(XPKG_OUTPUT_DIR) \
--store-packages $(STORE_PACKAGE) \
--store-packages "$(STORE_PACKAGES)" \
--build-only=$(BUILD_ONLY) \
--examples-root $(ROOT_DIR)/examples \
--examples-group-override monolith=* --examples-group-override config=providerconfig \
Expand All @@ -82,4 +84,4 @@ batch-process: $(UP)
--template-var XpkgRegOrg=$(XPKG_REG_ORGS) --template-var DepConstraint="$(DEP_CONSTRAINT)" --template-var ProviderName=$(PROVIDER_NAME) \
--concurrency $(CONCURRENCY) \
--push-retry 10 || $(FAIL)
@$(OK) Done processing smaller provider packages for: $(SUBPACKAGES)
@$(OK) Done processing smaller provider packages for: "$(SUBPACKAGES)"

0 comments on commit 8c62362

Please sign in to comment.