Skip to content

Commit

Permalink
restructure to use common-scripts and reduce Makefile complexity
Browse files Browse the repository at this point in the history
Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>
  • Loading branch information
rajatjindal committed May 6, 2024
1 parent a3ceefe commit 972e6e3
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 51 deletions.
26 changes: 10 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ up:
pod-status-check:
./scripts/pod-status-check.sh

./PHONY: workloads
workloads:
./scripts/workloads.sh
./PHONY: deploy-workloads-pushed-using-docker-build-push
deploy-workloads-pushed-using-docker-build-push:
./scripts/deploy-workloads.sh "workloads-pushed-using-docker-build-push"

./PHONY: workloads-spin-registry-push
workloads-spin-registry-push:
./scripts/workloads-spin-registry-push.sh
./PHONY: deploy-workloads-pushed-using-spin-registry-push
deploy-workloads-pushed-using-spin-registry-push:
./scripts/deploy-workloads.sh "workloads-pushed-using-spin-registry-push"

./PHONY: pod-terminates-test
pod-terminates-test:
Expand All @@ -54,18 +54,12 @@ pod-terminates-test:
integration-tests: prepare-cluster-and-images integration-docker-build-push-tests integration-spin-registry-push-tests

.PHONY: integration-docker-build-push-tests
integration-docker-build-push-tests: workloads pod-terminates-test
cargo test -p containerd-shim-spin-tests -- --nocapture
kubectl delete -f tests/workloads-common --wait --timeout 60s --ignore-not-found=true
kubectl delete -f tests/workloads-docker-build-push --wait --timeout 60s --ignore-not-found=true
kubectl wait pod --for=delete -l app=wasm-spin -l app=spin-keyvalue -l app=spin-outbound-redis -l app=spin-multi-trigger-app --timeout 60s
integration-docker-build-push-tests:
./scripts/run-integration-tests.sh "workloads-pushed-using-docker-build-push"

.PHONY: integration-spin-registry-push-tests pod-terminates-test
integration-spin-registry-push-tests: workloads-spin-registry-push
cargo test -p containerd-shim-spin-tests -- --nocapture
kubectl delete -f tests/workloads-common --wait --timeout 60s
kubectl delete -f tests/workloads-spin-registry-push --wait --timeout 60s
kubectl wait pod --for=delete -l app=wasm-spin -l app=spin-keyvalue -l app=spin-outbound-redis -l app=spin-multi-trigger-app --timeout 60s
integration-spin-registry-push-tests:
./scripts/run-integration-tests.sh "workloads-pushed-using-spin-registry-push"

.PHONY: prepare-cluster-and-images
prepare-cluster-and-images: check-bins move-bins up pod-status-check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ fi
# apply the workloads
echo ">>> apply workloads"
kubectl apply -f tests/workloads-common
kubectl apply -f tests/workloads-spin-registry-push

if [ "$1" == "workloads-pushed-using-spin-registry-push" ]; then
echo "deploying spin apps pushed to registry using 'spin registry push' command"
kubectl apply -f tests/workloads-pushed-using-spin-registry-push
else
echo "deploying spin apps pushed to registry using 'docker build && k3d image import' command"
kubectl apply -f tests/workloads-pushed-using-docker-build-push
fi

# wait for all the pods to be ready
kubectl wait --for=condition=ready --timeout=50s pod --all
Expand Down
21 changes: 21 additions & 0 deletions scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -euo pipefail

## Deploy workloads into k3d cluster
if [ "$1" == "workloads-pushed-using-spin-registry-push" ]; then
make deploy-workloads-pushed-using-spin-registry-push
else
make deploy-workloads-pushed-using-docker-build-push
fi



## Verify pods can be terminated successfully
make pod-terminates-test

## Run integration tests
cargo test -p containerd-shim-spin-tests -- --nocapture

## tests done, cleanup workloads for next test
make teardown-workloads
8 changes: 8 additions & 0 deletions scripts/teardown-workloads.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -euo pipefail

kubectl delete -f tests/workloads-common --wait --timeout 60s --ignore-not-found=true
kubectl delete -f tests/workloads-pushed-using-docker-build-push --wait --timeout 60s --ignore-not-found=true
kubectl delete -f tests/workloads-pushed-using-spin-registry-push --wait --timeout 60s --ignore-not-found=true
kubectl wait pod --for=delete -l app=wasm-spin -l app=spin-keyvalue -l app=spin-outbound-redis -l app=spin-multi-trigger-app --timeout 60s
34 changes: 0 additions & 34 deletions scripts/workloads.sh

This file was deleted.

1 change: 1 addition & 0 deletions tests/workloads-pushed-using-docker-build-push/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder has yaml file to apply workloads which are built using `docker build` and imported into k3d cluster using `k3d image import` command.
1 change: 1 addition & 0 deletions tests/workloads-pushed-using-spin-registry-push/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder has yaml file to apply workloads which are built using `spin build` and pushed to a registry, managed with k3d in CI, using `spin registry push` command.

0 comments on commit 972e6e3

Please sign in to comment.