2023-09-07 16:50:25 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
setup_file(){
|
|
|
|
load "$PWD/tests/integration/helpers/common"
|
|
|
|
_common_setup
|
|
|
|
_add_server
|
|
|
|
_new_app
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown_file(){
|
2023-09-21 09:52:35 +00:00
|
|
|
_rm_app
|
2023-09-07 16:50:25 +00:00
|
|
|
_rm_server
|
|
|
|
}
|
|
|
|
|
|
|
|
setup(){
|
|
|
|
load "$PWD/tests/integration/helpers/common"
|
|
|
|
_common_setup
|
|
|
|
}
|
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
teardown(){
|
|
|
|
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
|
|
|
|
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
|
|
|
|
_undeploy_app
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-09-07 16:50:25 +00:00
|
|
|
@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'
|
|
|
|
}
|
2023-09-21 09:52:35 +00:00
|
|
|
|
|
|
|
# bats test_tags=slow
|
2023-09-23 07:17:24 +00:00
|
|
|
@test "error if specific version is not an upgrade" {
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
|
|
|
|
assert_success
|
|
|
|
assert_output --partial '0.1.0+1.20.0'
|
|
|
|
|
|
|
|
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input
|
|
|
|
assert_failure
|
|
|
|
assert_output --partial 'is not an upgrade'
|
|
|
|
|
|
|
|
_undeploy_app
|
|
|
|
}
|
|
|
|
|
|
|
|
# bats test_tags=slow
|
|
|
|
@test "no upgrade if lint error" {
|
|
|
|
_deploy_app
|
|
|
|
|
|
|
|
run sed -i '/traefik.enable=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
|
|
|
assert_success
|
|
|
|
|
|
|
|
run $ABRA app upgrade "$TEST_APP_DOMAIN" \
|
|
|
|
--no-input --no-converge-checks --chaos
|
|
|
|
assert_failure
|
|
|
|
assert_output --partial 'failed lint checks'
|
|
|
|
|
2023-09-23 21:57:52 +00:00
|
|
|
_checkout_recipe
|
2023-09-23 07:17:24 +00:00
|
|
|
|
|
|
|
_undeploy_app
|
|
|
|
}
|
2023-09-21 09:52:35 +00:00
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
# bats test_tags=slow
|
|
|
|
@test "no upgrade if on latest version" {
|
|
|
|
_deploy_app
|
|
|
|
|
|
|
|
run $ABRA app upgrade "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
|
|
|
assert_success
|
|
|
|
assert_output --partial "you're on latest"
|
|
|
|
|
|
|
|
_undeploy_app
|
|
|
|
}
|
2023-09-21 09:52:35 +00:00
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
# bats test_tags=slow
|
|
|
|
@test "upgrade to latest catalogue published version" {
|
|
|
|
appDomain="custom-html.$TEST_SERVER"
|
|
|
|
|
|
|
|
run $ABRA app new custom-html \
|
2023-09-21 09:52:35 +00:00
|
|
|
--no-input \
|
|
|
|
--server "$TEST_SERVER" \
|
2023-09-23 07:17:24 +00:00
|
|
|
--domain "$appDomain"
|
|
|
|
|
|
|
|
oneVersionBack=$(jq -r '."custom-html".versions[-2] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
|
|
|
|
refute [ -z "$oneVersionBack" ];
|
|
|
|
|
|
|
|
run $ABRA app deploy "$appDomain" "$oneVersionBack" --no-input --no-converge-checks
|
2023-09-21 09:52:35 +00:00
|
|
|
assert_success
|
2023-09-23 07:17:24 +00:00
|
|
|
assert_output --partial "$oneVersionsBack"
|
2023-09-21 09:52:35 +00:00
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
latestVersion=$(jq -r '."custom-html".versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
|
|
|
|
refute [ -z "$latestVersion" ];
|
|
|
|
|
|
|
|
run $ABRA app upgrade "$appDomain" --no-input --no-converge-checks
|
2023-09-21 09:52:35 +00:00
|
|
|
assert_success
|
|
|
|
assert_output --partial "$latestVersion"
|
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
run $ABRA app undeploy "$appDomain" --no-input
|
2023-09-21 09:52:35 +00:00
|
|
|
assert_success
|
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
# NOTE(d1): to let the stack come down before nuking volumes
|
|
|
|
sleep 3
|
2023-09-21 09:52:35 +00:00
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
run $ABRA app volume remove "$appDomain" --no-input
|
2023-09-21 09:52:35 +00:00
|
|
|
assert_success
|
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
run $ABRA app remove "$appDomain" --no-input
|
|
|
|
assert_success
|
|
|
|
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER/$appDomain.env"
|
|
|
|
}
|
|
|
|
|
|
|
|
# bats test_tags=slow
|
|
|
|
@test "upgrade specific version" {
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
|
2023-09-21 09:52:35 +00:00
|
|
|
assert_success
|
2023-09-23 07:17:24 +00:00
|
|
|
assert_output --partial '0.1.0+1.20.0'
|
2023-09-21 09:52:35 +00:00
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input --no-converge-checks
|
2023-09-21 09:52:35 +00:00
|
|
|
assert_success
|
2023-09-23 07:17:24 +00:00
|
|
|
assert_output --partial '0.2.0+1.21.0'
|
2023-09-21 09:52:35 +00:00
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
_undeploy_app
|
|
|
|
}
|
2023-09-21 09:52:35 +00:00
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
# bats test_tags=slow
|
|
|
|
@test "upgrade to latest" {
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
|
|
|
|
assert_success
|
|
|
|
assert_output --partial '0.1.0+1.20.0'
|
|
|
|
|
|
|
|
latestRelease=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | tail -n 1)
|
|
|
|
|
|
|
|
run $ABRA app upgrade "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
|
|
|
assert_success
|
|
|
|
assert_output --partial "$latestRelease"
|
|
|
|
|
|
|
|
_undeploy_app
|
|
|
|
}
|
|
|
|
|
|
|
|
# bats test_tags=slow
|
|
|
|
@test "show single release note" {
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.1+1.20.2" --no-input --no-converge-checks
|
|
|
|
assert_success
|
|
|
|
assert_output --partial '0.1.1+1.20.2'
|
|
|
|
|
|
|
|
latestRelease=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | tail -n 1)
|
|
|
|
|
|
|
|
run $ABRA app upgrade "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
|
|
|
assert_success
|
|
|
|
assert_output --partial "$latestRelease"
|
|
|
|
assert_output --partial 'release notes baz' # 0.2.0+1.21.0
|
|
|
|
refute_output --partial 'release notes bar' # 0.1.1+1.20.2
|
|
|
|
|
|
|
|
_undeploy_app
|
|
|
|
}
|
|
|
|
|
|
|
|
# bats test_tags=slow
|
|
|
|
@test "show single release note for specific version" {
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
|
2023-09-21 09:52:35 +00:00
|
|
|
assert_success
|
2023-09-23 07:17:24 +00:00
|
|
|
assert_output --partial '0.1.0+1.20.0'
|
2023-09-21 09:52:35 +00:00
|
|
|
|
2023-09-23 07:17:24 +00:00
|
|
|
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.1.1+1.20.2" --no-input --no-converge-checks
|
2023-09-21 09:52:35 +00:00
|
|
|
assert_success
|
2023-09-23 07:17:24 +00:00
|
|
|
assert_output --partial '0.1.1+1.20.2'
|
|
|
|
assert_output --partial 'release notes bar' # 0.1.1+1.20.2
|
|
|
|
refute_output --partial 'release notes baz' # 0.2.0+1.21.0
|
|
|
|
|
|
|
|
_undeploy_app
|
|
|
|
}
|
|
|
|
|
|
|
|
# bats test_tags=slow
|
|
|
|
@test "show multiple release notes" {
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
|
|
|
|
assert_success
|
|
|
|
assert_output --partial '0.1.0+1.20.0'
|
|
|
|
|
|
|
|
latestRelease=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | tail -n 1)
|
|
|
|
|
|
|
|
run $ABRA app upgrade "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
|
|
|
assert_success
|
|
|
|
assert_output --partial "$latestRelease"
|
|
|
|
assert_output --partial 'release notes bar' # 0.1.1+1.20.2
|
|
|
|
assert_output --partial 'release notes baz' # 0.2.0+1.21.0
|
|
|
|
|
|
|
|
_undeploy_app
|
|
|
|
}
|
|
|
|
|
|
|
|
# bats test_tags=slow
|
|
|
|
@test "show multiple release notes for specific version" {
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
|
|
|
|
assert_success
|
|
|
|
assert_output --partial '0.1.0+1.20.0'
|
|
|
|
|
|
|
|
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input --no-converge-checks
|
|
|
|
assert_success
|
|
|
|
assert_output --partial '0.2.0+1.21.0'
|
|
|
|
assert_output --partial 'release notes bar' # 0.1.1+1.20.2
|
|
|
|
assert_output --partial 'release notes baz' # 0.2.0+1.21.0
|
|
|
|
|
|
|
|
_undeploy_app
|
2023-09-21 09:52:35 +00:00
|
|
|
}
|