test: less fragile integration suite [ci skip]

See coop-cloud/organising#584
See coop-cloud/organising#595
This commit is contained in:
decentral1se 2024-06-22 16:40:07 +02:00
parent a9ce2106c6
commit 2014cd6622
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
39 changed files with 249 additions and 425 deletions

View File

@ -19,13 +19,12 @@ setup() {
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
}
@test "retrieve recipe if missing" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
@ -39,6 +38,8 @@ teardown(){
}
@test "bail if unstaged changes and no --chaos" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_success
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
@ -59,6 +60,8 @@ teardown(){
# bats test_tags=slow
@test "do not bail if unstaged changes and --chaos" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run bash -c 'echo "unstaged changes" >> "$ABRA_DIR/recipes/$TEST_RECIPE/foo"'
assert_success
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
@ -81,6 +84,8 @@ teardown(){
}
@test "ensure recipe up to date if no --offline" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
assert_success
@ -98,6 +103,8 @@ teardown(){
}
@test "ensure recipe not up to date if --offline" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
refute [ -z "$latestCommit" ];
@ -124,6 +131,8 @@ teardown(){
}
@test "detect backup labels" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run $ABRA app backup "$TEST_APP_DOMAIN" --debug
assert_failure
assert_output --partial 'no containers matching'
@ -134,6 +143,8 @@ teardown(){
}
@test "error if backups not enabled" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run sed -i '/backupbot.backup=true/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
assert_success
@ -145,6 +156,8 @@ teardown(){
}
@test "error if backup paths not configured" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run sed -i '/backupbot.backup.path=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
assert_success
@ -157,6 +170,8 @@ teardown(){
# bats test_tags=slow
@test "backup single service" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
_deploy_app
run $ABRA app backup "$TEST_APP_DOMAIN" app

View File

@ -18,6 +18,10 @@ setup(){
_common_setup
}
teardown(){
_reset_recipe
}
@test "validate app argument" {
run $ABRA app check
assert_failure
@ -35,8 +39,6 @@ setup(){
run $ABRA app check "$TEST_APP_DOMAIN"
assert_success
refute_output --partial '❌'
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
}
@ -66,37 +68,33 @@ setup(){
}
@test "ensure recipe up to date if no --offline" {
wantHash=$(_get_n_hash 3)
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'
assert_equal $(_get_current_hash) "$wantHash"
run $ABRA app check "$TEST_APP_DOMAIN"
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --regexp 'behind .* 3 commits'
_reset_recipe
assert_equal $(_get_head_hash) $(_get_current_hash)
}
@test "ensure recipe not up to date if --offline" {
wantHash=$(_get_n_hash 1)
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~1
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --partial "Your branch is behind 'origin/main' by 1 commit"
assert_equal $(_get_current_hash) "$wantHash"
# NOTE(d1): we can't quite tell if this will fail or not in the future, so,
# since it isn't an important part of what we're testing here, we don't check
# it
run $ABRA app check "$TEST_APP_DOMAIN" --offline
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --partial "Your branch is behind 'origin/main' by 1 commit"
_reset_recipe
assert_equal $(_get_current_hash) "$wantHash"
}
@test "error if missing .env.sample" {
@ -106,8 +104,6 @@ setup(){
run $ABRA app check "$TEST_APP_DOMAIN" --chaos
assert_failure
assert_output --partial '.env.sample does not exist?'
_checkout_recipe
}
@test "error if missing env var" {
@ -121,6 +117,4 @@ setup(){
run $ABRA app check "$TEST_APP_DOMAIN" --chaos
assert_success
assert_output --partial '❌'
_checkout_recipe
}

View File

@ -19,10 +19,8 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
_reset_recipe
}
# bats test_tags=slow
@ -92,35 +90,33 @@ test_cmd_export"
}
@test "ensure recipe up to date if no --offline" {
wantHash=$(_get_n_hash 3)
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'
assert_equal $(_get_current_hash) "$wantHash"
run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd
assert_success
assert_output --partial 'baz'
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --partial "up to date"
_reset_recipe "$TEST_RECIPE"
assert_equal $(_get_head_hash) $(_get_current_hash)
}
@test "ensure recipe not up to date if --offline" {
wantHash=$(_get_n_hash 3)
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'
assert_equal $(_get_current_hash) "$wantHash"
run $ABRA app cmd --local --offline "$TEST_APP_DOMAIN" test_cmd
assert_success
assert_output --partial 'baz'
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --regexp 'behind .* 3 commits'
assert_equal $(_get_current_hash) $wantHash
_reset_recipe "$TEST_RECIPE"
}
@ -167,12 +163,16 @@ test_cmd_export"
}
@test "run command with single arg" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/581"
run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd_arg -- bing
assert_success
assert_output --partial 'bing'
}
@test "run command with several args" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/581"
run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd_args -- bong bang
assert_success
assert_output --partial 'bong bang'
@ -185,8 +185,6 @@ test_cmd_export"
run $ABRA app cmd "$TEST_APP_DOMAIN" app test_cmd
assert_success
assert_output --partial 'baz'
_undeploy_app
}
# bats test_tags=slow
@ -196,6 +194,4 @@ test_cmd_export"
run $ABRA app cmd "$TEST_APP_DOMAIN" doesnt_exist test_cmd
assert_failure
assert_output --partial 'no service doesnt_exist'
_undeploy_app
}

