From 3f3d2919604b7424545b24d1bf9dbb6bf352ff94 Mon Sep 17 00:00:00 2001 From: Vaughn Dice Date: Mon, 3 Jun 2024 11:25:29 -0600 Subject: [PATCH] feat(tests/images): add spin-static-assets app; use for archive layer testing Signed-off-by: Vaughn Dice --- images/.gitignore | 1 + .../spin-static-assets/assets/jabberwocky.txt | 34 +++++++++++++++++ images/spin-static-assets/spin.toml | 18 +++++++++ scripts/run-integration-tests.sh | 2 - scripts/up.sh | 10 +++-- .../workloads.yaml | 38 ++++++++++++++++++- .../workloads.yaml | 38 ++++++++++++++++++- 7 files changed, 134 insertions(+), 7 deletions(-) create mode 100644 images/.gitignore create mode 100644 images/spin-static-assets/assets/jabberwocky.txt create mode 100644 images/spin-static-assets/spin.toml diff --git a/images/.gitignore b/images/.gitignore new file mode 100644 index 00000000..76225928 --- /dev/null +++ b/images/.gitignore @@ -0,0 +1 @@ +**/.spin \ No newline at end of file diff --git a/images/spin-static-assets/assets/jabberwocky.txt b/images/spin-static-assets/assets/jabberwocky.txt new file mode 100644 index 00000000..08a0eb5e --- /dev/null +++ b/images/spin-static-assets/assets/jabberwocky.txt @@ -0,0 +1,34 @@ +'Twas brillig, and the slithy toves + Did gyre and gimble in the wabe: +All mimsy were the borogoves, + And the mome raths outgrabe. + +"Beware the Jabberwock, my son! + The jaws that bite, the claws that catch! +Beware the Jubjub bird, and shun + The frumious Bandersnatch!" + +He took his vorpal sword in hand; + Long time the manxome foe he sought- +So rested he by the Tumtum tree + And stood awhile in thought. + +And, as in uffish thought he stood, + The Jabberwock, with eyes of flame, +Came whiffling through the tulgey wood, + And burbled as it came! + +One, two! One, two! And through and through + The vorpal blade went snicker-snack! +He left it dead, and with its head + He went galumphing back. + +"And hast thou slain the Jabberwock? + Come to my arms, my beamish boy! +O frabjous day! Callooh! Callay!" + He chortled in his joy. + +'Twas brillig, and the slithy toves + Did gyre and gimble in the wabe: +All mimsy were the borogoves, + And the mome raths outgrabe. diff --git a/images/spin-static-assets/spin.toml b/images/spin-static-assets/spin.toml new file mode 100644 index 00000000..ef7eb521 --- /dev/null +++ b/images/spin-static-assets/spin.toml @@ -0,0 +1,18 @@ +spin_manifest_version = 2 + +[application] +name = "spin-static-assets" +version = "0.1.0" +authors = ["SpinKube Engineering Team"] + +[application.trigger.http] +base = "/" + +[[trigger.http]] +id = "trigger-static-fileserver" +component = "static-fileserver" +route = "/..." + +[component.static-fileserver] +source = { url = "https://github.com/fermyon/spin-fileserver/releases/download/v0.3.0/spin_static_fs.wasm", digest = "sha256:ef88708817e107bf49985c7cefe4dd1f199bf26f6727819183d5c996baa3d148" } +files = [{ source = "assets", destination = "/" }] diff --git a/scripts/run-integration-tests.sh b/scripts/run-integration-tests.sh index efe5cbfb..c97729c3 100755 --- a/scripts/run-integration-tests.sh +++ b/scripts/run-integration-tests.sh @@ -9,8 +9,6 @@ else make deploy-workloads-pushed-using-docker-build-push fi - - ## Verify pods can be terminated successfully make pod-terminates-test diff --git a/scripts/up.sh b/scripts/up.sh index fc86a2c2..3da0bd94 100755 --- a/scripts/up.sh +++ b/scripts/up.sh @@ -5,9 +5,9 @@ set -euo pipefail cluster_name="test-cluster" # name of the k3d cluster dockerfile_path="deployments/k3d" # path to the Dockerfile -DOCKER_IMAGES=("spin" "spin-keyvalue" "spin-outbound-redis" "spin-multi-trigger-app") -OUT_DIRS=("test/out_spin" "test/out_spin_keyvalue" "test/out_spin_outbound_redis" "test/out_spin_multi_trigger_app") -IMAGES=("spin-hello-world" "spin-keyvalue" "spin-outbound-redis" "spin-multi-trigger-app") +DOCKER_IMAGES=("spin" "spin-keyvalue" "spin-outbound-redis" "spin-multi-trigger-app" "spin-static-assets") +OUT_DIRS=("test/out_spin" "test/out_spin_keyvalue" "test/out_spin_outbound_redis" "test/out_spin_multi_trigger_app" "test/out_spin_static_assets") +IMAGES=("spin-hello-world" "spin-keyvalue" "spin-outbound-redis" "spin-multi-trigger-app" "spin-static-assets") # build the Docker image for the k3d cluster docker build -t k3d-shim-test "$dockerfile_path" @@ -29,6 +29,10 @@ for i in "${!DOCKER_IMAGES[@]}"; do ## images pushed as localhost:5000//: ## can be pulled as registry:5000//: from within k3d cluster spin build -f "./images/${DOCKER_IMAGES[$i]}/spin.toml" + ## For the spin-static-assets app, use archive layers to test this functionality in the shim + if [ "${i}" == "spin-static-assets" ]; then + export SPIN_OCI_ARCHIVE_LAYERS=1 + fi spin registry push "localhost:5000/spin-registry-push/${IMAGES[$i]}:latest" -f "./images/${DOCKER_IMAGES[$i]}/spin.toml" -k done diff --git a/tests/workloads-pushed-using-docker-build-push/workloads.yaml b/tests/workloads-pushed-using-docker-build-push/workloads.yaml index 5b1df894..dc68afe2 100644 --- a/tests/workloads-pushed-using-docker-build-push/workloads.yaml +++ b/tests/workloads-pushed-using-docker-build-push/workloads.yaml @@ -209,4 +209,40 @@ spec: port: 80 targetPort: 80 selector: - app: spin-multi-trigger-app \ No newline at end of file + app: spin-multi-trigger-app +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: spin-static-assets +spec: + replicas: 1 + selector: + matchLabels: + app: spin-static-assets + template: + metadata: + labels: + app: spin-static-assets + spec: + runtimeClassName: wasmtime-spin + containers: + - name: spin-static-assets + image: docker.io/library/spin-static-assets:latest + imagePullPolicy: IfNotPresent + command: ["/"] + ports: + - containerPort: 80 +--- +apiVersion: v1 +kind: Service +metadata: + name: spin-static-assets +spec: + type: LoadBalancer + ports: + - protocol: TCP + port: 80 + targetPort: 80 + selector: + app: spin-static-assets diff --git a/tests/workloads-pushed-using-spin-registry-push/workloads.yaml b/tests/workloads-pushed-using-spin-registry-push/workloads.yaml index 4ec22cff..6b30502c 100644 --- a/tests/workloads-pushed-using-spin-registry-push/workloads.yaml +++ b/tests/workloads-pushed-using-spin-registry-push/workloads.yaml @@ -209,4 +209,40 @@ spec: port: 80 targetPort: 80 selector: - app: spin-multi-trigger-app \ No newline at end of file + app: spin-multi-trigger-app +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: spin-static-assets +spec: + replicas: 1 + selector: + matchLabels: + app: spin-static-assets + template: + metadata: + labels: + app: spin-static-assets + spec: + runtimeClassName: wasmtime-spin + containers: + - name: spin-static-assets + image: test-registry:5000/spin-registry-push/spin-static-assets:latest + imagePullPolicy: IfNotPresent + command: ["/"] + ports: + - containerPort: 80 +--- +apiVersion: v1 +kind: Service +metadata: + name: spin-static-assets +spec: + type: LoadBalancer + ports: + - protocol: TCP + port: 80 + targetPort: 80 + selector: + app: spin-static-assets \ No newline at end of file