Skip to content

Commit

Permalink
feat(tests/images): add spin-static-assets app; use for archive layer…
Browse files Browse the repository at this point in the history
… testing

Signed-off-by: Vaughn Dice <[email protected]>
  • Loading branch information
vdice committed Jun 3, 2024
1 parent 1dea4f7 commit 3f3d291
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 7 deletions.
1 change: 1 addition & 0 deletions images/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.spin
34 changes: 34 additions & 0 deletions images/spin-static-assets/assets/jabberwocky.txt
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions images/spin-static-assets/spin.toml
Original file line number Diff line number Diff line change
@@ -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 = "/" }]
2 changes: 0 additions & 2 deletions scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ else
make deploy-workloads-pushed-using-docker-build-push
fi



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

Expand Down
10 changes: 7 additions & 3 deletions scripts/up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -29,6 +29,10 @@ for i in "${!DOCKER_IMAGES[@]}"; do
## images pushed as localhost:5000/<namespace>/<app>:<version>
## can be pulled as registry:5000/<namespace>/<app>:<version> 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

Expand Down
38 changes: 37 additions & 1 deletion tests/workloads-pushed-using-docker-build-push/workloads.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,40 @@ spec:
port: 80
targetPort: 80
selector:
app: spin-multi-trigger-app
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
38 changes: 37 additions & 1 deletion tests/workloads-pushed-using-spin-registry-push/workloads.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,40 @@ spec:
port: 80
targetPort: 80
selector:
app: spin-multi-trigger-app
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

0 comments on commit 3f3d291

Please sign in to comment.