Add more integration tests

Add tests for main, app, accessory, traefik and lock commands.
Other commands are generally covered by the main tests.

Also adds some changes to speed up the integration specs:
- Use a persistent volume for the registry so we can push images to to
reuse between runs (also gets around docker hub rate limits)
- Use persistent volume for mrsk gem install, to avoid re-installing
between tests
- Shorter stop wait time
- Shorter connection timeouts on the load balancer

Takes just over 2 minutes to run all tests locally on an M1 Mac
after docker caches are primed.
This commit is contained in:
Donal McBreen
2023-04-24 14:34:46 +01:00
parent 059388cb02
commit 7cd25fd163
18 changed files with 290 additions and 76 deletions

View File

@@ -0,0 +1 @@
SECRET_TOKEN=1234

View File

@@ -1,4 +1,4 @@
FROM nginx:1-alpine-slim
FROM registry:4443/nginx:1-alpine-slim
COPY default.conf /etc/nginx/conf.d/default.conf

View File

@@ -17,3 +17,11 @@ traefik:
args:
accesslog: true
accesslog.format: json
image: registry:4443/traefik:v2.9
accessories:
busybox:
image: registry:4443/busybox:1.36.0
cmd: sh -c 'echo "Starting busybox..."; trap exit term; while true; do sleep 1; done'
roles:
- web
stop_wait_time: 1

View File

@@ -1,9 +1,5 @@
#!/bin/bash
cd /mrsk && gem build mrsk.gemspec -o /tmp/mrsk.gem && gem install /tmp/mrsk.gem
dockerd &
trap "pkill -f sleep" term
sleep infinity & wait
exec sleep infinity

View File

@@ -0,0 +1,23 @@
#!/bin/bash
install_mrsk() {
cd /mrsk && gem build mrsk.gemspec -o /tmp/mrsk.gem && gem install /tmp/mrsk.gem
}
# Push the images to a persistent volume on the registry container
# This is to work around docker hub rate limits
push_image_to_registry_4443() {
# Check if the image is in the registry without having to pull it
if ! stat /registry/docker/registry/v2/repositories/$1/_manifests/tags/$2/current/link > /dev/null; then
hub_tag=$1:$2
registry_4443_tag=registry:4443/$1:$2
docker pull $hub_tag
docker tag $hub_tag $registry_4443_tag
docker push $registry_4443_tag
fi
}
install_mrsk
push_image_to_registry_4443 nginx 1-alpine-slim
push_image_to_registry_4443 traefik v2.9
push_image_to_registry_4443 busybox 1.36.0