forked from toolshed/abra
test: moar integration tests [ci skip]
This commit is contained in:
10
tests/README.md
Normal file
10
tests/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Test suite
|
||||
|
||||
* Unit testing is done in the packages themselves, run `find . -name
|
||||
"*_test.go"` to find those. Use `make test` to run the entire unit test
|
||||
suite. Some unit tests require mocked files which are located in
|
||||
`./tests/resources.`
|
||||
|
||||
* Integration tests are in `./tests/integration`. Please see [these
|
||||
docs](https://docs.coopcloud.tech/abra/hack/#integration-tests) for
|
||||
instructions and tips on how to run them.
|
80
tests/integration/app_backup.bats
Normal file
80
tests/integration/app_backup.bats
Normal file
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "retrieve recipe if missing" {
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
|
||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
|
||||
run $ABRA app backup "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'no containers matching'
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "detect backup labels" {
|
||||
run $ABRA app backup "$TEST_APP_DOMAIN" --debug
|
||||
assert_failure
|
||||
assert_output --partial 'no containers matching'
|
||||
|
||||
assert_output --partial 'detected backup paths'
|
||||
assert_output --partial 'detected pre-hook command'
|
||||
assert_output --partial 'detected post-hook command'
|
||||
}
|
||||
|
||||
@test "error if backups not enabled" {
|
||||
run sed -i '/backupbot.backup=true/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
||||
assert_success
|
||||
|
||||
run $ABRA app backup "$TEST_APP_DOMAIN" app
|
||||
assert_failure
|
||||
assert_output --partial 'no backup config for app'
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "error if backup paths not configured" {
|
||||
run sed -i '/backupbot.backup.path=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
||||
assert_success
|
||||
|
||||
run $ABRA app backup "$TEST_APP_DOMAIN" app
|
||||
assert_failure
|
||||
assert_output --partial 'backup paths are empty for app?'
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "backup single service" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app backup "$TEST_APP_DOMAIN" app
|
||||
assert_success
|
||||
assert_output --partial 'running backup for the app service'
|
||||
|
||||
sanitisedDomainName="${TEST_APP_DOMAIN//./_}"
|
||||
assert_output --partial "_$sanitisedDomainName_app"
|
||||
|
||||
assert_exists "$ABRA_DIR/backups"
|
||||
assert bash -c "ls $ABRA_DIR/backups | grep -q $1_$sanitisedDomainName_app"
|
||||
|
||||
_undeploy_app
|
||||
}
|
62
tests/integration/app_check.bats
Normal file
62
tests/integration/app_check.bats
Normal file
@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app check
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app check 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 check "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'all necessary environment variables defined'
|
||||
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "error if missing .env.sample" {
|
||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/.env.sample"
|
||||
assert_success
|
||||
|
||||
run $ABRA app check "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial '.env.sample does not exist?'
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "error if missing env var" {
|
||||
run bash -c 'echo "NEW_VAR=foo" >> "$ABRA_DIR/recipes/$TEST_RECIPE/.env.sample"'
|
||||
assert_success
|
||||
|
||||
run $ABRA app check "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial \
|
||||
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env is missing NEW_VAR"
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
115
tests/integration/app_cmd.bats
Normal file
115
tests/integration/app_cmd.bats
Normal file
@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app cmd
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app cmd 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 cmd "$TEST_APP_DOMAIN" test_cmd --local
|
||||
assert_success
|
||||
assert_output --partial 'baz'
|
||||
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "error if missing arguments without passing --local" {
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'missing arguments'
|
||||
}
|
||||
|
||||
@test "error if missing arguments when passing --local" {
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" --local
|
||||
assert_failure
|
||||
assert_output --partial 'missing arguments'
|
||||
}
|
||||
|
||||
@test "cannot use --local and --user at same time" {
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local --user root
|
||||
assert_failure
|
||||
assert_output --partial 'cannot use --local & --user together'
|
||||
}
|
||||
|
||||
@test "error if missing abra.sh" {
|
||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/abra.sh"
|
||||
assert_success
|
||||
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local
|
||||
assert_failure
|
||||
assert_output --partial "$ABRA_DIR/recipes/$TEST_RECIPE/abra.sh does not exist"
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "error if missing command" {
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" doesnt_exist --local
|
||||
assert_failure
|
||||
assert_output --partial "doesn't have a doesnt_exist function"
|
||||
}
|
||||
|
||||
@test "run --local command" {
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local
|
||||
assert_success
|
||||
assert_output --partial 'baz'
|
||||
}
|
||||
|
||||
@test "run command with single arg" {
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd_arg --local -- bing
|
||||
assert_success
|
||||
assert_output --partial 'bing'
|
||||
}
|
||||
|
||||
@test "run command with several args" {
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd_args --local -- bong bang
|
||||
assert_success
|
||||
assert_output --partial 'bong bang'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "run command on service" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" app test_cmd
|
||||
assert_success
|
||||
assert_output --partial 'baz'
|
||||
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "error if missing service" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" doesnt_exist test_cmd
|
||||
assert_failure
|
||||
assert_output --partial 'no service doesnt_exist'
|
||||
|
||||
_undeploy_app
|
||||
}
|
26
tests/integration/app_config.bats
Normal file
26
tests/integration/app_config.bats
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app config
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app config DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
123
tests/integration/app_cp.bats
Normal file
123
tests/integration/app_cp.bats
Normal file
@ -0,0 +1,123 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app cp
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app cp DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
@test "error if missing src/dest arguments" {
|
||||
run $ABRA app cp "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'missing <src> argument'
|
||||
|
||||
run $ABRA app cp "$TEST_APP_DOMAIN" myfile.txt
|
||||
assert_failure
|
||||
assert_output --partial 'missing <dest> argument'
|
||||
}
|
||||
|
||||
@test "either src/dest has correct syntax" {
|
||||
run $ABRA app cp "$TEST_APP_DOMAIN" myfile.txt app
|
||||
assert_failure
|
||||
assert_output --partial 'arguments must take $SERVICE:$PATH form'
|
||||
|
||||
run $ABRA app cp "$TEST_APP_DOMAIN" app .
|
||||
assert_failure
|
||||
assert_output --partial 'arguments must take $SERVICE:$PATH form'
|
||||
}
|
||||
|
||||
@test "detect 'coming FROM' syntax" {
|
||||
run $ABRA app cp "$TEST_APP_DOMAIN" app:/myfile.txt . --debug
|
||||
assert_failure
|
||||
assert_output --partial 'coming FROM the container'
|
||||
}
|
||||
|
||||
@test "detect 'going TO' syntax" {
|
||||
run $ABRA app cp "$TEST_APP_DOMAIN" myfile.txt app:/somewhere --debug
|
||||
assert_failure
|
||||
assert_output --partial 'going TO the container'
|
||||
}
|
||||
|
||||
@test "error if local file missing" {
|
||||
run $ABRA app cp "$TEST_APP_DOMAIN" myfile.txt app:/somewhere
|
||||
assert_failure
|
||||
assert_output --partial 'myfile.txt does not exist locally?'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "error if service doesn't exist" {
|
||||
_deploy_app
|
||||
|
||||
run bash -c "echo foo >> $BATS_TMPDIR/myfile.txt"
|
||||
assert_success
|
||||
|
||||
run $ABRA app cp "$TEST_APP_DOMAIN" "$BATS_TMPDIR/myfile.txt" doesnt_exist:/
|
||||
assert_failure
|
||||
assert_output --partial 'no containers matching'
|
||||
|
||||
run rm -rf "$BATS_TMPDIR/myfile.txt"
|
||||
assert_success
|
||||
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "copy to container" {
|
||||
_deploy_app
|
||||
|
||||
run bash -c "echo foo >> $BATS_TMPDIR/myfile.txt"
|
||||
assert_success
|
||||
|
||||
run $ABRA app cp "$TEST_APP_DOMAIN" "$BATS_TMPDIR/myfile.txt" app:/etc
|
||||
assert_success
|
||||
|
||||
run rm -rf "$BATS_TMPDIR/myfile.txt"
|
||||
assert_success
|
||||
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "copy from container" {
|
||||
_deploy_app
|
||||
|
||||
run bash -c "echo foo >> $BATS_TMPDIR/myfile.txt"
|
||||
assert_success
|
||||
|
||||
run $ABRA app cp "$TEST_APP_DOMAIN" "$BATS_TMPDIR/myfile.txt" app:/etc
|
||||
assert_success
|
||||
|
||||
run rm -rf "$BATS_TMPDIR/myfile.txt"
|
||||
assert_success
|
||||
|
||||
run $ABRA app cp "$TEST_APP_DOMAIN" app:/etc/myfile.txt "$BATS_TMPDIR"
|
||||
assert_success
|
||||
assert_exists "$BATS_TMPDIR/myfile.txt"
|
||||
assert bash -c "cat $BATS_TMPDIR/myfile.txt | grep -q foo"
|
||||
|
||||
run rm -rf "$BATS_TMPDIR/myfile.txt"
|
||||
assert_success
|
||||
|
||||
_undeploy_app
|
||||
}
|
276
tests/integration/app_deploy.bats
Normal file
276
tests/integration/app_deploy.bats
Normal file
@ -0,0 +1,276 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@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"
|
||||
}
|
||||
|
||||
# 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 --partial 'behind 3'
|
||||
|
||||
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 --partial 'behind 3'
|
||||
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@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 --partial 'behind 3'
|
||||
|
||||
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
||||
--no-input --no-converge-checks --offline
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
_undeploy_app
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "deploy latest commit if no published versions and no --chaos" {
|
||||
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
|
||||
|
||||
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||
assert_success
|
||||
assert_output --partial "$latestCommit"
|
||||
refute_output --partial 'chaos'
|
||||
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
# 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 --partial 'behind 3'
|
||||
|
||||
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
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
||||
assert_success
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
||||
|
||||
# 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 "$TEST_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
|
||||
}
|
||||
|
||||
# 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
|
||||
}
|
43
tests/integration/app_errors.bats
Normal file
43
tests/integration/app_errors.bats
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app errors
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app errors DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
@test "error if not deployed" {
|
||||
run $ABRA app errors "$TEST_APP_DOMAIN"
|
||||
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
|
||||
}
|
130
tests/integration/app_list.bats
Normal file
130
tests/integration/app_list.bats
Normal file
@ -0,0 +1,130 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "list without status" {
|
||||
run $ABRA app ls
|
||||
assert_success
|
||||
assert_output --partial "$TEST_SERVER"
|
||||
assert_output --partial "$TEST_APP_DOMAIN"
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "list with status" {
|
||||
run $ABRA app ls --status
|
||||
assert_success
|
||||
assert_output --partial "$TEST_SERVER"
|
||||
assert_output --partial "$TEST_APP_DOMAIN"
|
||||
assert_output --partial "unknown"
|
||||
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app ls --status
|
||||
assert_success
|
||||
assert_output --partial "$TEST_SERVER"
|
||||
assert_output --partial "$TEST_APP_DOMAIN"
|
||||
assert_output --partial "deployed"
|
||||
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
@test "filter by server" {
|
||||
run mkdir -p "$ABRA_DIR/servers/foo.com"
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/foo.com"
|
||||
|
||||
run cp \
|
||||
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" \
|
||||
"$ABRA_DIR/servers/foo.com/app.foo.com.env"
|
||||
assert_exists "$ABRA_DIR/servers/foo.com/app.foo.com.env"
|
||||
|
||||
run $ABRA app ls
|
||||
assert_success
|
||||
assert_output --partial "$TEST_SERVER"
|
||||
assert_output --partial "foo.com"
|
||||
|
||||
run $ABRA app ls --server foo.com
|
||||
assert_success
|
||||
refute_output --partial "server: $TEST_SERVER |"
|
||||
assert_output --partial "server: foo.com |"
|
||||
|
||||
run rm -rf "$ABRA_DIR/servers/foo.com"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/servers/foo.com"
|
||||
}
|
||||
|
||||
@test "filter by recipe" {
|
||||
run mkdir -p "$ABRA_DIR/servers/foo.com"
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/foo.com"
|
||||
|
||||
run cp \
|
||||
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" \
|
||||
"$ABRA_DIR/servers/foo.com/app.foo.com.env"
|
||||
assert_exists "$ABRA_DIR/servers/foo.com/app.foo.com.env"
|
||||
|
||||
run sed -i "s/TYPE=$TEST_RECIPE/TYPE=foo-recipe/g" "$ABRA_DIR/servers/foo.com/app.foo.com.env"
|
||||
assert grep -q "TYPE=foo-recipe" "$ABRA_DIR/servers/foo.com/app.foo.com.env"
|
||||
|
||||
run $ABRA app ls
|
||||
assert_success
|
||||
assert_output --partial "$TEST_RECIPE"
|
||||
assert_output --partial "foo-recipe"
|
||||
|
||||
run $ABRA app ls --recipe foo-recipe
|
||||
assert_success
|
||||
refute_output --partial "$TEST_RECIPE"
|
||||
assert_output --partial "foo-recipe"
|
||||
}
|
||||
|
||||
@test "server stats are correct" {
|
||||
run $ABRA app ls
|
||||
assert_success
|
||||
assert_output --partial "server: $TEST_SERVER"
|
||||
assert_output --partial "total apps: 1"
|
||||
|
||||
run mkdir -p "$ABRA_DIR/servers/foo.com"
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/foo.com"
|
||||
|
||||
run cp \
|
||||
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" \
|
||||
"$ABRA_DIR/servers/foo.com/app.foo.com.env"
|
||||
assert_exists "$ABRA_DIR/servers/foo.com/app.foo.com.env"
|
||||
|
||||
run $ABRA app ls
|
||||
assert_success
|
||||
assert_output --partial "$TEST_SERVER"
|
||||
assert_output --partial "foo.com"
|
||||
assert_output --partial "total servers: 2"
|
||||
assert_output --partial "total apps: 2"
|
||||
|
||||
run rm -rf "$ABRA_DIR/servers/foo.com"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/servers/foo.com"
|
||||
}
|
||||
|
||||
@test "output is machine readable" {
|
||||
run $ABRA app ls --machine
|
||||
|
||||
expectedOutput='{"'
|
||||
expectedOutput+="$TEST_SERVER"
|
||||
expectedOutput+='":{"apps":'
|
||||
|
||||
assert_output --partial "$expectedOutput"
|
||||
}
|
33
tests/integration/app_logs.bats
Normal file
33
tests/integration/app_logs.bats
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app logs
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app logs DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
@test "error if not deployed" {
|
||||
run $ABRA app logs "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'is not deployed'
|
||||
}
|
55
tests/integration/app_new.bats
Normal file
55
tests/integration/app_new.bats
Normal file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "create new app" {
|
||||
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"
|
||||
|
||||
_rm_app
|
||||
}
|
||||
|
||||
@test "does not overwrite existing env files" {
|
||||
_new_app
|
||||
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'already exists'
|
||||
|
||||
_rm_app
|
||||
}
|
||||
|
||||
@test "generate secrets" {
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$TEST_APP_DOMAIN" \
|
||||
--secrets
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'test_password'
|
||||
}
|
46
tests/integration/app_ps.bats
Normal file
46
tests/integration/app_ps.bats
Normal file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app ps
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app ps DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
@test "error if not deployed" {
|
||||
run $ABRA app ps "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'is not deployed'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "show ps report" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app ps "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'app'
|
||||
assert_output --partial 'healthy'
|
||||
|
||||
_undeploy_app
|
||||
}
|
148
tests/integration/app_remove.bats
Normal file
148
tests/integration/app_remove.bats
Normal file
@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@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 "do not show ALERTA warning if --force / --no-input" {
|
||||
run $ABRA app rm "$TEST_APP_DOMAIN" --force
|
||||
refute_output --partial 'ALERTA'
|
||||
|
||||
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
|
||||
refute_output --partial 'ALERTA'
|
||||
|
||||
_new_app
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "error if still deployed" {
|
||||
_deploy_app
|
||||
|
||||
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" {
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'test_password'
|
||||
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all --no-input
|
||||
assert_success
|
||||
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'test_password'
|
||||
assert_output --partial 'false'
|
||||
|
||||
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
|
||||
assert_success
|
||||
assert_output --partial 'no secrets to remove'
|
||||
|
||||
_new_app
|
||||
}
|
||||
|
||||
@test "remove secrets" {
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
||||
assert_failure
|
||||
assert_output --partial 'already exists'
|
||||
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'test_password'
|
||||
|
||||
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
|
||||
assert_success
|
||||
refute_output --partial 'no secrets to remove'
|
||||
|
||||
sanitisedDomainName="${TEST_APP_DOMAIN//./_}"
|
||||
assert_output --partial "$sanitisedDomainName_test_password_v1 removed"
|
||||
|
||||
_new_app
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "detect no volumes to remove" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app volume ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'test-volume'
|
||||
|
||||
_undeploy_app
|
||||
|
||||
# NOTE(d1): to let the stack come down before nuking volumes
|
||||
sleep 5
|
||||
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force
|
||||
assert_success
|
||||
|
||||
run $ABRA app volume ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
refute_output --partial 'test-volume'
|
||||
assert_output --partial 'no volumes created'
|
||||
|
||||
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
|
||||
assert_success
|
||||
assert_output --partial 'no volumes to remove'
|
||||
|
||||
_new_app
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "remove volumes" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app volume ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'test-volume'
|
||||
|
||||
_undeploy_app
|
||||
|
||||
# NOTE(d1): to let the stack come down before nuking volumes
|
||||
sleep 5
|
||||
|
||||
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
|
||||
assert_success
|
||||
assert_output --partial 'test-volume'
|
||||
assert_output --partial 'removed'
|
||||
|
||||
_new_app
|
||||
}
|
||||
|
||||
@test "remove .env file" {
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
|
||||
assert_success
|
||||
|
||||
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
_new_app
|
||||
}
|
53
tests/integration/app_restart.bats
Normal file
53
tests/integration/app_restart.bats
Normal file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app restart
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app restart DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
@test "error if service missing" {
|
||||
run $ABRA app restart "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'missing service'
|
||||
}
|
||||
|
||||
@test "error if not deployed" {
|
||||
run $ABRA app restart "$TEST_APP_DOMAIN" app
|
||||
assert_failure
|
||||
assert_output --partial 'is not deployed'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "app is restarted" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app restart "$TEST_APP_DOMAIN" app --debug
|
||||
assert_success
|
||||
assert_output --regexp 'attempting to scale .* to 0'
|
||||
assert_output --regexp 'attempting to scale .* to 1'
|
||||
assert_output --partial 'service successfully restarted'
|
||||
|
||||
_undeploy_app
|
||||
}
|
146
tests/integration/app_restore.bats
Normal file
146
tests/integration/app_restore.bats
Normal file
@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@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 "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"
|
||||
}
|
||||
|
||||
@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"
|
||||
}
|
||||
|
||||
# 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
|
||||
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 "$TEST_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
|
||||
}
|
232
tests/integration/app_rollback.bats
Normal file
232
tests/integration/app_rollback.bats
Normal file
@ -0,0 +1,232 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
# TODO(d1): test "no available downgrades" when this is implemented
|
||||
# https://git.coopcloud.tech/coop-cloud/organising/issues/204
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app rollback
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app rollback 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 rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||
assert_failure
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_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 --partial 'behind 3'
|
||||
|
||||
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||
assert_failure
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
||||
|
||||
@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 --partial 'behind 3'
|
||||
|
||||
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 --partial 'behind 3'
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
||||
|
||||
@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 rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||
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"
|
||||
}
|
||||
|
||||
# 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'
|
||||
|
||||
run $ABRA app rollback "$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 same commit if --chaos" {
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout main
|
||||
assert_success
|
||||
|
||||
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 --partial 'behind 3'
|
||||
|
||||
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'
|
||||
|
||||
run $ABRA app rollback "$TEST_APP_DOMAIN" \
|
||||
--chaos --no-input --no-converge-checks
|
||||
assert_success
|
||||
refute_output --partial "$latestCommit"
|
||||
assert_output --partial "$threeCommitsBack"
|
||||
assert_output --partial 'chaos'
|
||||
|
||||
_undeploy_app
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
||||
assert_success
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "no rollback if lint error" {
|
||||
_deploy_app
|
||||
|
||||
run sed -i '/traefik.enable=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
||||
assert_success
|
||||
|
||||
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --chaos
|
||||
assert_failure
|
||||
assert_output --partial 'failed lint checks'
|
||||
|
||||
_undeploy_app
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "error if not already deployed" {
|
||||
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --chaos
|
||||
assert_failure
|
||||
assert_output --partial 'not deployed'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "error if no published release and no --chaos" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input
|
||||
assert_failure
|
||||
assert_output --partial 'no published releases'
|
||||
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "rollback to previous version" {
|
||||
latestVersion=$(jq -r '.gitea.versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
|
||||
refute [ -z "$latestVersion" ];
|
||||
|
||||
rollbackVersion=$(jq -r '.gitea.versions[-2] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
|
||||
refute [ -z "$rollbackVersion" ];
|
||||
|
||||
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 rollback "gitea.$TEST_SERVER" --no-input --no-converge-checks
|
||||
assert_success
|
||||
assert_output --partial "$rollbackVersion"
|
||||
|
||||
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"
|
||||
}
|
60
tests/integration/app_run.bats
Normal file
60
tests/integration/app_run.bats
Normal file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app run
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app run DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
@test "error if missing service" {
|
||||
run $ABRA app run "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'no <service> provided'
|
||||
|
||||
run $ABRA app run "$TEST_APP_DOMAIN" app
|
||||
assert_failure
|
||||
assert_output --partial 'no <args> provided'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "error if service doesn't exist" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app run "$TEST_APP_DOMAIN" DOESNTEXIST ls
|
||||
assert_failure
|
||||
assert_output --partial 'no containers matching'
|
||||
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "run command" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app run "$TEST_APP_DOMAIN" app ls /
|
||||
assert_success
|
||||
assert_output --partial 'root'
|
||||
|
||||
_undeploy_app
|
||||
}
|
216
tests/integration/app_secret.bats
Normal file
216
tests/integration/app_secret.bats
Normal file
@ -0,0 +1,216 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "generate: validate arguments" {
|
||||
run $ABRA app secret generate
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app secret generate DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'missing arguments'
|
||||
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN" testSecret testVersion --all
|
||||
assert_failure
|
||||
assert_output --partial 'cannot use'
|
||||
assert_output --partial "'--all' together"
|
||||
}
|
||||
|
||||
@test "generate: single secret no match" {
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN" DOESNTEXIST v1
|
||||
assert_failure
|
||||
assert_output --partial "doesn't exist in the env config"
|
||||
}
|
||||
|
||||
@test "generate: 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 --partial 'behind 3'
|
||||
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
refute_output --partial 'behind 3'
|
||||
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "generate: 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 --partial 'behind 3'
|
||||
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all --offline
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
||||
|
||||
@test "generate: create secrets" {
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'false'
|
||||
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'true'
|
||||
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "insert: validate arguments" {
|
||||
run $ABRA app secret insert
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app secret insert "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'missing arguments'
|
||||
|
||||
run $ABRA app secret insert "$TEST_APP_DOMAIN" bar
|
||||
assert_failure
|
||||
assert_output --partial 'missing arguments'
|
||||
|
||||
run $ABRA app secret insert "$TEST_APP_DOMAIN" bar baz
|
||||
assert_failure
|
||||
assert_output --partial 'missing arguments'
|
||||
}
|
||||
|
||||
@test "insert: create secret" {
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'false'
|
||||
|
||||
run $ABRA app secret insert "$TEST_APP_DOMAIN" test_password v1 foo
|
||||
assert_success
|
||||
assert_output --partial 'successfully stored on server'
|
||||
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'true'
|
||||
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" test_password
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "rm: validate arguments" {
|
||||
run $ABRA app secret rm
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app secret rm DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'no secret(s) specified'
|
||||
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" test_password --all
|
||||
assert_failure
|
||||
assert_output --partial 'cannot use'
|
||||
assert_output --partial "'--all' together"
|
||||
}
|
||||
|
||||
@test "rm: single secret no match" {
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" foo_password
|
||||
assert_failure
|
||||
assert_output --partial "doesn't exist on server"
|
||||
}
|
||||
|
||||
@test "rm: no secret match" {
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
||||
assert_failure
|
||||
assert_output --partial 'no secrets to remove'
|
||||
}
|
||||
|
||||
@test "rm: remove secret" {
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'true'
|
||||
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'false'
|
||||
}
|
||||
|
||||
@test "ls: validate arguments" {
|
||||
run $ABRA app secret ls
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app secret ls DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
@test "ls: show secrets" {
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'false'
|
||||
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
|
||||
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'true'
|
||||
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
}
|
48
tests/integration/app_services.bats
Normal file
48
tests/integration/app_services.bats
Normal file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app services
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app services DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
@test "error if not deployed" {
|
||||
run $ABRA app services "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'is not deployed'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "list services" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app services "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
|
||||
sanitisedDomainName="${TEST_APP_DOMAIN//./_}"
|
||||
assert_output --partial "$sanitisedDomainName_app"
|
||||
assert_output --partial "nginx"
|
||||
|
||||
_undeploy_app
|
||||
}
|
48
tests/integration/app_undeploy.bats
Normal file
48
tests/integration/app_undeploy.bats
Normal file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app undeploy
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app undeploy DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
@test "error if not deployed" {
|
||||
run $ABRA app undeploy "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'is not deployed'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "undeploy app" {
|
||||
_deploy_app
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "undeploy and prune" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app undeploy "$TEST_APP_DOMAIN" --no-input --prune
|
||||
assert_success
|
||||
}
|
27
tests/integration/app_upgrade.bats
Normal file
27
tests/integration/app_upgrade.bats
Normal file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app upgrade
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app upgrade DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
98
tests/integration/app_version.bats
Normal file
98
tests/integration/app_version.bats
Normal file
@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate app argument" {
|
||||
run $ABRA app version
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app version DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
@test "error if not deployed" {
|
||||
run $ABRA app version "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'is not deployed'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "error if version unknown" {
|
||||
run sed -i '/coop-cloud.${STACK_NAME}.version=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
||||
assert_success
|
||||
|
||||
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
||||
--no-input --no-converge-checks --chaos
|
||||
assert_success
|
||||
|
||||
run $ABRA app version "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'failed to determine'
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "error if no version in catalogue" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app version "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'could not retrieve deployed version'
|
||||
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
@test "list version" {
|
||||
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
|
||||
|
||||
run $ABRA app deploy "gitea.$TEST_SERVER" \
|
||||
--no-input --no-converge-checks
|
||||
assert_success
|
||||
|
||||
run $ABRA app version "gitea.$TEST_SERVER"
|
||||
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"
|
||||
}
|
98
tests/integration/app_volume.bats
Normal file
98
tests/integration/app_volume.bats
Normal file
@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "ls validate app argument" {
|
||||
run $ABRA app volume ls
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app volume ls DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
@test "list no volumes" {
|
||||
run $ABRA app volume ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'no volumes created'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "list volumes" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app volume ls "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_output --partial 'test-volume'
|
||||
|
||||
_undeploy_app
|
||||
}
|
||||
|
||||
@test "rm validate app argument" {
|
||||
run $ABRA app volume rm
|
||||
assert_failure
|
||||
assert_output --partial 'no app provided'
|
||||
|
||||
run $ABRA app volume rm DOESNTEXIST
|
||||
assert_failure
|
||||
assert_output --partial 'cannot find app'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "rm error if deployed" {
|
||||
_deploy_app
|
||||
|
||||
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
|
||||
|
||||
_undeploy_app
|
||||
|
||||
# NOTE(d1): to let the stack come down before nuking volumes
|
||||
sleep 5
|
||||
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force
|
||||
assert_success
|
||||
assert_output --partial 'volumes removed successfully'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "remove no volumes" {
|
||||
_deploy_app
|
||||
|
||||
_undeploy_app
|
||||
|
||||
# NOTE(d1): to let the stack come down before nuking volumes
|
||||
sleep 5
|
||||
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force
|
||||
assert_success
|
||||
assert_output --partial 'volumes removed successfully'
|
||||
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force
|
||||
assert_success
|
||||
assert_output --partial 'no volumes removed'
|
||||
}
|
@ -1,35 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
||||
source "$DIR/helpers.sh"
|
||||
_setup_env
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "bash autocompletion" {
|
||||
run $ABRA autocomplete bash
|
||||
assert_success
|
||||
assert [ -f "$ABRA_DIR/autocompletion/bash" ]
|
||||
assert_exists "$ABRA_DIR/autocompletion/bash"
|
||||
}
|
||||
|
||||
@test "zsh autocompletion" {
|
||||
run $ABRA autocomplete zsh
|
||||
assert_success
|
||||
assert [ -f "$ABRA_DIR/autocompletion/zsh" ]
|
||||
assert_exists "$ABRA_DIR/autocompletion/zsh"
|
||||
}
|
||||
|
||||
@test "fish autocompletion" {
|
||||
run $ABRA autocomplete fish
|
||||
assert_success
|
||||
assert [ -f "$ABRA_DIR/autocompletion/fish" ]
|
||||
assert_exists "$ABRA_DIR/autocompletion/fish"
|
||||
}
|
||||
|
||||
@test "fizsh autocompletion" {
|
||||
run $ABRA autocomplete fizsh
|
||||
assert_success
|
||||
assert [ -f "$ABRA_DIR/autocompletion/zsh" ]
|
||||
}
|
||||
|
||||
teardown(){
|
||||
_default_teardown
|
||||
assert_exists "$ABRA_DIR/autocompletion/zsh"
|
||||
}
|
||||
|
@ -1,21 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
||||
source "$DIR/helpers.sh"
|
||||
_setup_env
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "catalogue generate" {
|
||||
# bats test_tags=slow
|
||||
@test "generate entire catalogue" {
|
||||
run $ABRA catalogue generate
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "catalogue generate specific recipe" {
|
||||
# bats test_tags=slow
|
||||
@test "generate only specific recipe" {
|
||||
run $ABRA catalogue generate gitea
|
||||
assert_success
|
||||
}
|
||||
|
||||
teardown(){
|
||||
_default_teardown
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
||||
source "$DIR/helpers.sh"
|
||||
_setup_env
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
|
||||
if [[ -d "$ABRA_DIR" ]]; then
|
||||
rm -rf "$ABRA_DIR"
|
||||
fi
|
||||
}
|
||||
|
||||
@test "ABRA_DIR can be overriden" {
|
||||
@test "ABRA_DIR is overriden" {
|
||||
ABRA_DIR="$HOME/.abra_foo"
|
||||
|
||||
run $ABRA app ls
|
||||
@ -15,22 +18,25 @@ setup() {
|
||||
# checks if it should create these base directories and that is what we want
|
||||
assert_failure
|
||||
|
||||
assert [ -d "$HOME/.abra_foo" ]
|
||||
assert_exists "$HOME/.abra_foo"
|
||||
|
||||
run rm -rf "$ABRA_DIR"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "abra directories created" {
|
||||
@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
|
||||
assert_failure
|
||||
|
||||
assert [ -d "$ABRA_DIR" ]
|
||||
assert [ -d "$ABRA_DIR/servers" ]
|
||||
assert [ -d "$ABRA_DIR/recipes" ]
|
||||
assert [ -d "$ABRA_DIR/backups" ]
|
||||
assert [ -d "$ABRA_DIR/vendor" ]
|
||||
assert [ -d "$ABRA_DIR/catalogue" ]
|
||||
assert_exists "$ABRA_DIR"
|
||||
assert_exists "$ABRA_DIR/servers"
|
||||
assert_exists "$ABRA_DIR/recipes"
|
||||
assert_exists "$ABRA_DIR/backups"
|
||||
assert_exists "$ABRA_DIR/vendor"
|
||||
assert_exists "$ABRA_DIR/catalogue"
|
||||
}
|
||||
|
||||
@test "catalogue recipe is a git repository" {
|
||||
@ -42,10 +48,6 @@ setup() {
|
||||
|
||||
assert_output --partial 'local recipe catalogue is missing'
|
||||
|
||||
assert [ -d "$ABRA_DIR/catalogue" ]
|
||||
assert [ -d "$ABRA_DIR/catalogue/.git" ]
|
||||
}
|
||||
|
||||
teardown(){
|
||||
_default_teardown
|
||||
assert_exists "$ABRA_DIR/catalogue"
|
||||
assert_exists "$ABRA_DIR/catalogue/.git"
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_build_abra() {
|
||||
if [[ ! -e "$ROOT/abra" ]]; then
|
||||
cd "$ROOT" && make build-abra
|
||||
return 0
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
_build_kadabra() {
|
||||
if [[ ! -e "$ROOT/kadabra" ]]; then
|
||||
cd "$ROOT" && make build-kadabra
|
||||
return 0
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
_setup_env(){
|
||||
load '/usr/lib/bats/bats-support/load'
|
||||
load '/usr/lib/bats/bats-assert/load'
|
||||
|
||||
ROOT="$DIR/../.."
|
||||
ABRA="$ROOT/abra"
|
||||
KADABRA="$ROOT/kadabra"
|
||||
|
||||
ABRA_DIR="$HOME/.abra_test"
|
||||
|
||||
_build_abra
|
||||
_build_kadabra
|
||||
}
|
||||
|
||||
_default_teardown(){
|
||||
rm -rf "$ABRA_DIR"
|
||||
}
|
42
tests/integration/helpers/app.bash
Normal file
42
tests/integration/helpers/app.bash
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_new_app() {
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$TEST_APP_DOMAIN" \
|
||||
--secrets
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
}
|
||||
|
||||
_deploy_app() {
|
||||
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input
|
||||
assert_success
|
||||
|
||||
run $ABRA app ls --server "$TEST_SERVER" --status
|
||||
assert_success
|
||||
assert_output --partial "$TEST_APP_DOMAIN"
|
||||
assert_output --partial 'deployed'
|
||||
}
|
||||
|
||||
_undeploy_app() {
|
||||
run $ABRA app undeploy "$TEST_APP_DOMAIN" --no-input
|
||||
assert_success
|
||||
|
||||
run $ABRA app ls --server "$TEST_SERVER" --status
|
||||
assert_success
|
||||
assert_output --partial "$TEST_APP_DOMAIN"
|
||||
assert_output --partial 'unknown'
|
||||
}
|
||||
|
||||
_rm_app() {
|
||||
# NOTE(d1): not asserting outcomes on teardown here since some might fail
|
||||
# depending on what the test created. all commands run through anyway
|
||||
if [[ -f "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" ]]; then
|
||||
run $ABRA app undeploy "$TEST_APP_DOMAIN" --no-input
|
||||
run $ABRA app secret remove "$TEST_APP_DOMAIN" --all --no-input
|
||||
run $ABRA app volume remove "$TEST_APP_DOMAIN" --no-input
|
||||
run $ABRA app remove "$TEST_APP_DOMAIN" --no-input
|
||||
fi
|
||||
}
|
19
tests/integration/helpers/common.bash
Normal file
19
tests/integration/helpers/common.bash
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_common_setup() {
|
||||
load '/usr/lib/bats/bats-support/load'
|
||||
load '/usr/lib/bats/bats-assert/load'
|
||||
load '/usr/lib/bats/bats-file/load'
|
||||
|
||||
load "$PWD/tests/integration/helpers/app"
|
||||
load "$PWD/tests/integration/helpers/git"
|
||||
load "$PWD/tests/integration/helpers/recipe"
|
||||
load "$PWD/tests/integration/helpers/server"
|
||||
|
||||
export ABRA="$PWD/abra"
|
||||
export KADABRA="$PWD/kadabra"
|
||||
|
||||
export TEST_APP_NAME="$(basename "${BATS_TEST_FILENAME//./_}")"
|
||||
export TEST_APP_DOMAIN="$TEST_APP_NAME.$TEST_SERVER"
|
||||
export TEST_RECIPE="abra-integration-test-recipe"
|
||||
}
|
11
tests/integration/helpers/git.bash
Normal file
11
tests/integration/helpers/git.bash
Normal file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_checkout_recipe() {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo 'forgot to pass argument to function?'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$1" checkout .
|
||||
assert_success
|
||||
}
|
16
tests/integration/helpers/recipe.bash
Normal file
16
tests/integration/helpers/recipe.bash
Normal file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_fetch_recipe() {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo 'forgot to pass argument to function?'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$ABRA_DIR/recipes/$1" ]]; then
|
||||
run mkdir -p "$ABRA_DIR/recipes"
|
||||
assert_success
|
||||
|
||||
run git clone "https://git.coopcloud.tech/coop-cloud/$1" "$ABRA_DIR/recipes/$1"
|
||||
assert_success
|
||||
fi
|
||||
}
|
19
tests/integration/helpers/server.bash
Normal file
19
tests/integration/helpers/server.bash
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_add_server() {
|
||||
run $ABRA server add "$TEST_SERVER"
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER"
|
||||
}
|
||||
|
||||
_rm_server() {
|
||||
run $ABRA server remove --no-input "$TEST_SERVER"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER"
|
||||
}
|
||||
|
||||
_rm_default_server(){
|
||||
run rm -rf "$ABRA_DIR/servers/default"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/servers/default"
|
||||
}
|
@ -1,38 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
||||
source "$DIR/helpers.sh"
|
||||
_setup_env
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
|
||||
if [[ -f "$HOME/.local/bin/abra" ]]; then
|
||||
mv "$HOME/.local/bin/abra" "$HOME/.local/bin/abra_before_test"
|
||||
fi
|
||||
}
|
||||
|
||||
@test "install from script" {
|
||||
run bash -c 'curl https://install.abra.coopcloud.tech | bash'
|
||||
assert_success
|
||||
|
||||
assert [ -f "$HOME/.local/bin/abra" ]
|
||||
run $HOME/.local/bin/abra -v
|
||||
assert_output --partial 'beta'
|
||||
}
|
||||
|
||||
@test "install release candidate from script" {
|
||||
run bash -c 'curl https://install.abra.coopcloud.tech | bash -s -- --rc'
|
||||
assert_success
|
||||
|
||||
assert [ -f "$HOME/.local/bin/abra" ]
|
||||
run $HOME/.local/bin/abra -v
|
||||
assert_output --partial '-rc'
|
||||
}
|
||||
|
||||
teardown(){
|
||||
_default_teardown
|
||||
|
||||
if [[ -f "$HOME/.local/bin/abra_before_test" ]]; then
|
||||
rm -rf "$HOME/.local/bin/abra"
|
||||
mv "$HOME/.local/bin/abra_before_test" "$HOME/.local/bin/abra"
|
||||
fi
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "install from script" {
|
||||
run bash -c 'curl https://install.abra.coopcloud.tech | bash'
|
||||
assert_success
|
||||
|
||||
assert_exists "$HOME/.local/bin/abra"
|
||||
run "$HOME/.local/bin/abra" -v
|
||||
assert_output --partial 'beta'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "install release candidate from script" {
|
||||
run bash -c 'curl https://install.abra.coopcloud.tech | bash -s -- --rc'
|
||||
assert_success
|
||||
|
||||
assert_exists "$HOME/.local/bin/abra"
|
||||
run "$HOME/.local/bin/abra" -v
|
||||
assert_output --partial '-rc'
|
||||
}
|
||||
|
@ -1,87 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
||||
source "$DIR/helpers.sh"
|
||||
_setup_env
|
||||
|
||||
mkdir -p "$HOME/.abra_test/servers/example.com"
|
||||
if ! grep -R -q "example.com" "$HOME/.docker"; then
|
||||
docker context create --docker host=ssh://foo@example.com:222 example.com
|
||||
fi
|
||||
}
|
||||
|
||||
@test "create new recipe" {
|
||||
run $ABRA recipe new foobar
|
||||
assert_success
|
||||
assert_output --partial 'Your new foobar recipe has been created'
|
||||
|
||||
run $ABRA app new foobar \
|
||||
--no-input \
|
||||
--server example.com \
|
||||
--domain foobar.example.com
|
||||
assert_success
|
||||
assert_output --partial 'A new foobar app has been created!'
|
||||
}
|
||||
|
||||
@test "recipe fetch" {
|
||||
run $ABRA recipe fetch matrix-synapse
|
||||
assert_success
|
||||
assert [ -d "$ABRA_DIR/recipes/matrix-synapse" ]
|
||||
}
|
||||
|
||||
@test "recipe sync allows unstaged changes" {
|
||||
run $ABRA recipe fetch matrix-synapse
|
||||
assert_success
|
||||
|
||||
run echo "unstaged changes" >> "$ABRA_DIR/recipes/matrix-synapse/foo"
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe sync matrix-synapse --patch
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "recipe sync detects unstaged label changes" {
|
||||
run $ABRA recipe fetch matrix-synapse
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe sync matrix-synapse --patch
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe sync matrix-synapse --patch
|
||||
assert_success
|
||||
assert_output --partial 'is already set, nothing to do?'
|
||||
}
|
||||
|
||||
@test "recipe list" {
|
||||
run $ABRA recipe list
|
||||
assert_success
|
||||
NUM_RECIPES=$(jq length "$ABRA_DIR/catalogue/recipes.json")
|
||||
assert_output --partial "total recipes: $NUM_RECIPES"
|
||||
}
|
||||
|
||||
@test "recipe list with pattern" {
|
||||
run $ABRA recipe list --pattern cloud
|
||||
assert_success
|
||||
assert_output --partial 'nextcloud'
|
||||
refute_output --partial 'matrix-synapse'
|
||||
}
|
||||
|
||||
@test "recipe lint" {
|
||||
run $ABRA recipe lint gitea
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "recipe versions" {
|
||||
run $ABRA recipe versions gitea
|
||||
assert_success
|
||||
assert_output --partial '2.3.2+1.20.3-rootless'
|
||||
}
|
||||
|
||||
teardown() {
|
||||
_default_teardown
|
||||
|
||||
if grep -R -q "example.com" "$HOME/.docker"; then
|
||||
docker context rm example.com
|
||||
fi
|
||||
}
|
16
tests/integration/recipe_fetch.bats
Normal file
16
tests/integration/recipe_fetch.bats
Normal file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "recipe fetch" {
|
||||
run rm -rf "$ABRA_DIR/recipes/matrix-synapse"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/recipes/matrix-synapse"
|
||||
|
||||
run $ABRA recipe fetch matrix-synapse
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/recipes/matrix-synapse"
|
||||
}
|
50
tests/integration/recipe_lint.bats
Normal file
50
tests/integration/recipe_lint.bats
Normal file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "recipe lint" {
|
||||
run $ABRA recipe lint gitea
|
||||
assert_success
|
||||
assert_output --partial 'compose config has expected version'
|
||||
}
|
||||
|
||||
@test "recipe lint warns on error" {
|
||||
run $ABRA recipe lint "$TEST_RECIPE"
|
||||
assert_success
|
||||
refute_output --partial 'watch out, some critical errors are present'
|
||||
|
||||
run sed -i '/traefik.enable=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe lint "$TEST_RECIPE"
|
||||
assert_success --partial 'watch out, some critical errors are present'
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "recipe lint uses latest commit" {
|
||||
_fetch_recipe "$TEST_RECIPE"
|
||||
|
||||
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 --partial 'behind 3'
|
||||
|
||||
run $ABRA recipe lint "$TEST_RECIPE"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
20
tests/integration/recipe_list.bats
Normal file
20
tests/integration/recipe_list.bats
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "recipe list" {
|
||||
run $ABRA recipe list
|
||||
assert_success
|
||||
NUM_RECIPES=$(jq length "$ABRA_DIR/catalogue/recipes.json")
|
||||
assert_output --partial "total recipes: $NUM_RECIPES"
|
||||
}
|
||||
|
||||
@test "recipe list with pattern" {
|
||||
run $ABRA recipe list --pattern cloud
|
||||
assert_success
|
||||
assert_output --partial 'nextcloud'
|
||||
refute_output --partial 'matrix-synapse'
|
||||
}
|
42
tests/integration/recipe_new.bats
Normal file
42
tests/integration/recipe_new.bats
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
teardown(){
|
||||
if [[ -d "$ABRA_DIR/recipes/foobar" ]]; then
|
||||
run rm -rf "$ABRA_DIR/recipes/foobar"
|
||||
assert_success
|
||||
fi
|
||||
}
|
||||
|
||||
@test "create new recipe" {
|
||||
run $ABRA recipe new foobar
|
||||
assert_success
|
||||
assert_output --partial 'Your new foobar recipe has been created'
|
||||
assert_exists "$ABRA_DIR/recipes/foobar"
|
||||
}
|
||||
|
||||
@test "create new app from new recipe" {
|
||||
run $ABRA recipe new foobar
|
||||
assert_success
|
||||
|
||||
run $ABRA app new foobar \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "foobar.$TEST_SERVER"
|
||||
assert_success
|
||||
assert_output --partial 'A new foobar app has been created!'
|
||||
}
|
22
tests/integration/recipe_release.bats
Normal file
22
tests/integration/recipe_release.bats
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "pull in latest changes" {
|
||||
run $ABRA recipe fetch matrix-synapse
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/matrix-synapse" reset --hard HEAD~3
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe release matrix-synapse --no-input
|
||||
assert_failure
|
||||
assert_output --regexp 'latest git tag .* are the same'
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/matrix-synapse" status
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
39
tests/integration/recipe_sync.bats
Normal file
39
tests/integration/recipe_sync.bats
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "allow unstaged changes" {
|
||||
run $ABRA recipe fetch matrix-synapse
|
||||
assert_success
|
||||
|
||||
run echo "unstaged changes" >> "$ABRA_DIR/recipes/matrix-synapse/foo"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/matrix-synapse" status
|
||||
assert_success
|
||||
assert_output --partial 'foo'
|
||||
|
||||
run $ABRA recipe sync matrix-synapse --patch
|
||||
assert_success
|
||||
|
||||
run rm -rf "$ABRA_DIR/recipes/matrix-synapse/foo"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/recipes/matrix-synapse/foo"
|
||||
}
|
||||
|
||||
@test "detect unstaged label changes" {
|
||||
run $ABRA recipe fetch matrix-synapse
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe sync matrix-synapse --patch
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe sync matrix-synapse --patch
|
||||
assert_success
|
||||
assert_output --partial 'is already set, nothing to do?'
|
||||
}
|
||||
|
||||
# TODO(d1): implement
|
8
tests/integration/recipe_upgrade.bats
Normal file
8
tests/integration/recipe_upgrade.bats
Normal file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
# TODO(d1): implement
|
12
tests/integration/recipe_version.bats
Normal file
12
tests/integration/recipe_version.bats
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "recipe versions" {
|
||||
run $ABRA recipe versions gitea
|
||||
assert_success
|
||||
assert_output --partial '2.3.2+1.20.3-rootless'
|
||||
}
|
53
tests/integration/server_add.bats
Normal file
53
tests/integration/server_add.bats
Normal file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "add new server" {
|
||||
run $ABRA server add "$TEST_SERVER"
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER"
|
||||
|
||||
run $ABRA server ls
|
||||
assert_output --partial "$TEST_SERVER"
|
||||
|
||||
assert bash -c "docker context ls | grep -q $TEST_SERVER"
|
||||
}
|
||||
|
||||
@test "error if using domain and --local together" {
|
||||
run $ABRA server add "$TEST_SERVER" --local
|
||||
assert_failure
|
||||
assert_output --partial 'cannot use <domain> and --local together'
|
||||
}
|
||||
|
||||
@test "create local server" {
|
||||
run docker swarm init
|
||||
assert_success
|
||||
|
||||
run $ABRA server add --local
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/default"
|
||||
assert bash -c "docker context ls | grep -q default"
|
||||
assert_output --partial 'local server added'
|
||||
|
||||
docker swarm leave --force
|
||||
assert_success
|
||||
|
||||
_rm_default_server
|
||||
}
|
||||
|
||||
@test "create local server fails when no docker swarm" {
|
||||
run $ABRA server add --local
|
||||
assert_failure
|
||||
assert_not_exists "$ABRA_DIR/servers/default"
|
||||
assert_output --partial 'swarm mode not enabled on local server'
|
||||
}
|
||||
|
||||
@test "cleanup when cannot add server" {
|
||||
run $ABRA server add example.com
|
||||
assert_failure
|
||||
assert_not_exists "$ABRA_DIR/servers/example.com"
|
||||
refute bash -c "docker context ls | grep -q example.com"
|
||||
}
|
75
tests/integration/server_list.bats
Normal file
75
tests/integration/server_list.bats
Normal file
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "list server" {
|
||||
run "$ABRA" server ls
|
||||
assert_success
|
||||
assert_output --partial "$TEST_SERVER"
|
||||
}
|
||||
|
||||
@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"
|
||||
|
||||
run "$ABRA" server ls
|
||||
assert_success
|
||||
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" {
|
||||
run "$ABRA" server ls --problems
|
||||
assert_success
|
||||
assert_output --partial 'all servers wired up correctly'
|
||||
|
||||
run docker context create --docker host=ssh://incorrect nowhere.com
|
||||
assert_success
|
||||
|
||||
run mkdir -p "$ABRA_DIR/servers/nowhere.com"
|
||||
assert_success
|
||||
|
||||
run "$ABRA" server ls --problems
|
||||
assert_success
|
||||
assert_output --partial 'unknown'
|
||||
|
||||
run rm -rf "$ABRA_DIR/servers/nowhere.com"
|
||||
assert_success
|
||||
|
||||
run docker context rm nowhere.com
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "machine readable output" {
|
||||
run "$ABRA" server ls --machine
|
||||
assert_success
|
||||
|
||||
expectedOutput='[{"name":"'
|
||||
expectedOutput+="$TEST_SERVER"
|
||||
expectedOutput+='"'
|
||||
|
||||
assert_output --partial "$expectedOutput"
|
||||
}
|
46
tests/integration/server_prune.bats
Normal file
46
tests/integration/server_prune.bats
Normal file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate server" {
|
||||
run $ABRA server prune --no-input
|
||||
assert_failure
|
||||
assert_output --partial 'no server provided'
|
||||
|
||||
run $ABRA server prune foo
|
||||
assert_failure
|
||||
assert_output --partial "server doesn't exist"
|
||||
}
|
||||
|
||||
@test "prune containers, networks and images" {
|
||||
run $ABRA server prune "$TEST_SERVER"
|
||||
assert_success
|
||||
assert_output --partial 'containers pruned'
|
||||
assert_output --partial 'networks pruned'
|
||||
assert_output --partial 'images pruned'
|
||||
}
|
||||
|
||||
@test "prune all images" {
|
||||
run $ABRA server prune "$TEST_SERVER" --all --debug
|
||||
assert_success
|
||||
assert_output --partial 'removing all images, not only dangling ones'
|
||||
}
|
||||
|
||||
@test "prune volumes" {
|
||||
run $ABRA server prune "$TEST_SERVER" --volumes
|
||||
assert_success
|
||||
assert_output --partial 'volumes pruned'
|
||||
}
|
36
tests/integration/server_remove.bats
Normal file
36
tests/integration/server_remove.bats
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
}
|
||||
|
||||
teardown_file(){
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "validate server" {
|
||||
run $ABRA server remove --no-input
|
||||
assert_failure
|
||||
assert_output --partial 'no server provided'
|
||||
|
||||
run $ABRA server remove foo
|
||||
assert_failure
|
||||
assert_output --partial "server doesn't exist"
|
||||
}
|
||||
|
||||
@test "remove server" {
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER"
|
||||
assert bash -c "docker context ls | grep -q $TEST_SERVER"
|
||||
|
||||
run $ABRA server remove --no-input "$TEST_SERVER"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER"
|
||||
refute bash -c "docker context ls | grep -q $TEST_SERVER"
|
||||
}
|
42
tests/integration/setup_suite.bash
Normal file
42
tests/integration/setup_suite.bash
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_suite(){
|
||||
if [[ -z "${TEST_SERVER}" ]]; then
|
||||
echo 'set $TEST_SERVER before running the test suite' >&3
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "${ABRA_DIR}" ]]; then
|
||||
echo 'set $ABRA_DIR before running the test suite' >&3
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$PWD/abra" ]]; then
|
||||
make build-abra
|
||||
fi
|
||||
|
||||
if [[ ! -f "$PWD/kadabra" ]]; then
|
||||
make build-kadabra
|
||||
fi
|
||||
|
||||
if [[ -d "$ABRA_DIR" ]]; then
|
||||
rm -rf "$ABRA_DIR"
|
||||
fi
|
||||
|
||||
# NOTE(d1): hack to copy over a local copy of the catalogue from the typical
|
||||
# $HOME/.abra directory if it exists. This avoids a costly git clone over the
|
||||
# network for every test invocation
|
||||
if [[ ! -d "$ABRA_DIR/catalogue" ]]; then
|
||||
if [[ -d "$HOME/.abra/catalogue" ]]; then
|
||||
mkdir -p "$ABRA_DIR"
|
||||
cp -r "$HOME/.abra/catalogue" "$ABRA_DIR"
|
||||
git -C "$ABRA_DIR/catalogue" checkout .
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
teardown_suite(){
|
||||
if [[ -d "$ABRA_DIR" ]]; then
|
||||
rm -rf "$ABRA_DIR"
|
||||
fi
|
||||
}
|
@ -1,40 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
||||
source "$DIR/helpers.sh"
|
||||
_setup_env
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
|
||||
if [[ -f "$HOME/.local/bin/abra" ]]; then
|
||||
mv "$HOME/.local/bin/abra" "$HOME/.local/bin/abra_before_test"
|
||||
fi
|
||||
}
|
||||
|
||||
@test "abra upgrade" {
|
||||
run $ABRA upgrade
|
||||
assert_success
|
||||
assert_output --partial 'Public interest infrastructure'
|
||||
|
||||
assert [ -f "$HOME/.local/bin/abra" ]
|
||||
run $HOME/.local/bin/abra -v
|
||||
assert_output --partial 'beta'
|
||||
}
|
||||
|
||||
@test "abra upgrade release candidate" {
|
||||
run $ABRA upgrade --rc
|
||||
assert_success
|
||||
assert_output --partial 'Public interest infrastructure'
|
||||
|
||||
assert [ -f "$HOME/.local/bin/abra" ]
|
||||
run $HOME/.local/bin/abra -v
|
||||
assert_output --partial '-rc'
|
||||
}
|
||||
|
||||
teardown(){
|
||||
_default_teardown
|
||||
|
||||
if [[ -f "$HOME/.local/bin/abra_before_test" ]]; then
|
||||
rm -rf "$HOME/.local/bin/abra"
|
||||
mv "$HOME/.local/bin/abra_before_test" "$HOME/.local/bin/abra"
|
||||
fi
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "abra upgrade" {
|
||||
run $ABRA upgrade
|
||||
assert_success
|
||||
assert_output --partial 'Public interest infrastructure'
|
||||
|
||||
assert_exists "$HOME/.local/bin/abra"
|
||||
run "$HOME/.local/bin/abra" -v
|
||||
assert_output --partial 'beta'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "abra upgrade release candidate" {
|
||||
run $ABRA upgrade --rc
|
||||
assert_success
|
||||
assert_output --partial 'Public interest infrastructure'
|
||||
|
||||
assert_exists "$HOME/.local/bin/abra"
|
||||
run "$HOME/.local/bin/abra" -v
|
||||
assert_output --partial '-rc'
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
||||
source "$DIR/helpers.sh"
|
||||
_setup_env
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "abra version" {
|
||||
@ -11,7 +10,3 @@ setup() {
|
||||
assert_success
|
||||
assert_output --partial 'dev'
|
||||
}
|
||||
|
||||
teardown(){
|
||||
_default_teardown
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
GANDI_TOKEN=...
|
||||
HCLOUD_TOKEN=...
|
||||
REGISTRY_PASSWORD=...
|
||||
REGISTRY_USERNAME=...
|
1
tests/manual/.gitignore
vendored
1
tests/manual/.gitignore
vendored
@ -1 +0,0 @@
|
||||
logs
|
@ -1,28 +0,0 @@
|
||||
# integration tests
|
||||
|
||||
> You need to be a member of Autonomic Co-op to run these tests, sorry!
|
||||
|
||||
`testfunctions.sh` contains the functions necessary to save and manipulate
|
||||
logs. Run `test_all.sh logdir` to run tests specified in that file and save the
|
||||
logs to `logdir`.
|
||||
|
||||
When creating new tests, make sure the test command is a one-liner (you can use
|
||||
`;` to separate commands). Include `testfunctions.sh` and then write your tests
|
||||
like this:
|
||||
|
||||
```
|
||||
run_test '$ABRA other stuff here'
|
||||
```
|
||||
|
||||
By default, the testing script will ask after every command if the execution
|
||||
succeeded. If you reply `n`, it will log the test in the `logdir`. If you want
|
||||
all tests to run without questions, run `export logall=yes` before executing
|
||||
the test script.
|
||||
|
||||
To run tests, you'll need to prepare your environment:
|
||||
|
||||
```
|
||||
cp .envrc.sample .envrc # fill out values...
|
||||
direnv allow
|
||||
./test_all.sh logs
|
||||
```
|
@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./testfunctions.sh
|
||||
source ./common.sh
|
||||
|
||||
run_test '$ABRA app ls'
|
||||
|
||||
run_test '$ABRA app ls --status'
|
||||
|
||||
run_test '$ABRA app ls --type wordpress'
|
||||
|
||||
run_test '$ABRA app ls --type wordpress --server swarm.autonomic.zone'
|
||||
|
||||
run_test '$ABRA app ls --type wordpress --server swarm.autonomic.zone --status'
|
@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./testfunctions.sh
|
||||
source ./common.sh
|
||||
|
||||
create_server_app_recipe
|
||||
|
||||
run_test '$ABRA app cmd foo.com test --local'
|
||||
|
||||
run_test '$ABRA app cmd foo.com test --local -- foo'
|
||||
|
||||
run_test '$ABRA app cmd foo.com test --local -- foo bar baz'
|
||||
|
||||
clean_server_app_recipe
|
@ -1,25 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
create_server_app_recipe() {
|
||||
ln -srf ../resources/testapp ~/.abra/servers/foo.com
|
||||
ln -srf ../resources/testrecipe ~/.abra/recipes
|
||||
}
|
||||
|
||||
clean_server_app_recipe() {
|
||||
unlink ~/.abra/servers/foo.com
|
||||
unlink ~/.abra/recipes/testrecipe
|
||||
}
|
||||
|
||||
function init() {
|
||||
ABRA="$(pwd)/../../abra"
|
||||
INSTALLER_URL="https://git.coopcloud.tech/coop-cloud/abra/raw/branch/main/scripts/installer/installer"
|
||||
|
||||
export PATH=$PATH:$HOME/.local/bin
|
||||
|
||||
echo "choosing $ABRA as abra command"
|
||||
echo "choosing $INSTALLER_URL as abra installer url"
|
||||
}
|
||||
|
||||
init "$@"
|
@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./testfunctions.sh
|
||||
source ./common.sh
|
||||
|
||||
run_test "$ABRA record new \
|
||||
--provider gandi \
|
||||
--record-type A \
|
||||
--record-name integration-tests \
|
||||
--record-value 192.157.2.21 \
|
||||
--no-input coopcloud.tech \
|
||||
"
|
||||
|
||||
run_test '$ABRA record list --provider gandi coopcloud.tech'
|
||||
|
||||
run_test "$ABRA record rm \
|
||||
--provider gandi \
|
||||
--record-type A \
|
||||
--record-name integration-tests \
|
||||
--no-input coopcloud.tech
|
||||
"
|
@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./testfunctions.sh
|
||||
source ./common.sh
|
||||
|
||||
run_test '$ABRA server new --provider hetzner-cloud --hetzner-name integration-tests --no-input'
|
||||
|
||||
run_test '$ABRA server ls'
|
||||
|
||||
run_test '$ABRA server rm --provider hetzner-cloud --hetzner-name int-core --server --no-input'
|
@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z $1 ]; then
|
||||
echo "usage: ./test_all.sh logdir"
|
||||
exit
|
||||
fi
|
||||
|
||||
res_dir=$1/
|
||||
if [[ ! -d "$res_dir" ]]; then
|
||||
mkdir "$res_dir"
|
||||
fi
|
||||
|
||||
# Usage: run_test [number] [name] [command]
|
||||
run_test () {
|
||||
logfile="$res_dir/$1-$2.log"
|
||||
echo $logfile
|
||||
}
|
||||
|
||||
testScripts=("app.sh" "autocomplete.sh" "catalogue.sh" "install.sh" "recipe.sh" "records.sh" "server.sh", "cmd.sh")
|
||||
|
||||
for i in "${testScripts[@]}"; do
|
||||
cmd="./$i $res_dir${i/sh/log}"
|
||||
eval $cmd
|
||||
done
|
@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z $1 ]; then
|
||||
logfile=/dev/null
|
||||
else
|
||||
logfile=$1
|
||||
fi
|
||||
|
||||
if [ -z $logall ]; then
|
||||
logall=no
|
||||
fi
|
||||
|
||||
run_test () {
|
||||
if [ -z "$@" ]; then
|
||||
echo "run_test needs a command to run"
|
||||
else
|
||||
tempLogfile=$(mktemp)
|
||||
cmd=$(eval echo "$@")
|
||||
echo -e "\\n------------ INPUT -------------------" | tee -a $tempLogfile
|
||||
echo "$" "$cmd" | tee -a $tempLogfile
|
||||
echo "------------ OUTPUT ------------------" | tee -a $tempLogfile
|
||||
eval $cmd 2>&1 | tee -a $tempLogfile
|
||||
if [ $logall = "yes" ]; then
|
||||
cat $tempLogfile >> $logfile
|
||||
echo -e "\\n\\n" >> $logfile
|
||||
else
|
||||
read -N 1 -p "Did the test pass? [y/n]: " pass
|
||||
if [ $pass = 'n' ]; then
|
||||
cat $tempLogfile >> $logfile
|
||||
echo -e "\\n\\n" >> $logfile
|
||||
fi
|
||||
fi
|
||||
rm $tempLogfile
|
||||
fi
|
||||
}
|
@ -1 +0,0 @@
|
||||
TYPE=test
|
@ -1 +0,0 @@
|
||||
.
|
@ -1,5 +0,0 @@
|
||||
test(){
|
||||
echo "1: $1"
|
||||
echo "2: $2"
|
||||
echo "all: $@"
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
app: []
|
Reference in New Issue
Block a user