diff --git a/.gitignore b/.gitignore index 9a0f910a..e54a8a4b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ .vscode/ abra dist/ +tests/integration/.abra/catalogue vendor/ diff --git a/Makefile b/Makefile index c245e67a..020130f9 100644 --- a/Makefile +++ b/Makefile @@ -43,15 +43,3 @@ loc-author: sort -f | \ uniq -ic | \ sort -n - -int-core: - @docker run \ - -v $$(pwd):/src \ - --env-file .e2e.env \ - debian:bullseye-slim \ - sh -c "\ - apt update && apt install -y wget curl git; echo ""; echo ""; \ - git config --global user.email 'e2e@coopcloud.tech'; \ - git config --global user.name 'e2e'; \ - cd /src/tests/integration && bash core.sh -- --dev \ - " diff --git a/tests/integration/.abra/servers/server1/gitea1.env b/tests/integration/.abra/servers/server1/gitea1.env new file mode 100644 index 00000000..8c5387c6 --- /dev/null +++ b/tests/integration/.abra/servers/server1/gitea1.env @@ -0,0 +1 @@ +TYPE=gitea diff --git a/tests/integration/.abra/servers/server1/wp1.env b/tests/integration/.abra/servers/server1/wp1.env new file mode 100644 index 00000000..dfb38a13 --- /dev/null +++ b/tests/integration/.abra/servers/server1/wp1.env @@ -0,0 +1 @@ +TYPE=wordpress diff --git a/tests/integration/.abra/servers/server2/wp2.env b/tests/integration/.abra/servers/server2/wp2.env new file mode 100644 index 00000000..dfb38a13 --- /dev/null +++ b/tests/integration/.abra/servers/server2/wp2.env @@ -0,0 +1 @@ +TYPE=wordpress diff --git a/tests/integration/.envrc.sample b/tests/integration/.envrc.sample new file mode 100644 index 00000000..f16b6c15 --- /dev/null +++ b/tests/integration/.envrc.sample @@ -0,0 +1,4 @@ +GANDI_TOKEN=... +HCLOUD_TOKEN=... +REGISTRY_PASSWORD=... +REGISTRY_USERNAME=... diff --git a/tests/integration/Dockerfile b/tests/integration/Dockerfile new file mode 100644 index 00000000..87375592 --- /dev/null +++ b/tests/integration/Dockerfile @@ -0,0 +1,7 @@ +FROM debian:bullseye-slim + +RUN apt update && apt install -y wget curl git; + +RUN git config --global user.email "integration-tests@coopcloud.tech"; + +RUN git config --global user.name "integration-tests"; diff --git a/tests/integration/README.md b/tests/integration/README.md new file mode 100644 index 00000000..e1447840 --- /dev/null +++ b/tests/integration/README.md @@ -0,0 +1,4 @@ +# integration tests + +- `cp .envrc.sample .envrc` (fill out values && `direnv allow`) +- `TARGET=install.sh make` (ensure `docker context use default`) diff --git a/tests/integration/app.sh b/tests/integration/app.sh new file mode 100755 index 00000000..851d9b49 --- /dev/null +++ b/tests/integration/app.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +source ./common.sh + +echo "all apps, all servers" +$ABRA app ls +printf "\\n\\n\\n" + +echo "all wordpress apps, all servers" +$ABRA app ls --type wordpress +printf "\\n\\n\\n" + +echo "all wordpress apps, only server2" +$ABRA app ls --type wordpress --server server2 +printf "\\n\\n\\n" diff --git a/tests/integration/autocomplete.sh b/tests/integration/autocomplete.sh new file mode 100755 index 00000000..e0770ca9 --- /dev/null +++ b/tests/integration/autocomplete.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +source ./common.sh + +$ABRA autocomplete bash + +$ABRA autocomplete fizsh + +$ABRA autocomplete zsh diff --git a/tests/integration/catalogue.sh b/tests/integration/catalogue.sh new file mode 100755 index 00000000..5522f12e --- /dev/null +++ b/tests/integration/catalogue.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +source ./common.sh + +$ABRA catalogue generate --debug + +$ABRA catalogue generate gitea --debug diff --git a/tests/integration/common.sh b/tests/integration/common.sh new file mode 100755 index 00000000..c1d4e345 --- /dev/null +++ b/tests/integration/common.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +function init() { + ABRA="$HOME/.local/bin/abra" + INSTALLER_URL="https://install.abra.coopcloud.tech" + + for arg in "$@"; do + if [ "$arg" == "--dev" ]; then + ABRA="/src/abra" + INSTALLER_URL="https://git.coopcloud.tech/coop-cloud/abra/raw/branch/main/scripts/installer/installer" + fi + done + + export PATH=$PATH:$HOME/.local/bin + + echo "choosing $ABRA as abra command" + echo "choosing $INSTALLER_URL as abra installer url" +} + +init "$@" diff --git a/tests/integration/core.sh b/tests/integration/core.sh deleted file mode 100755 index 4c94035e..00000000 --- a/tests/integration/core.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash - -# the goal of this script is to ensure basic core functionality is working -# before we make new releases. we try to make a balance between manual testing -# and automated testing, i.e. we don't invest too much time in a fragile -# automation that costs us more time to maintain and instead just do the test -# manually (see `../manual/manual.md` for more). it is a balance which we -# figure out together. - -set -ex - -ABRA="$HOME/.local/bin/abra -d" -INSTALLER_URL="https://install.abra.coopcloud.tech" - -for arg in "$@"; do - if [ "$arg" == "--dev" ]; then - ABRA="/src/abra -d" - INSTALLER_URL="https://git.coopcloud.tech/coop-cloud/abra/raw/branch/main/scripts/installer/installer" - fi -done - -export PATH=$PATH:$HOME/.local/bin - -# ======================================================================== -# choosing abra executable for test run -# ======================================================================== -echo "choosing $ABRA as abra executable" -echo "choosing $INSTALLER_URL as abra installer url" - -# ======================================================================== -# latest stable release -# ======================================================================== -wget -O- https://install.abra.autonomic.zone | bash -~/.local/bin/abra -v - -# ======================================================================== -# latest rc release -# ======================================================================== -wget -O- https://install.abra.autonomic.zone | bash -s -- --rc -~/.local/bin/abra -v - -# ======================================================================== -# upgrade to stable in-place -# ======================================================================== -$ABRA upgrade -~/.local/bin/abra -v - -# ======================================================================== -# upgrade to rc in-place -# ======================================================================== -$ABRA upgrade --rc -~/.local/bin/abra -v - -# ======================================================================== -# autocomplete -# ======================================================================== -$ABRA autocomplete bash -$ABRA autocomplete fizsh -$ABRA autocomplete zsh - -# ======================================================================== -# record command -# ======================================================================== -$ABRA record new -p gandi -t A -n int-core -v 192.157.2.21 coopcloud.tech -$ABRA record list -p gandi coopcloud.tech | grep -q int-core -$ABRA -n record rm -p gandi -t A -n int-core coopcloud.tech - -# ======================================================================== -# catalogue command -# ======================================================================== -$ABRA catalogue generate -$ABRA catalogue generate -s gitea - -# ======================================================================== -# recipe command -# ======================================================================== -$ABRA recipe new testrecipe - -$ABRA recipe list -$ABRA recipe list -p cloud - -$ABRA recipe versions peertube - -$ABRA recipe lint gitea - -# ======================================================================== -# server command -# ======================================================================== -$ABRA -n server new -p hetzner-cloud --hn int-core - -$ABRA server ls | grep -q int-core - -$ABRA -n server rm -s -p hetzner-cloud --hn int-core - -# ======================================================================== -# app command -# ======================================================================== - -$ABRA app ls - -$ABRA app ls -S diff --git a/tests/integration/install.sh b/tests/integration/install.sh new file mode 100755 index 00000000..a0c31a39 --- /dev/null +++ b/tests/integration/install.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +source ./common.sh + +wget -O- https://install.abra.autonomic.zone | bash +~/.local/bin/abra -v + +wget -O- https://install.abra.autonomic.zone | bash -s -- --rc +~/.local/bin/abra -v + +$ABRA upgrade +~/.local/bin/abra -v + +$ABRA upgrade --rc +~/.local/bin/abra -v diff --git a/tests/integration/makefile b/tests/integration/makefile new file mode 100644 index 00000000..58dc4e1b --- /dev/null +++ b/tests/integration/makefile @@ -0,0 +1,11 @@ +default: + @docker run \ + -v $$(pwd)/../../:/src \ + -v $$(pwd)/.abra:/root/.abra \ + --env-file .envrc \ + decentral1se/abra-int:latest \ + sh -c '\ + echo "Running $(TARGET)..."; \ + cd /src/tests/integration; \ + bash "$(TARGET)" -- --dev \ + ' diff --git a/tests/integration/recipe.sh b/tests/integration/recipe.sh new file mode 100755 index 00000000..76ead9cd --- /dev/null +++ b/tests/integration/recipe.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +source ./common.sh + +$ABRA recipe new testrecipe + +$ABRA recipe list +$ABRA recipe list -p cloud + +$ABRA recipe versions peertube + +$ABRA recipe lint gitea diff --git a/tests/integration/records.sh b/tests/integration/records.sh new file mode 100755 index 00000000..c8f157fb --- /dev/null +++ b/tests/integration/records.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +source ./common.sh + +$ABRA record new -p gandi -t A -n int-core -v 192.157.2.21 coopcloud.tech + +$ABRA record list -p gandi coopcloud.tech | grep -q int-core + +$ABRA -n record rm -p gandi -t A -n int-core coopcloud.tech diff --git a/tests/integration/server.sh b/tests/integration/server.sh new file mode 100755 index 00000000..ae8dfcaa --- /dev/null +++ b/tests/integration/server.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +source ./common.sh + +$ABRA -n server new -p hetzner-cloud --hn int-core + +$ABRA server ls | grep -q int-core + +$ABRA -n server rm -s -p hetzner-cloud --hn int-core diff --git a/tests/manual/apps/works/.env.sample b/tests/manual/apps/works/.env.sample deleted file mode 100644 index aa318fd7..00000000 --- a/tests/manual/apps/works/.env.sample +++ /dev/null @@ -1 +0,0 @@ -TYPE=works diff --git a/tests/manual/apps/works/compose.yml b/tests/manual/apps/works/compose.yml deleted file mode 100644 index 5dba3672..00000000 --- a/tests/manual/apps/works/compose.yml +++ /dev/null @@ -1,84 +0,0 @@ ---- - -# The goal of this compose file is to have a testing ground for understanding -# what cases we need to handle to get stable deployments. For that, we need to -# work with healthchecks and deploy configurations quite closely. If you run -# the `make symlink` target then this will be loaded into a "fake" app on your -# local machine which you can deploy with `abra`. - -version: "3.8" -services: - r1_should_work: - image: redis:alpine - deploy: - update_config: - failure_action: rollback - order: start-first - rollback_config: - order: start-first - restart_policy: - max_attempts: 1 - healthcheck: - test: redis-cli ping - interval: 2s - retries: 3 - start_period: 1s - timeout: 3s - - r2_broken_health_check: - image: redis:alpine - deploy: - update_config: - failure_action: rollback - order: start-first - rollback_config: - order: start-first - restart_policy: - max_attempts: 3 - healthcheck: - test: foobar - interval: 2s - retries: 3 - start_period: 1s - timeout: 3s - - r3_no_health_check: - image: redis:alpine - deploy: - update_config: - failure_action: rollback - order: start-first - rollback_config: - order: start-first - restart_policy: - max_attempts: 3 - - r4_disabled_health_check: - image: redis:alpine - deploy: - update_config: - failure_action: rollback - order: start-first - rollback_config: - order: start-first - restart_policy: - max_attempts: 3 - healthcheck: - disable: true - - r5_should_also_work: - image: redis:alpine - deploy: - update_config: - failure_action: rollback - order: start-first - rollback_config: - order: start-first - restart_policy: - max_attempts: 1 - healthcheck: - test: redis-cli ping - interval: 2s - retries: 3 - start_period: 1s - timeout: 3s diff --git a/tests/manual/default/works.env b/tests/manual/default/works.env deleted file mode 100644 index aa318fd7..00000000 --- a/tests/manual/default/works.env +++ /dev/null @@ -1 +0,0 @@ -TYPE=works diff --git a/tests/manual/manual.md b/tests/manual/manual.md index 303c7485..350576a7 100644 --- a/tests/manual/manual.md +++ b/tests/manual/manual.md @@ -1,9 +1,5 @@ # manual test plan -Best served after running `make int-core` which assures most core functionality -is still working. These manual tests are for testing things that are hard to -wire up for testing in an automated way. - ## recipe publish - `abra recipe upgrade ` @@ -17,36 +13,28 @@ wire up for testing in an automated way. ## deploy, upgrade, rollback -- `abra app deploy ` -- `abra app deploy --force ` - `abra app deploy --chaos ` -- `abra app upgrade ` +- `abra app deploy --force ` +- `abra app deploy ` - `abra app rollback ` +- `abra app upgrade ` ## app day-to-day ops -### easy mode - -- `abra app ls -t ` -- `abra app ls -s ` -- `abra app ls -s -t ` -- `abra app ls -s -t -S` -- `abra app config ` - `abra app check ` -- `abra app ps ` -- `abra app logs ` +- `abra app config ` - `abra app cp ` -- `abra app run ` -- `abra app secret ls ` -- `abra app volume ls ` -- `abra app new --secrets ` - -### hard mode - -- `abra app restart ` -- `abra app remove ` -- `abra app secret insert foo v1 bar` -- `abra app secret remove foo` -- `abra app secret generate --all` -- `abra app volume remove --force ` - `abra app errors -w ` +- `abra app logs ` +- `abra app ls --status ` +- `abra app new --secrets ` +- `abra app ps ` +- `abra app remove ` +- `abra app restart ` +- `abra app run ` +- `abra app secret generate --all` +- `abra app secret insert foo v1 bar` +- `abra app secret ls ` +- `abra app secret remove foo` +- `abra app volume ls ` +- `abra app volume remove --force `