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>
252 lines
6.5 KiB
Bash
252 lines
6.5 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
|
|
}
|
|
|
|
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 restore
|
|
assert_failure
|
|
assert_output --partial 'no app provided'
|
|
|
|
run $ABRA app restore DOESNTEXIST
|
|
assert_failure
|
|
assert_output --partial 'cannot find app'
|
|
}
|
|
|
|
@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 restore "$TEST_APP_DOMAIN" app DOESNTEXIST
|
|
assert_failure
|
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
}
|
|
|
|
@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 restore "$TEST_APP_DOMAIN" app DOESNTEXIST
|
|
assert_failure
|
|
assert_output --partial 'locally unstaged changes'
|
|
|
|
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 touch "$BATS_TMPDIR/foo.txt"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/foo.txt"
|
|
|
|
run tar -cvf "$BATS_TMPDIR/foo.tar.gz" "$BATS_TMPDIR/foo.txt"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/foo.tar.gz"
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --chaos --no-input
|
|
assert_success
|
|
|
|
run $ABRA app restore "$TEST_APP_DOMAIN" app "$BATS_TMPDIR/foo.tar.gz" \
|
|
--debug --chaos
|
|
assert_success
|
|
assert_output --partial 'restore config detected'
|
|
assert_output --partial 'detected pre-hook command'
|
|
assert_output --partial 'detected post-hook command'
|
|
|
|
run $ABRA app run "$TEST_APP_DOMAIN" app ls "$BATS_TMPDIR"
|
|
assert_success
|
|
assert_output --partial 'foo.txt'
|
|
|
|
_undeploy_app
|
|
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
|
|
_checkout_recipe
|
|
}
|
|
|
|
@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 restore "$TEST_APP_DOMAIN" app
|
|
assert_failure
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_output --partial "up to date"
|
|
}
|
|
|
|
@test "ensure recipe not up to date if --offline" {
|
|
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
|
|
refute [ -z "$latestCommit" ];
|
|
|
|
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 restore "$TEST_APP_DOMAIN" app --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
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_output --partial "HEAD detached at $latestCommit"
|
|
}
|
|
|
|
@test "error if missing service" {
|
|
run $ABRA app restore "$TEST_APP_DOMAIN"
|
|
assert_failure
|
|
assert_output --partial 'missing <service>'
|
|
|
|
run $ABRA app restore "$TEST_APP_DOMAIN" app
|
|
assert_failure
|
|
assert_output --partial 'missing <file>'
|
|
}
|
|
|
|
@test "error if file doesn't exist" {
|
|
run $ABRA app restore "$TEST_APP_DOMAIN" app DOESNTEXIST
|
|
assert_failure
|
|
assert_output --partial "doesn't exist"
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "detect labels if restore enabled" {
|
|
run touch "$BATS_TMPDIR/foo.txt"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/foo.txt"
|
|
|
|
run tar -cvf "$BATS_TMPDIR/foo.tar.gz" "$BATS_TMPDIR/foo.txt"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/foo.tar.gz"
|
|
|
|
_deploy_app
|
|
|
|
run $ABRA app restore "$TEST_APP_DOMAIN" app "$BATS_TMPDIR/foo.tar.gz" --debug
|
|
assert_success
|
|
assert_output --partial 'restore config detected'
|
|
assert_output --partial 'detected pre-hook command'
|
|
assert_output --partial 'detected post-hook command'
|
|
|
|
_undeploy_app
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "no error if restore not enabled" {
|
|
run sed -i '/backupbot.restore=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
|
assert_success
|
|
|
|
run touch "$BATS_TMPDIR/foo.txt"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/foo.txt"
|
|
|
|
run tar -cvf "$BATS_TMPDIR/foo.tar.gz" "$BATS_TMPDIR/foo.txt"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/foo.tar.gz"
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --chaos
|
|
assert_success
|
|
|
|
run $ABRA app restore "$TEST_APP_DOMAIN" app "$BATS_TMPDIR/foo.tar.gz" \
|
|
--debug --chaos
|
|
assert_success
|
|
refute_output --partial 'restore config detected'
|
|
refute_output --partial 'detected pre-hook command'
|
|
refute_output --partial 'detected post-hook command'
|
|
|
|
_undeploy_app
|
|
|
|
_checkout_recipe
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "error if service doesn't exist" {
|
|
run touch "$BATS_TMPDIR/foo.txt"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/foo.txt"
|
|
|
|
run tar -cvf "$BATS_TMPDIR/foo.tar.gz" "$BATS_TMPDIR/foo.txt"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/foo.tar.gz"
|
|
|
|
_deploy_app
|
|
|
|
run $ABRA app restore "$TEST_APP_DOMAIN" DOESNTEXIST "$BATS_TMPDIR/foo.tar.gz" --debug
|
|
assert_failure
|
|
assert_output --partial 'no containers matching'
|
|
|
|
_undeploy_app
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "restore backup" {
|
|
run touch "$BATS_TMPDIR/foo.txt"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/foo.txt"
|
|
|
|
run tar -cvf "$BATS_TMPDIR/foo.tar.gz" "$BATS_TMPDIR/foo.txt"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/foo.tar.gz"
|
|
|
|
_deploy_app
|
|
|
|
run $ABRA app restore "$TEST_APP_DOMAIN" app "$BATS_TMPDIR/foo.tar.gz" --debug
|
|
assert_success
|
|
assert_output --partial 'restore config detected'
|
|
assert_output --partial 'detected pre-hook command'
|
|
assert_output --partial 'detected post-hook command'
|
|
|
|
run $ABRA app run "$TEST_APP_DOMAIN" app ls "$BATS_TMPDIR"
|
|
assert_success
|
|
assert_output --partial 'foo.txt'
|
|
|
|
_undeploy_app
|
|
}
|