All checks were successful
continuous-integration/drone/push Build is passing
In preparation for the new abra release, let's fix all integration tests After merging, this needs to be cherry-picked into the release-0-9 branch. - [x] app_backup.bats (skip this one) - [x] app_check.bats (fixed bybd21014fed
) - [x] app_cmd.bats (partially fixed in08232b74f6
), has known regression coop-cloud/organising#581 - [x] app_config.bats (no changes needed) - [x] app_cp.bats (no changes needed) - [x] app_deploy.bats - [x] app_errors.bats (no changes needed) - [x] app_list.bats (no changes needed) - [x] app_logs.bats (no changes needed) - [x] app_new.bats (no changes needed) - [x] app_ps.bats (no changes needed) - [x] app_remove.bats (fixed by [2f29fbeb2e](coop-cloud/abra#403/commits/2f29fbeb2e018656413fa25f8615b7a98cdcb083)) - [x] app_restart.bats (no changes needed - [x] app_restore.bats (fixed by [f2dd5afc38](coop-cloud/abra#403/commits/f2dd5afc38a25a8316899fa0c6d59499445868d7)) - [x] app_rollback.bats (partially fixed by6e99b74c24
) - [x] app_run.bats (no changes needed) - [x] app_secret.bats (fixed bybd069d32f6
) - [x] app_services.bats (no changes needed) - [x] app_undeploy.bats (no changes needed) - [x] app_upgrade.bats (no changes needed) - [x] app_version.bats (partially fixed byad323ad2bd
) - [x] app_volume.bats (fixed by [03c3823770](coop-cloud/abra#403/commits/03c38237707ae795b723180eb07a7edc84a8de35)) - [x] autocomplete.bats (no changes needed) - [x] catalogue.bats (no changes needed) - [x] dirs.bats (no changes needed) - [x] install.bats (failes, but is expected) - [x] recipe_diff.bats (no changes needed) - [x] recipe_fetch.bats (no changes needed) - [x] recipe_lint.bats (fixed by [b6b0808066](coop-cloud/abra#403/commits/b6b0808066a11e4bcd77517ec39600d500bcb944)) - [x] recipe_list.bats (no changes needed) - [x] recipe_new.bats (fixed by [0aac464ded](coop-cloud/abra#403/commits/0aac464ded6b43afb3ec37ade2f64d6191b9838f)) - [x] recipe_release.bats (no changes needed) - [x] recipe_reset.bats (no changes needed) - [x] recipe_sync.bats (no changes needed) - [x] recipe_upgrade.bats (fixed by [ab86904cf4](coop-cloud/abra#403/commits/ab86904cf45db89c7c189ca1fd9971909bd446dd)) - [x] recipe_version.bats (fixed by81897bf4da
) - [x] server_add.bats - [x] server_list.bats - [x] server_prune.bats (no changes needed) - [x] server_remove.bats - [x] upgrade.bats - [x] version.bats (no changes needed) Co-authored-by: decentral1se <cellarspoon@riseup.net> Reviewed-on: coop-cloud/abra#403 Co-authored-by: p4u1 <p4u1_f4u1@riseup.net> Co-committed-by: p4u1 <p4u1_f4u1@riseup.net>
373 lines
10 KiB
Bash
373 lines
10 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
setup_file(){
|
|
load "$PWD/tests/integration/helpers/common"
|
|
_common_setup
|
|
_add_server
|
|
_new_app
|
|
}
|
|
|
|
teardown_file(){
|
|
_rm_app
|
|
_rm_server
|
|
_reset_recipe
|
|
}
|
|
|
|
setup(){
|
|
load "$PWD/tests/integration/helpers/common"
|
|
_common_setup
|
|
_reset_recipe
|
|
}
|
|
|
|
teardown(){
|
|
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
|
|
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
|
|
_undeploy_app
|
|
fi
|
|
}
|
|
|
|
@test "validate app argument" {
|
|
run $ABRA app deploy
|
|
assert_failure
|
|
assert_output --partial 'no app provided'
|
|
|
|
run $ABRA app deploy DOESNTEXIST
|
|
assert_failure
|
|
assert_output --partial 'cannot find app'
|
|
}
|
|
|
|
@test "bail if unstaged changes and no --chaos" {
|
|
run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_success
|
|
assert_output --partial 'foo'
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input
|
|
assert_failure
|
|
assert_output --partial 'locally unstaged changes'
|
|
refute_output --partial 'chaos'
|
|
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
|
|
_checkout_recipe
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "do not bail if unstaged changes and --chaos" {
|
|
run bash -c 'echo "unstaged changes" >> "$ABRA_DIR/recipes/$TEST_RECIPE/foo"'
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_success
|
|
assert_output --partial 'foo'
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--chaos --no-input --no-converge-checks
|
|
assert_success
|
|
assert_output --partial 'chaos'
|
|
|
|
_undeploy_app
|
|
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "ensure recipe up to date if no --offline" {
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_output --regexp 'behind .* 3 commits'
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
refute_output --regexp 'behind .* 3 commits'
|
|
|
|
_reset_recipe
|
|
_undeploy_app
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "ensure recipe not up to date if --offline" {
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_output --regexp 'behind .* 3 commits'
|
|
|
|
# NOTE(d1): need to use --chaos to force same commit
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--no-input --no-converge-checks --chaos --offline
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_output --regexp 'behind .* 3 commits'
|
|
|
|
_undeploy_app
|
|
_reset_recipe
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "deploy latest commit if no published versions and no --chaos" {
|
|
# TODO(d1): fix with a new test recipe which has no published versions?
|
|
skip "known issue, abra-test-recipe has published versions now"
|
|
|
|
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
|
|
|
|
_remove_tags
|
|
|
|
# NOTE(d1): need to pass --offline to stop tags being pulled again
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--no-input --no-converge-checks --offline
|
|
assert_success
|
|
assert_output --partial "$latestCommit"
|
|
assert_output --partial 'using latest commit'
|
|
refute_output --partial 'chaos'
|
|
|
|
_undeploy_app
|
|
_reset_tags
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "ensure same commit if --chaos" {
|
|
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_output --regexp 'behind .* 3 commits'
|
|
|
|
threeCommitsBack="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--no-input --no-converge-checks --chaos
|
|
assert_success
|
|
refute_output --partial "$latestCommit"
|
|
assert_output --partial "$threeCommitsBack"
|
|
assert_output --partial 'chaos'
|
|
|
|
_undeploy_app
|
|
_reset_recipe
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "retrieve recipe if missing" {
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
assert_success
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
|
assert_success
|
|
|
|
_undeploy_app
|
|
|
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
}
|
|
|
|
@test "no deploy if lint error" {
|
|
run sed -i '/traefik.enable=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
|
assert_success
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--no-input --no-converge-checks --chaos
|
|
assert_failure
|
|
assert_output --partial 'failed lint checks'
|
|
|
|
_checkout_recipe
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "error if already deployed and no --force/--chaos" {
|
|
_deploy_app
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--no-input --no-converge-checks
|
|
assert_failure
|
|
assert_output --partial 'already deployed'
|
|
|
|
_undeploy_app
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "re-deploy deployed app if --force/--chaos" {
|
|
_deploy_app
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--no-input --no-converge-checks --force
|
|
assert_success
|
|
assert_output --partial 'already deployed but continuing'
|
|
assert_output --partial '--force'
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--no-input --no-converge-checks --chaos
|
|
assert_success
|
|
assert_output --partial 'already deployed but continuing'
|
|
assert_output --partial '--chaos'
|
|
|
|
_undeploy_app
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "deploy latest version from catalogue if no --chaos" {
|
|
latestVersion=$(jq -r '.gitea.versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
|
|
refute [ -z "$latestVersion" ];
|
|
|
|
run $ABRA app new gitea \
|
|
--no-input \
|
|
--server "$TEST_SERVER" \
|
|
--domain "gitea.$TEST_SERVER" \
|
|
--secrets
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/gitea.$TEST_SERVER.env"
|
|
|
|
run $ABRA app deploy "gitea.$TEST_SERVER" --no-input --no-converge-checks
|
|
assert_success
|
|
assert_output --partial "$latestVersion"
|
|
|
|
run $ABRA app undeploy "gitea.$TEST_SERVER" --no-input
|
|
assert_success
|
|
|
|
run $ABRA app secret remove "gitea.$TEST_SERVER" --all --no-input
|
|
assert_success
|
|
|
|
# NOTE(d1): to let the stack come down before nuking volumes
|
|
sleep 5
|
|
|
|
run $ABRA app volume remove "gitea.$TEST_SERVER" --no-input
|
|
assert_success
|
|
|
|
run $ABRA app remove "gitea.$TEST_SERVER" --no-input
|
|
assert_success
|
|
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER/gitea.$TEST_SERVER.env"
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "skip domain check if missing DOMAIN=" {
|
|
run cp "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" "$BATS_TMPDIR/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/$TEST_APP_DOMAIN.env"
|
|
|
|
run grep -q "DOMAIN=" "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
|
|
run sed -i '/DOMAIN=.*/d' "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
|
|
run grep -q "DOMAIN=" "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_failure
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
|
assert_success
|
|
assert_output --partial 'no DOMAIN=... configured for app'
|
|
|
|
run $ABRA app undeploy "$TEST_APP_DOMAIN" --no-input
|
|
assert_success
|
|
|
|
run mv "$BATS_TMPDIR/$TEST_APP_DOMAIN.env" "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
}
|
|
|
|
@test "ensure domain is checked" {
|
|
if [[ "$TEST_SERVER" == "default" ]]; then
|
|
skip "domain checks are disabled for local server"
|
|
fi
|
|
|
|
appDomain="custom-html.DOESNTEXIST"
|
|
|
|
run $ABRA app new custom-html \
|
|
--no-input \
|
|
--server "$TEST_SERVER" \
|
|
--domain "$appDomain"
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$appDomain.env"
|
|
|
|
run $ABRA app deploy "$appDomain" --no-input
|
|
assert_failure
|
|
assert_output --partial 'no such host'
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "skip domain check when requested" {
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--no-input --no-converge-checks --no-domain-checks
|
|
assert_success
|
|
assert_output --partial 'skipping domain checks as requested'
|
|
|
|
_undeploy_app
|
|
}
|
|
|
|
@test "error if specific version does not exist" {
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" DOESNTEXIST --no-input --no-converge-checks
|
|
assert_failure
|
|
assert_output --partial "doesn't seem to have version DOESNTEXIST available"
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "deploy specific version" {
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input
|
|
assert_success
|
|
assert_output --partial "0.2.0+1.21.0"
|
|
|
|
_undeploy_app
|
|
}
|
|
|
|
@test "bail out if specific version and chaos" {
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.2.0+1.21.0" \
|
|
--chaos --no-input --no-converge-checks
|
|
assert_failure
|
|
assert_output --partial 'cannot use'
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "COMPOSE_FILE with \$COMPOSE_FILE override works" {
|
|
_reset_recipe
|
|
|
|
run sed -i 's/#COMPOSE_FILE="$COMPOSE_FILE:compose.extra_env.yml"/COMPOSE_FILE="$COMPOSE_FILE:compose.extra_env.yml"/g' \
|
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
|
|
# NOTE(d1): --chaos used to bypass versions and access compose.extra_env.yml
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--no-input --no-converge-checks --chaos
|
|
assert_success
|
|
assert_output --partial "compose.yml"
|
|
assert_output --partial "compose.extra_env.yml"
|
|
|
|
_undeploy_app
|
|
_reset_app
|
|
}
|
|
|
|
@test "error if no secrets generated" {
|
|
run sed -i 's/COMPOSE_FILE="compose.yml"/COMPOSE_FILE="compose.yml:compose.extra_secret.yml"/g' \
|
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
|
|
run sed -i 's/#SECRET_EXTRA_PASS_VERSION=v1/SECRET_EXTRA_PASS_VERSION=v1/g' \
|
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
|
assert_failure
|
|
assert_output --partial 'unable to deploy, secrets not generated'
|
|
|
|
_reset_app
|
|
}
|
|
|
|
@test "recipe config comments not present in values" {
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input
|
|
assert_success
|
|
|
|
run $ABRA app run "$TEST_APP_DOMAIN" app env
|
|
assert_success
|
|
refute_output --partial 'should be removed'
|
|
}
|