From 9b7af67a26ed87fe67fd1f2d120f76a4f4b55d5a Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Sat, 7 Jan 2023 18:50:27 +0100 Subject: [PATCH] Run tests using compose v2 (#178) --- test/certs/run.sh | 6 +++--- test/commands/run.sh | 6 +++--- test/confd/run.sh | 4 ++-- test/extend/run.sh | 6 +++--- test/gpg/run.sh | 6 +++--- test/ignore/run.sh | 6 +++--- test/local/run.sh | 12 ++++++------ test/notifications/run.sh | 12 ++++++------ test/ownership/run.sh | 6 +++--- test/s3/run.sh | 10 +++++----- test/ssh/run.sh | 10 +++++----- test/webdav/run.sh | 10 +++++----- 12 files changed, 47 insertions(+), 47 deletions(-) diff --git a/test/certs/run.sh b/test/certs/run.sh index 548982d..c021ec0 100644 --- a/test/certs/run.sh +++ b/test/certs/run.sh @@ -24,10 +24,10 @@ openssl x509 -req -passin pass:test \ openssl x509 -in minio.crt -noout -text -docker-compose up -d +docker compose up -d sleep 5 -docker-compose exec backup backup +docker compose exec backup backup sleep 5 @@ -40,4 +40,4 @@ docker run --rm -it \ pass "Found relevant files in untared remote backups." -docker-compose down --volumes +docker compose down --volumes diff --git a/test/commands/run.sh b/test/commands/run.sh index 70a928e..6074ebe 100644 --- a/test/commands/run.sh +++ b/test/commands/run.sh @@ -6,10 +6,10 @@ cd $(dirname $0) . ../util.sh current_test=$(basename $(pwd)) -docker-compose up -d +docker compose up -d sleep 30 # mariadb likes to take a bit before responding -docker-compose exec backup backup +docker compose exec backup backup sudo cp -r $(docker volume inspect --format='{{ .Mountpoint }}' commands_archive) ./local tar -xvf ./local/test.tar.gz @@ -28,7 +28,7 @@ if [ -f ./backup/data/post.txt ]; then fi pass "Did not find unexpected file." -docker-compose down --volumes +docker compose down --volumes sudo rm -rf ./local diff --git a/test/confd/run.sh b/test/confd/run.sh index 1b7a89f..ed2f911 100755 --- a/test/confd/run.sh +++ b/test/confd/run.sh @@ -8,12 +8,12 @@ current_test=$(basename $(pwd)) mkdir -p local -docker-compose up -d +docker compose up -d # sleep until a backup is guaranteed to have happened on the 1 minute schedule sleep 100 -docker-compose down --volumes +docker compose down --volumes if [ ! -f ./local/conf.tar.gz ]; then fail "Config from file was not used." diff --git a/test/extend/run.sh b/test/extend/run.sh index 59d78e7..1c95cad 100644 --- a/test/extend/run.sh +++ b/test/extend/run.sh @@ -12,10 +12,10 @@ export TEST_VERSION="${TEST_VERSION:-canary}-with-rsync" docker build . -t offen/docker-volume-backup:$TEST_VERSION -docker-compose up -d +docker compose up -d sleep 5 -docker-compose exec backup backup +docker compose exec backup backup sleep 5 @@ -25,4 +25,4 @@ if [ ! -f "./local/app_data/offen.db" ]; then fail "Could not find expected file in untared archive." fi -docker-compose down --volumes +docker compose down --volumes diff --git a/test/gpg/run.sh b/test/gpg/run.sh index 46cca34..1efaa6b 100755 --- a/test/gpg/run.sh +++ b/test/gpg/run.sh @@ -8,10 +8,10 @@ current_test=$(basename $(pwd)) mkdir -p local -docker-compose up -d +docker compose up -d sleep 5 -docker-compose exec backup backup +docker compose exec backup backup expect_running_containers "2" @@ -30,4 +30,4 @@ if [ ! -L ./local/test-latest.tar.gz.gpg ]; then fail "Could not find local symlink to latest encrypted backup." fi -docker-compose down --volumes +docker compose down --volumes diff --git a/test/ignore/run.sh b/test/ignore/run.sh index 16640ba..b5699da 100644 --- a/test/ignore/run.sh +++ b/test/ignore/run.sh @@ -8,11 +8,11 @@ current_test=$(basename $(pwd)) mkdir -p local -docker-compose up -d +docker compose up -d sleep 5 -docker-compose exec backup backup +docker compose exec backup backup -docker-compose down --volumes +docker compose down --volumes out=$(mktemp -d) sudo tar --same-owner -xvf ./local/test.tar.gz -C "$out" diff --git a/test/local/run.sh b/test/local/run.sh index 3632e65..713929c 100755 --- a/test/local/run.sh +++ b/test/local/run.sh @@ -8,13 +8,13 @@ current_test=$(basename $(pwd)) mkdir -p local -docker-compose up -d +docker compose up -d sleep 5 # A symlink for a known file in the volume is created so the test can check # whether symlinks are preserved on backup. -docker-compose exec offen ln -s /var/opt/offen/offen.db /var/opt/offen/db.link -docker-compose exec backup backup +docker compose exec offen ln -s /var/opt/offen/offen.db /var/opt/offen/db.link +docker compose exec backup backup sleep 5 @@ -42,14 +42,14 @@ pass "Found symlink to latest version in local backup." # The second part of this test checks if backups get deleted when the retention # is set to 0 days (which it should not as it would mean all backups get deleted) # TODO: find out if we can test actual deletion without having to wait for a day -BACKUP_RETENTION_DAYS="0" docker-compose up -d +BACKUP_RETENTION_DAYS="0" docker compose up -d sleep 5 -docker-compose exec backup backup +docker compose exec backup backup if [ "$(find ./local -type f | wc -l)" != "1" ]; then fail "Backups should not have been deleted, instead seen: "$(find ./local -type f)"" fi pass "Local backups have not been deleted." -docker-compose down --volumes +docker compose down --volumes diff --git a/test/notifications/run.sh b/test/notifications/run.sh index 49dab08..68efcf7 100755 --- a/test/notifications/run.sh +++ b/test/notifications/run.sh @@ -8,13 +8,13 @@ current_test=$(basename $(pwd)) mkdir -p local -docker-compose up -d +docker compose up -d sleep 5 GOTIFY_TOKEN=$(curl -sSLX POST -H 'Content-Type: application/json' -d '{"name":"test"}' http://admin:custom@localhost:8080/application | jq -r '.token') info "Set up Gotify application using token $GOTIFY_TOKEN" -docker-compose exec backup backup +docker compose exec backup backup NUM_MESSAGES=$(curl -sSL http://admin:custom@localhost:8080/message | jq -r '.messages | length') if [ "$NUM_MESSAGES" != 0 ]; then @@ -22,11 +22,11 @@ if [ "$NUM_MESSAGES" != 0 ]; then fi pass "No notifications were sent when not configured." -docker-compose down +docker compose down -NOTIFICATION_URLS="gotify://gotify/${GOTIFY_TOKEN}?disableTLS=true" docker-compose up -d +NOTIFICATION_URLS="gotify://gotify/${GOTIFY_TOKEN}?disableTLS=true" docker compose up -d -docker-compose exec backup backup +docker compose exec backup backup NUM_MESSAGES=$(curl -sSL http://admin:custom@localhost:8080/message | jq -r '.messages | length') if [ "$NUM_MESSAGES" != 1 ]; then @@ -47,4 +47,4 @@ if [ "$MESSAGE_BODY" != "Backing up /tmp/test.tar.gz succeeded." ]; then fi pass "Custom notification body was used." -docker-compose down --volumes +docker compose down --volumes diff --git a/test/ownership/run.sh b/test/ownership/run.sh index 266d61c..f2a1873 100644 --- a/test/ownership/run.sh +++ b/test/ownership/run.sh @@ -9,10 +9,10 @@ current_test=$(basename $(pwd)) mkdir -p local -docker-compose up -d +docker compose up -d sleep 5 -docker-compose exec backup backup +docker compose exec backup backup tmp_dir=$(mktemp -d) sudo tar --same-owner -xvf ./local/backup.tar.gz -C $tmp_dir @@ -27,4 +27,4 @@ for file in $(sudo find $tmp_dir/backup/postgres); do done pass "All files and directories in backup preserved their ownership." -docker-compose down --volumes +docker compose down --volumes diff --git a/test/s3/run.sh b/test/s3/run.sh index a6acd15..84c7ae9 100755 --- a/test/s3/run.sh +++ b/test/s3/run.sh @@ -6,12 +6,12 @@ cd "$(dirname "$0")" . ../util.sh current_test=$(basename $(pwd)) -docker-compose up -d +docker compose up -d sleep 5 # A symlink for a known file in the volume is created so the test can check # whether symlinks are preserved on backup. -docker-compose exec backup backup +docker compose exec backup backup sleep 5 @@ -27,10 +27,10 @@ pass "Found relevant files in untared remote backups." # The second part of this test checks if backups get deleted when the retention # is set to 0 days (which it should not as it would mean all backups get deleted) # TODO: find out if we can test actual deletion without having to wait for a day -BACKUP_RETENTION_DAYS="0" docker-compose up -d +BACKUP_RETENTION_DAYS="0" docker compose up -d sleep 5 -docker-compose exec backup backup +docker compose exec backup backup docker run --rm -it \ -v minio_backup_data:/minio_data \ @@ -39,4 +39,4 @@ docker run --rm -it \ pass "Remote backups have not been deleted." -docker-compose down --volumes +docker compose down --volumes diff --git a/test/ssh/run.sh b/test/ssh/run.sh index 3e7995d..eb0ce03 100755 --- a/test/ssh/run.sh +++ b/test/ssh/run.sh @@ -8,10 +8,10 @@ current_test=$(basename $(pwd)) ssh-keygen -t rsa -m pem -b 4096 -N "test1234" -f id_rsa -C "docker-volume-backup@local" -docker-compose up -d +docker compose up -d sleep 5 -docker-compose exec backup backup +docker compose exec backup backup sleep 5 @@ -27,10 +27,10 @@ pass "Found relevant files in decrypted and untared remote backups." # The second part of this test checks if backups get deleted when the retention # is set to 0 days (which it should not as it would mean all backups get deleted) # TODO: find out if we can test actual deletion without having to wait for a day -BACKUP_RETENTION_DAYS="0" docker-compose up -d +BACKUP_RETENTION_DAYS="0" docker compose up -d sleep 5 -docker-compose exec backup backup +docker compose exec backup backup docker run --rm -it \ -v ssh_backup_data:/ssh_data \ @@ -39,5 +39,5 @@ docker run --rm -it \ pass "Remote backups have not been deleted." -docker-compose down --volumes +docker compose down --volumes rm -f id_rsa id_rsa.pub diff --git a/test/webdav/run.sh b/test/webdav/run.sh index 8678b75..0ec3017 100755 --- a/test/webdav/run.sh +++ b/test/webdav/run.sh @@ -6,10 +6,10 @@ cd "$(dirname "$0")" . ../util.sh current_test=$(basename $(pwd)) -docker-compose up -d +docker compose up -d sleep 5 -docker-compose exec backup backup +docker compose exec backup backup sleep 5 @@ -25,10 +25,10 @@ pass "Found relevant files in untared remote backup." # The second part of this test checks if backups get deleted when the retention # is set to 0 days (which it should not as it would mean all backups get deleted) # TODO: find out if we can test actual deletion without having to wait for a day -BACKUP_RETENTION_DAYS="0" docker-compose up -d +BACKUP_RETENTION_DAYS="0" docker compose up -d sleep 5 -docker-compose exec backup backup +docker compose exec backup backup docker run --rm -it \ -v webdav_backup_data:/webdav_data \ @@ -37,4 +37,4 @@ docker run --rm -it \ pass "Remote backups have not been deleted." -docker-compose down --volumes +docker compose down --volumes