View File

@ -19,6 +19,13 @@ setup(){
_common_setup
}
teardown(){
_rm "$BATS_TMPDIR/*.txt"
_rm_remote "/etc/*.txt"
_rm "$BATS_TMPDIR/mydir"
}
@test "validate app argument" {
run $ABRA app cp
assert_failure
@ -49,6 +56,7 @@ setup(){
assert_output --partial 'arguments must take $SERVICE:$PATH form'
}
# bats test_tags=slow
@test "error if local file missing" {
run $ABRA app cp "$TEST_APP_DOMAIN" thisfileshouldnotexist.txt app:/somewhere
assert_failure
@ -62,8 +70,6 @@ setup(){
run $ABRA app cp "$TEST_APP_DOMAIN" "$BATS_TMPDIR/myfile.txt" doesnt_exist:/ --debug
assert_failure
assert_output --partial 'no containers matching'
_rm "$BATS_TMPDIR/myfile.txt"
}
# bats test_tags=slow
@ -76,9 +82,6 @@ setup(){
run $ABRA app run "$TEST_APP_DOMAIN" app cat /etc/myfile.txt
assert_success
assert_output --partial "foo"
_rm "$BATS_TMPDIR/myfile.txt"
_rm_remote "/etc/myfile.txt"
}
# bats test_tags=slow
@ -102,9 +105,6 @@ setup(){
run $ABRA app run "$TEST_APP_DOMAIN" app cat /etc/myfile.txt
assert_success
assert_output --partial "bar"
_rm "$BATS_TMPDIR/myfile.txt"
_rm_remote "/etc/myfile.txt"
}
# bats test_tags=slow
@ -155,9 +155,6 @@ setup(){
run $ABRA app run "$TEST_APP_DOMAIN" app ls /etc/myfile2.txt
assert_success
assert_output --partial "myfile2.txt"
_rm "$BATS_TMPDIR/mydir"
_rm_remote "/etc/myfile*"
}
# bats test_tags=slow
@ -169,9 +166,6 @@ setup(){
assert_success
assert_exists "$BATS_TMPDIR/myfile.txt"
assert bash -c "cat $BATS_TMPDIR/myfile.txt | grep -q foo"
_rm "$BATS_TMPDIR/myfile.txt"
_rm_remote "/etc/myfile.txt"
}
# bats test_tags=slow
@ -183,9 +177,6 @@ setup(){
assert_success
assert_exists "$BATS_TMPDIR/myfile.txt"
assert bash -c "cat $BATS_TMPDIR/myfile.txt | grep -q foo"
_rm "$BATS_TMPDIR/myfile.txt"
_rm_remote "/etc/myfile.txt"
}
# bats test_tags=slow
@ -197,9 +188,6 @@ setup(){
assert_success
assert_exists "$BATS_TMPDIR/myfile2.txt"
assert bash -c "cat $BATS_TMPDIR/myfile2.txt | grep -q foo"
_rm "$BATS_TMPDIR/myfile2.txt"
_rm_remote "/etc/myfile.txt"
}
# bats test_tags=slow
@ -217,10 +205,6 @@ setup(){
assert_exists "$BATS_TMPDIR/mydir/etc/myfile.txt"
assert_success
assert_exists "$BATS_TMPDIR/mydir/etc/myfile2.txt"
_rm "$BATS_TMPDIR/mydir"
_rm_remote "/etc/myfile.txt"
_rm_remote "/etc/myfile2.txt"
}
# bats test_tags=slow
@ -238,8 +222,4 @@ setup(){
assert_exists "$BATS_TMPDIR/mydir/myfile.txt"
assert_success
assert_exists "$BATS_TMPDIR/mydir/myfile2.txt"
_rm "$BATS_TMPDIR/mydir"
_rm_remote "/etc/myfile.txt"
_rm_remote "/etc/myfile2.txt"
}

View File

@ -1,7 +1,6 @@
#!/usr/bin/env bash
setup_file(){
load "$PWD/tests/integration/helpers/git"
load "$PWD/tests/integration/helpers/common"
_common_setup
_add_server
@ -17,14 +16,16 @@ teardown_file(){
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
_undeploy_app
_reset_recipe
_reset_app
_reset_tags
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
}
@test "validate app argument" {
@ -50,11 +51,6 @@ teardown(){
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
@ -71,56 +67,42 @@ teardown(){
--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" {
wantHash=$(_get_n_hash 3)
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'
assert_equal $(_get_current_hash) "$wantHash"
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
assert_equal $(_get_head_hash) $(_get_current_hash)
}
# bats test_tags=slow
@test "ensure recipe not up to date if --offline" {
wantHash=$(_get_n_hash 3)
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'
assert_equal $(_get_current_hash) "$wantHash"
# 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
assert_equal $(_get_current_hash) "$wantHash"
}
# 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
@ -132,32 +114,22 @@ teardown(){
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)"
wantHash=$(_get_n_hash 3)
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)"
assert_equal $(_get_current_hash) "$wantHash"
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 "${wantHash:0:8}"
assert_output --partial 'chaos'
_undeploy_app
_reset_recipe
}
# bats test_tags=slow
@ -169,8 +141,6 @@ teardown(){
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
_undeploy_app
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
}
@ -182,8 +152,6 @@ teardown(){
--no-input --no-converge-checks --chaos
assert_failure
assert_output --partial 'failed lint checks'
_checkout_recipe
}
# bats test_tags=slow
@ -194,8 +162,6 @@ teardown(){
--no-input --no-converge-checks
assert_failure
assert_output --partial 'already deployed'
_undeploy_app
}
# bats test_tags=slow
@ -213,8 +179,6 @@ teardown(){
assert_success
assert_output --partial 'already deployed but continuing'
assert_output --partial '--chaos'
_undeploy_app
}
# bats test_tags=slow
@ -240,9 +204,6 @@ teardown(){
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
@ -277,6 +238,7 @@ teardown(){
assert_success
}
# bats test_tags=dns
@test "ensure domain is checked" {
if [[ "$TEST_SERVER" == "default" ]]; then
skip "domain checks are disabled for local server"
@ -302,8 +264,6 @@ teardown(){
--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" {
@ -317,8 +277,6 @@ teardown(){
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" {
@ -330,8 +288,6 @@ teardown(){
# 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
@ -342,9 +298,6 @@ teardown(){
assert_success
assert_output --partial "compose.yml"
assert_output --partial "compose.extra_env.yml"
_undeploy_app
_reset_app
}
@test "error if no secrets generated" {
@ -359,8 +312,6 @@ teardown(){
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
}
# bats test_tags=slow
@ -393,15 +344,15 @@ teardown(){
_git_commit
# NOTE(d1): 0.1.1+1.20.2 is a previous version which includes compose.extra_secret.yml
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.1+1.20.2" --no-input --no-converge-checks
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.1+1.20.2" \
--no-input --no-converge-checks
assert_success
refute_output --partial 'no such file or directory'
_undeploy_app
_reset_app
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
# TODO(d1): use of `--chaos` is a hack while the following is not fixed
# https://git.coopcloud.tech/coop-cloud/organising/issues/620
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all --chaos
assert_success
_reset_recipe
}

View File

@ -32,13 +32,3 @@ setup(){
assert_failure
assert_output --partial 'is not deployed'
}
# bats test_tags=slow
@test "report errors" {
_deploy_app
run $ABRA app errors "$TEST_APP_DOMAIN"
assert_success
_undeploy_app
}

View File

@ -18,10 +18,7 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
}
@test "list without status" {
@ -46,8 +43,6 @@ teardown(){
assert_output --partial "$TEST_SERVER"
assert_output --partial "$TEST_APP_DOMAIN"
assert_output --partial "deployed"
_undeploy_app
}
@test "filter by server" {

View File

@ -13,14 +13,13 @@ teardown_file(){
setup(){
load "$PWD/tests/integration/helpers/common"
load "$PWD/tests/integration/helpers/git"
_common_setup
_fetch_recipe
}
teardown(){
load "$PWD/tests/integration/helpers/common"
_rm_app
_reset_recipe
}
@test "autocomplete" {
@ -110,7 +109,6 @@ teardown(){
}
@test "ensure recipe up to date if no --offline" {
_reset_recipe
wantHash=$(_get_n_hash 3)
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
@ -126,12 +124,9 @@ teardown(){
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_equal $(_get_head_hash) $(_get_current_hash)
_reset_recipe
}
@test "ensure recipe not up to date if --offline" {
_reset_recipe
wantHash=$(_get_n_hash 3)
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
@ -150,8 +145,6 @@ teardown(){
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_equal $(_get_current_hash) "$wantHash"
_reset_recipe
}
# bats test_tags=slow

View File

@ -18,10 +18,7 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
}
@test "validate app argument" {
@ -48,6 +45,4 @@ teardown(){
assert_success
assert_output --partial 'app'
assert_output --partial 'healthy'
_undeploy_app
}

View File

@ -18,10 +18,11 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
if [[ ! -f "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" ]]; then
_new_app
fi
_undeploy_app
}
@test "validate app argument" {
@ -40,8 +41,6 @@ teardown(){
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
refute_output --partial 'ALERTA'
_new_app
}
# bats test_tags=slow
@ -51,8 +50,6 @@ teardown(){
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
assert_failure
assert_output --partial 'is still deployed'
_undeploy_app
}
@test "detect no secrets to remove" {
@ -71,8 +68,6 @@ teardown(){
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
assert_success
assert_output --partial 'no secrets to remove'
_new_app
}
@test "remove secrets" {
@ -90,8 +85,6 @@ teardown(){
sanitisedDomainName="${TEST_APP_DOMAIN//./_}"
assert_output --partial "$sanitisedDomainName_test_pass_one_v1 removed"
_new_app
}
# bats test_tags=slow
@ -115,8 +108,6 @@ teardown(){
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
assert_success
assert_output --partial 'no volumes to remove'
_new_app
}
# bats test_tags=slow
@ -133,8 +124,6 @@ teardown(){
assert_success
assert_output --partial 'test-volume'
assert_output --partial 'removed'
_new_app
}
@test "remove .env file" {
@ -144,6 +133,4 @@ teardown(){
assert_success
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
_new_app
}

View File

@ -18,10 +18,7 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
}
@test "validate app argument" {
@ -55,6 +52,4 @@ teardown(){
assert_output --regexp 'attempting to scale .* to 0'
assert_output --regexp 'attempting to scale .* to 1'
assert_output --partial 'service successfully restarted'
_undeploy_app
}

View File

@ -19,13 +19,12 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
}
@test "validate app argument" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run $ABRA app restore
assert_failure
assert_output --partial 'no app provided'
@ -36,6 +35,8 @@ teardown(){
}
@test "retrieve recipe if missing" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
assert_success
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
@ -46,6 +47,8 @@ teardown(){
}
@test "bail if unstaged changes and no --chaos" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_success
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
@ -66,6 +69,8 @@ teardown(){
# bats test_tags=slow
@test "do not bail if unstaged changes and --chaos" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run bash -c 'echo "unstaged changes" >> "$ABRA_DIR/recipes/$TEST_RECIPE/foo"'
assert_success
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
@ -105,6 +110,8 @@ teardown(){
}
@test "ensure recipe up to date if no --offline" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
assert_success
@ -119,6 +126,8 @@ teardown(){
}
@test "ensure recipe not up to date if --offline" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
refute [ -z "$latestCommit" ];
@ -142,6 +151,8 @@ teardown(){
}
@test "error if missing service" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run $ABRA app restore "$TEST_APP_DOMAIN"
assert_failure
assert_output --partial 'missing <service>'
@ -152,6 +163,8 @@ teardown(){
}
@test "error if file doesn't exist" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run $ABRA app restore "$TEST_APP_DOMAIN" app DOESNTEXIST
assert_failure
assert_output --partial "doesn't exist"
@ -159,6 +172,8 @@ teardown(){
# bats test_tags=slow
@test "detect labels if restore enabled" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run touch "$BATS_TMPDIR/foo.txt"
assert_success
assert_exists "$BATS_TMPDIR/foo.txt"
@ -180,6 +195,8 @@ teardown(){
# bats test_tags=slow
@test "no error if restore not enabled" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run sed -i '/backupbot.restore=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
assert_success
@ -208,6 +225,8 @@ teardown(){
# bats test_tags=slow
@test "error if service doesn't exist" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run touch "$BATS_TMPDIR/foo.txt"
assert_success
assert_exists "$BATS_TMPDIR/foo.txt"
@ -227,6 +246,8 @@ teardown(){
# bats test_tags=slow
@test "restore backup" {
skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583"
run touch "$BATS_TMPDIR/foo.txt"
assert_success
assert_exists "$BATS_TMPDIR/foo.txt"

View File

@ -19,10 +19,8 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
_reset_recipe
}
@test "validate app argument" {
@ -46,40 +44,32 @@ teardown(){
}
@test "ensure recipe up to date if no --offline" {
wantHash=$(_get_n_hash 3)
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'
assert_equal $(_get_current_hash) "$wantHash"
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_failure
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --partial "up to date"
assert_equal $(_get_current_hash) $(_get_head_hash)
}
@test "ensure recipe not up to date if --offline" {
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
refute [ -z "$latestCommit" ];
wantHash=$(_get_n_hash 3)
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'
assert_equal $(_get_current_hash) "$wantHash"
run $ABRA app rollback "$TEST_APP_DOMAIN" \
--no-input --no-converge-checks --offline
assert_failure
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --regexp 'behind .* 3 commits'
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
assert_success
_reset_recipe "$TEST_RECIPE"
assert_equal $(_get_current_hash) $wantHash
}
@test "bail if unstaged changes and no --chaos" {
@ -133,7 +123,7 @@ teardown(){
run $ABRA app deploy "$TEST_APP_DOMAIN" \
--no-input --chaos
assert_success
assert_output --partial "$latestCommit"
assert_output --partial "${latestCommit}"
assert_output --partial 'chaos'
run $ABRA app rollback "$TEST_APP_DOMAIN" \
@ -141,8 +131,6 @@ teardown(){
assert_success
assert_output --partial "$latestCommit"
assert_output --partial 'chaos'
_undeploy_app
}
# bats test_tags=slow
@ -156,10 +144,6 @@ teardown(){
--no-input --chaos --chaos --no-converge-checks
assert_failure
assert_output --partial 'failed lint checks'
_undeploy_app
_checkout_recipe
}
@test "error if not already deployed" {
@ -177,8 +161,6 @@ teardown(){
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
assert_output --partial "you're on oldest"
_undeploy_app
}
# bats test_tags=slow
@ -190,8 +172,6 @@ teardown(){
run $ABRA app rollback "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_failure
assert_output --partial 'is not a downgrade'
_undeploy_app
}
@test "bail out if specific version and chaos" {
@ -210,8 +190,6 @@ teardown(){
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
assert_output --partial "0.1.0+1.20.0"
_undeploy_app
}
# bats test_tags=slow
@ -223,6 +201,4 @@ teardown(){
run $ABRA app rollback "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_success
assert_output --partial "0.1.0+1.20.0"
_undeploy_app
}

View File

@ -18,10 +18,7 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
}
@test "validate app argument" {
@ -51,8 +48,6 @@ teardown(){
run $ABRA app run "$TEST_APP_DOMAIN" DOESNTEXIST ls
assert_failure
assert_output --partial 'no containers matching'
_undeploy_app
}
# bats test_tags=slow
@ -62,6 +57,4 @@ teardown(){
run $ABRA app run "$TEST_APP_DOMAIN" app ls /
assert_success
assert_output --partial 'root'
_undeploy_app
}

View File

@ -5,6 +5,7 @@ setup_file(){
_common_setup
_add_server
# NOTE(d1): create new app without secrets
run $ABRA app new "$TEST_RECIPE" \
--no-input \
--server "$TEST_SERVER" \
@ -19,18 +20,18 @@ teardown_file(){
_reset_recipe
}
teardown() {
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
_reset_app
_reset_recipe
_checkout_recipe
}
setup(){
load "$PWD/tests/integration/helpers/common"
_common_setup
}
teardown(){
_reset_recipe
_reset_app
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all --no-input
}
@test "generate: validate arguments" {
run $ABRA app secret generate
assert_failure
@ -61,29 +62,23 @@ setup(){
assert_success
assert_output --partial 'test_pass_one'
assert_output --partial 'test_pass_two'
refute_output --partial 'extra_pass'
assert_output --partial 'false'
refute_output --partial 'true'
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
assert_success
assert_output --partial 'test_pass_one'
assert_output --partial 'test_pass_two'
refute_output --partial 'extra_pass'
run $ABRA app secret ls "$TEST_APP_DOMAIN"
assert_success
assert_output --partial 'test_pass_one'
assert_output --partial 'test_pass_two'
refute_output --partial 'extra_pass'
refute_output --partial 'false'
assert_output --partial 'true'
run docker -c "$TEST_SERVER" secret ls
assert_success
assert_output --partial 'test_pass_one'
assert_output --partial 'test_pass_two'
refute_output --partial 'extra_pass'
}
@test "generate: broken if missing version" {
@ -150,11 +145,7 @@ setup(){
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all --chaos
assert_success
assert_output --partial 'test_pass_one not enabled in recipe config'
assert_output --partial 'test_pass_two'
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all --chaos
assert_success
assert_output --partial 'test_pass_one not enabled'
}
@test "generate: ensure secret name uses trimmed stack name" {
@ -184,9 +175,6 @@ setup(){
| jq -r ".[] | select(.name==\"test_pass_two\") | .value" | awk "{print length}"'
assert_success
assert_output --partial '10' # NOTE(d1): hardcoded # length=10 in recipe config
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
assert_success
}
@test "insert: validate arguments" {
@ -228,11 +216,12 @@ setup(){
run bash -c "echo bar >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
run $ABRA app secret insert --file "$TEST_APP_DOMAIN" test_pass_one v1 "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
run $ABRA app secret insert \
--file "$TEST_APP_DOMAIN" test_pass_one v1 "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_success
assert_output --partial 'successfully stored on server'
run $ABRA app secret ls "$TEST_APP_DOMAIN"
run $ABRA app secret ls "$TEST_APP_DOMAIN" --chaos
assert_success
assert_output --partial 'true'
}

View File

@ -19,10 +19,7 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
}
@test "validate app argument" {
@ -51,6 +48,4 @@ teardown(){
sanitisedDomainName="${TEST_APP_DOMAIN//./_}"
assert_output --partial "$sanitisedDomainName_app"
assert_output --partial "nginx"
_undeploy_app
}

View File

@ -18,10 +18,7 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
}
@test "validate app argument" {

View File

@ -18,10 +18,8 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
_reset_recipe
}
@test "validate app argument" {
@ -43,8 +41,6 @@ teardown(){
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input
assert_failure
assert_output --partial 'is not an upgrade'
_undeploy_app
}
@test "bail out if specific version and chaos" {
@ -65,10 +61,6 @@ teardown(){
--no-input --no-converge-checks --chaos
assert_failure
assert_output --partial 'failed lint checks'
_checkout_recipe
_undeploy_app
}
# bats test_tags=slow
@ -78,8 +70,6 @@ teardown(){
run $ABRA app upgrade "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
assert_output --partial "you're on latest"
_undeploy_app
}
# bats test_tags=slow
@ -108,9 +98,6 @@ teardown(){
run $ABRA app undeploy "$appDomain" --no-input
assert_success
# NOTE(d1): to let the stack come down before nuking volumes
sleep 3
run $ABRA app volume remove "$appDomain" --no-input
assert_success
@ -128,8 +115,6 @@ teardown(){
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input --no-converge-checks
assert_success
assert_output --partial '0.2.0+1.21.0'
_undeploy_app
}
# bats test_tags=slow
@ -143,8 +128,6 @@ teardown(){
run $ABRA app upgrade "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
assert_output --partial "$latestRelease"
_undeploy_app
}
# bats test_tags=slow
@ -160,8 +143,6 @@ teardown(){
assert_output --partial "$latestRelease"
assert_output --partial 'release notes baz' # 0.2.0+1.21.0
refute_output --partial 'release notes bar' # 0.1.1+1.20.2
_undeploy_app
}
# bats test_tags=slow
@ -175,8 +156,6 @@ teardown(){
assert_output --partial '0.1.1+1.20.2'
assert_output --partial 'release notes bar' # 0.1.1+1.20.2
refute_output --partial 'release notes baz' # 0.2.0+1.21.0
_undeploy_app
}
# bats test_tags=slow
@ -192,8 +171,6 @@ teardown(){
assert_output --partial "$latestRelease"
assert_output --partial 'release notes bar' # 0.1.1+1.20.2
assert_output --partial 'release notes baz' # 0.2.0+1.21.0
_undeploy_app
}
# bats test_tags=slow
@ -207,6 +184,4 @@ teardown(){
assert_output --partial '0.2.0+1.21.0'
assert_output --partial 'release notes bar' # 0.1.1+1.20.2
assert_output --partial 'release notes baz' # 0.2.0+1.21.0
_undeploy_app
}

View File

@ -18,10 +18,8 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
_reset_recipe
}
@test "validate app argument" {
@ -52,22 +50,15 @@ teardown(){
run $ABRA app version "$TEST_APP_DOMAIN"
assert_failure
assert_output --partial 'failed to determine'
_checkout_recipe
_undeploy_app
}
# bats test_tags=slow
@test "error if not in catalogue" {
skip "known issue, see https://git.coopcloud.tech/coop-cloud/recipes-catalogue-json/issues/6"
_deploy_app
run $ABRA app version "$TEST_APP_DOMAIN"
assert_failure
assert_output --partial 'does not exist'
_undeploy_app
}
# bats test_tags=slow
@ -93,9 +84,6 @@ teardown(){
run $ABRA app undeploy "$appDomain" --no-input
assert_success
# NOTE(d1): to let the stack come down before nuking volumes
sleep 5
run $ABRA app volume remove "$appDomain" --no-input
assert_success

View File

@ -18,10 +18,7 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
}
@test "ls validate app argument" {
@ -47,8 +44,6 @@ teardown(){
run $ABRA app volume ls "$TEST_APP_DOMAIN"
assert_success
assert_output --partial 'test-volume'
_undeploy_app
}
@test "rm validate app argument" {
@ -68,14 +63,13 @@ teardown(){
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force
assert_failure
assert_output --partial 'is still deployed'
_undeploy_app
}
# bats test_tags=slow
@test "remove volumes" {
_deploy_app
sleep 3 # NOTE(d1): hack to avoid "network not found"
_deploy_app
_undeploy_app
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force
@ -85,8 +79,9 @@ teardown(){
# bats test_tags=slow
@test "remove no volumes" {
_deploy_app
sleep 3 # NOTE(d1): hack to avoid "network not found"
_deploy_app
_undeploy_app
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force

View File

@ -27,8 +27,9 @@ setup(){
@test "abra directory is created" {
run $ABRA app ls
# no servers yet, so will fail. however, it will run the required code which
# checks if it should create these base directories and that is what we want
# NOTE(d1): no servers yet, so will fail. however, it will run the required
# code which checks if it should create these base directories and that is
# what we want
assert_failure
assert_exists "$ABRA_DIR"
@ -36,16 +37,13 @@ setup(){
assert_exists "$ABRA_DIR/recipes"
assert_exists "$ABRA_DIR/backups"
assert_exists "$ABRA_DIR/vendor"
assert_exists "$ABRA_DIR/catalogue"
assert_not_exists "$ABRA_DIR/catalogue"
}
@test "catalogue recipe is a git repository" {
run $ABRA app ls
# no servers yet, so will fail. however, it will run the required code which
# checks if it should create these base directories and that is what we want
assert_failure
run $ABRA recipe fetch "$TEST_RECIPE"
assert_success
assert_output --partial 'local recipe catalogue is missing'
assert_exists "$ABRA_DIR/catalogue"

View File

@ -46,10 +46,5 @@ _reset_app(){
assert_success
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
run $ABRA app new "$TEST_RECIPE" \
--no-input \
--server "$TEST_SERVER" \
--domain "$TEST_APP_DOMAIN"
assert_success
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
_new_app
}

View File

@ -10,6 +10,7 @@ _common_setup() {
load "$PWD/tests/integration/helpers/git"
load "$PWD/tests/integration/helpers/recipe"
load "$PWD/tests/integration/helpers/server"
load "$PWD/tests/integration/helpers/docker"
export ABRA="$PWD/abra"
export KADABRA="$PWD/kadabra"
@ -17,4 +18,6 @@ _common_setup() {
export TEST_APP_NAME="$(basename "${BATS_TEST_FILENAME//./_}")"
export TEST_APP_DOMAIN="$TEST_APP_NAME.$TEST_SERVER"
export TEST_RECIPE="abra-test-recipe"
_ensure_swarm
}

View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
_ensure_swarm() {
if [ "$(docker info | grep Swarm | sed 's/Swarm: //g' | tr -d ' ')" == "inactive" ]; then
run docker swarm init
assert_success
fi
if ! $(docker network ls | grep -q 'proxy'); then
run docker network create -d overlay proxy
assert_success
fi
}

View File

@ -46,25 +46,17 @@ _git_commit() {
}
_get_tag_hash() {
tagHash=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-list -n 1 "$1")
assert_success
echo "$tagHash"
echo $(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-list -n 1 "$1")
}
_get_head_hash() {
headHash=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" show -s --format="%H" HEAD)
assert_success
echo "$headHash"
echo $(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" show -s --format="%H" HEAD)
}
_get_current_hash() {
currentHash=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" show -s --format="%H")
assert_success
echo "$currentHash"
echo $(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" show -s --format="%H")
}
_get_n_hash() {
nHash=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" show -s --format="%H" "HEAD~$1")
assert_success
echo "$nHash"
echo $(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" show -s --format="%H" "HEAD~$1")
}

View File

@ -17,3 +17,12 @@ _reset_recipe(){
_fetch_recipe
}
_ensure_latest_version(){
latestRelease=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | tail -n 1)
if [ ! $latestRelease = "$1" ]; then
echo "expected latest recipe version of '$1', saw: $latestRelease"
return 1
fi
}

View File

@ -28,6 +28,8 @@ teardown(){
# bats test_tags=slow
@test "install release candidate from script" {
skip "current RC is brokenly specified in the installer script"
run bash -c 'curl https://install.abra.coopcloud.tech | bash -s -- --rc'
assert_success

View File

@ -5,6 +5,10 @@ setup() {
_common_setup
}
teardown(){
_reset_recipe
}
@test "show unstaged changes" {
run $ABRA recipe diff "$TEST_RECIPE"
assert_success
@ -16,6 +20,4 @@ setup() {
run $ABRA recipe diff "$TEST_RECIPE"
assert_success
assert_output --partial 'traefik.enable'
_reset_recipe
}

View File

@ -5,6 +5,7 @@ setup() {
_common_setup
}
# bats test_tags=slow
@test "recipe fetch all" {
run rm -rf "$ABRA_DIR/recipes/matrix-synapse"
assert_success

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
teardown_file() {
setup_file(){
load "$PWD/tests/integration/helpers/common"
_common_setup
_reset_recipe
_fetch_recipe
}
setup() {
@ -11,6 +11,10 @@ setup() {
_common_setup
}
teardown(){
_reset_recipe
}
@test "recipe lint" {
run $ABRA recipe lint gitea
assert_success
@ -62,35 +66,31 @@ setup() {
}
@test "ensure recipe up to date if no --offline" {
wantHash=$(_get_n_hash 3)
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'
assert_equal $(_get_current_hash) "$wantHash"
run $ABRA recipe lint "$TEST_RECIPE"
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --regexp 'behind .* 3 commits'
_reset_recipe
assert_equal $(_get_head_hash) $(_get_current_hash)
}
@test "ensure recipe not up to date if --offline" {
wantHash=$(_get_n_hash 3)
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'
assert_equal $(_get_current_hash) "$wantHash"
run $ABRA recipe lint "$TEST_RECIPE" --offline
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --regexp 'behind .* 3 commits'
_reset_recipe
assert_equal $(_get_current_hash) "$wantHash"
}
@test "recipe lint warns on error" {
@ -103,6 +103,4 @@ setup() {
run $ABRA recipe lint "$TEST_RECIPE" --chaos
assert_success --partial 'watch out, some critical errors are present'
_checkout_recipe
}

View File

@ -52,4 +52,3 @@ teardown(){
assert_output --partial 'fooUser'
assert_output --partial 'foo@example.com'
}

View File

@ -32,8 +32,9 @@ teardown() {
assert_output --partial 'unable to validate recipe'
}
# NOTE(d1): relies on only 3 versions being published for the $TEST_RECIPE.
@test "release patch bump" {
_ensure_latest_version "0.3.0+1.21.0"
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --patch
assert_success
@ -47,7 +48,7 @@ teardown() {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.2.1+1.21.6'
assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.3.1+1.21.6'
run $ABRA recipe release "$TEST_RECIPE" --no-input --patch
assert_success
@ -55,13 +56,12 @@ teardown() {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag --list
assert_success
assert_output --partial '0.2.1+1.21.6'
assert_output --partial '0.3.1+1.21.6'
}
# NOTE(d1): this test can't assert hardcoded versions since we upgrade a minor
# version which could be anything in the future. so, we do our best with
# --regexp.
@test "release minor bump" {
_ensure_latest_version "0.3.0+1.21.0"
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --minor
assert_success
@ -75,7 +75,7 @@ teardown() {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.3\.0\+1\.2.*'
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.4\.0\+1\.2.*'
run $ABRA recipe release "$TEST_RECIPE" --no-input --minor
assert_success
@ -83,7 +83,7 @@ teardown() {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag --list
assert_success
assert_output --regexp '0\.3\.0\+1\.2.*'
assert_output --regexp '0\.4\.0\+1\.2.*'
}
@test "unknown files not committed" {
@ -103,11 +103,14 @@ teardown() {
assert_output --partial "fatal: pathspec 'foo' did not match any files"
}
# NOTE: relies on 0.2.x being the last minor version
@test "release with next release note" {
_ensure_latest_version "0.3.0+1.21.0"
_mkfile "$ABRA_DIR/recipes/$TEST_RECIPE/release/next" "those are some release notes for the next release"
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" add release/next
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" commit -m "added some release notes"
assert_success
@ -116,6 +119,6 @@ teardown() {
assert_output --partial 'no -p/--publish passed, not publishing'
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/release/next"
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/release/0.3.0+1.21.0"
assert_file_contains "$ABRA_DIR/recipes/$TEST_RECIPE/release/0.3.0+1.21.0" "those are some release notes for the next release"
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/release/0.4.0+1.21.0"
assert_file_contains "$ABRA_DIR/recipes/$TEST_RECIPE/release/0.4.0+1.21.0" "those are some release notes for the next release"
}

View File

@ -16,6 +16,11 @@ setup(){
_common_setup
}
teardown(){
_reset_recipe
_reset_tags
}
@test "validate recipe argument" {
run $ABRA recipe sync --no-input
assert_failure
@ -40,8 +45,6 @@ setup(){
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_success
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
_checkout_recipe
}
@test "detect unstaged label changes" {
@ -54,12 +57,11 @@ setup(){
run $ABRA recipe sync "$TEST_RECIPE" --patch
assert_success
assert_output --partial 'is already set, nothing to do?'
_checkout_recipe
}
# NOTE(d1): relies on only 3 versions being published for the $TEST_RECIPE.
@test "sync patch label bump" {
_ensure_latest_version "0.3.0+1.21.0"
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --patch
assert_success
@ -72,12 +74,12 @@ setup(){
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.2.1+1.21.6'
_checkout_recipe
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.3\.1\+1\.2.*'
}
@test "sync minor label bump" {
_ensure_latest_version "0.3.0+1.21.0"
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --minor
assert_success
@ -90,9 +92,7 @@ setup(){
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.2\.0\+1\.2.*'
_checkout_recipe
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.4\.0\+1\.2.*'
}
@test "error if --no-input and no initial version" {
@ -102,8 +102,6 @@ setup(){
assert_failure
assert_output --partial 'unable to continue'
assert_output --partial 'initial version'
_reset_tags
}
@test "output label sync only once" {
@ -118,6 +116,4 @@ setup(){
assert_success
assert_line --index 0 --partial 'synced label'
refute_line --index 1 --partial 'synced label'
_checkout_recipe
}

View File

@ -17,6 +17,10 @@ setup(){
_common_setup
}
teardown(){
_reset_recipe
}
@test "validate recipe argument" {
run $ABRA recipe upgrade --no-input
assert_failure
@ -57,20 +61,18 @@ setup(){
}
@test "ensure up to date" {
wantHash=$(_get_n_hash 3)
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'
assert_equal $(_get_current_hash) "$wantHash"
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input
assert_success
assert_output --partial 'can upgrade service: app'
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --regexp 'behind .* 3 commits'
_reset_recipe
assert_equal $(_get_head_hash) $(_get_current_hash)
}
@test "only one of -x/y/z flags" {
@ -79,16 +81,18 @@ setup(){
assert_output --partial 'you can only use one of'
}
# NOTE(d1): relies on only 3 versions being published for the $TEST_RECIPE.
@test "upgrade patch" {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "0.2.0+1.21.0"
assert_success
assert_equal $(_get_tag_hash 0.2.0+1.21.0) $(_get_current_hash)
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --patch
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --partial 'image: nginx:1.21.6'
_checkout_recipe
}
@test "upgrade minor" {
@ -98,6 +102,4 @@ setup(){
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --regexp 'image: nginx:1.2.*'
_checkout_recipe
}

View File

@ -12,8 +12,6 @@ setup() {
}
@test "error if not present in catalogue" {
skip "known issue, see https://git.coopcloud.tech/coop-cloud/recipes-catalogue-json/issues/6"
run $ABRA recipe versions "$TEST_RECIPE"
assert_failure
assert_output --partial "is not published on the catalogue"

View File

@ -3,25 +3,19 @@
setup_file(){
load "$PWD/tests/integration/helpers/common"
_common_setup
run docker swarm leave --force
}
setup(){
load "$PWD/tests/integration/helpers/common"
_common_setup
run docker swarm init
assert_success
}
teardown(){
run docker swarm leave --force
assert_success
_rm_server
_ensure_swarm
}
# bats test_tags=slow,dns
@test "add new server" {
run $ABRA server add "$TEST_SERVER"
assert_success
@ -57,6 +51,7 @@ teardown(){
assert_output --partial 'swarm mode not enabled on local server'
}
# bats test_tags=slow
@test "cleanup when cannot add server" {
run $ABRA server add example.com
assert_failure

View File

@ -22,9 +22,6 @@ setup(){
}
@test "show 'local' when --local server created" {
run docker swarm init
assert_success
run $ABRA server add --local
assert_success
assert_exists "$ABRA_DIR/servers/default"
@ -34,11 +31,6 @@ setup(){
assert_output --partial 'default'
assert_output --partial 'local'
assert_output --partial 'n/a'
run docker swarm leave --force
assert_success
_rm_default_server
}
@test "filter by problem" {

View File

@ -26,6 +26,10 @@ setup(){
}
@test "remove server" {
if [ "$TEST_SERVER" = "default" ]; then
skip "cannot delete 'default' server (local)"
fi
assert_exists "$ABRA_DIR/servers/$TEST_SERVER"
assert bash -c "docker context ls | grep -q $TEST_SERVER"

View File

@ -29,6 +29,8 @@ teardown(){
# bats test_tags=slow
@test "abra upgrade release candidate" {
skip "TODO: RC publishing broke somehow, needs investigation"
run $ABRA upgrade --rc
assert_success
assert_output --partial 'Public interest infrastructure'