forked from toolshed/abra
		
	test: test arguments, notes, local tag lookup
This commit is contained in:
		| @ -17,6 +17,13 @@ setup() { | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "retrieve recipe if missing" { | @test "retrieve recipe if missing" { | ||||||
|   assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE" |   assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE" | ||||||
|  |  | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app cmd |   run $ABRA app cmd | ||||||
|   assert_failure |   assert_failure | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app cp |   run $ABRA app cp | ||||||
|   assert_failure |   assert_failure | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app deploy |   run $ABRA app deploy | ||||||
|   assert_failure |   assert_failure | ||||||
| @ -43,6 +50,8 @@ setup(){ | |||||||
|  |  | ||||||
|   run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" |   run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" | ||||||
|   assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" |   assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" | ||||||
|  |  | ||||||
|  |   _checkout_recipe "$TEST_RECIPE" | ||||||
| } | } | ||||||
|  |  | ||||||
| # bats test_tags=slow | # bats test_tags=slow | ||||||
| @ -77,25 +86,26 @@ setup(){ | |||||||
|   run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks |   run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks | ||||||
|   assert_success |   assert_success | ||||||
|  |  | ||||||
|   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status |   # NOTE(d1): nuke it to ensure clean git state | ||||||
|   refute_output --partial 'behind 3' |   run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE" | ||||||
|  |   assert_success | ||||||
|  |   assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE" | ||||||
|  |   _fetch_recipe "$TEST_RECIPE" | ||||||
|  |  | ||||||
|   _undeploy_app |   _undeploy_app | ||||||
| } | } | ||||||
|  |  | ||||||
| # bats test_tags=slow | # bats test_tags=slow | ||||||
| @test "ensure recipe not up to date if --offline" { | @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 |   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3 | ||||||
|   assert_success |   assert_success | ||||||
|  |  | ||||||
|   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status |   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status | ||||||
|   assert_output --partial 'behind 3' |   assert_output --partial 'behind 3' | ||||||
|  |  | ||||||
|  |   # NOTE(d1): need to use --chaos to force same commit | ||||||
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \ |   run $ABRA app deploy "$TEST_APP_DOMAIN" \ | ||||||
|     --no-input --no-converge-checks --offline |     --no-input --no-converge-checks --chaos --offline | ||||||
|   assert_success |   assert_success | ||||||
|  |  | ||||||
|   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status |   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status | ||||||
| @ -103,23 +113,46 @@ setup(){ | |||||||
|  |  | ||||||
|   _undeploy_app |   _undeploy_app | ||||||
|  |  | ||||||
|   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit" |   # NOTE(d1): nuke it to ensure clean git state | ||||||
|  |   run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE" | ||||||
|   assert_success |   assert_success | ||||||
|  |   assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE" | ||||||
|   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status |   _fetch_recipe "$TEST_RECIPE" | ||||||
|   refute_output --partial 'behind 3' |  | ||||||
| } | } | ||||||
|  |  | ||||||
| # bats test_tags=slow | # bats test_tags=slow | ||||||
| @test "deploy latest commit if no published versions and no --chaos" { | @test "deploy latest commit if no published versions and no --chaos" { | ||||||
|   latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)" |   latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)" | ||||||
|  |  | ||||||
|   run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks |   run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l' | ||||||
|  |   assert_success | ||||||
|  |   refute_output '0' | ||||||
|  |  | ||||||
|  |   run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | \ | ||||||
|  |     xargs -I{} git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -d {}' | ||||||
|  |   assert_success | ||||||
|  |   assert_output --partial 'Deleted tag' | ||||||
|  |  | ||||||
|  |   run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l' | ||||||
|  |   assert_success | ||||||
|  |   assert_output '0' | ||||||
|  |  | ||||||
|  |   # NOTE(d1): need to pass --offline to stop tags being pulled again | ||||||
|  |   run $ABRA app deploy "$TEST_APP_DOMAIN" \ | ||||||
|  |     --no-input --no-converge-checks --offline | ||||||
|   assert_success |   assert_success | ||||||
|   assert_output --partial "$latestCommit" |   assert_output --partial "$latestCommit" | ||||||
|  |   assert_output --partial 'using latest commit' | ||||||
|   refute_output --partial 'chaos' |   refute_output --partial 'chaos' | ||||||
|  |  | ||||||
|   _undeploy_app |   _undeploy_app | ||||||
|  |  | ||||||
|  |   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" fetch --all | ||||||
|  |   assert_success | ||||||
|  |  | ||||||
|  |   run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l' | ||||||
|  |   assert_success | ||||||
|  |   refute_output '0' | ||||||
| } | } | ||||||
|  |  | ||||||
| # bats test_tags=slow | # bats test_tags=slow | ||||||
| @ -143,9 +176,11 @@ setup(){ | |||||||
|  |  | ||||||
|   _undeploy_app |   _undeploy_app | ||||||
|  |  | ||||||
|   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit" |   # NOTE(d1): nuke it to ensure clean git state | ||||||
|  |   run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE" | ||||||
|   assert_success |   assert_success | ||||||
|   refute_output --partial 'behind 3' |   assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE" | ||||||
|  |   _fetch_recipe "$TEST_RECIPE" | ||||||
| } | } | ||||||
|  |  | ||||||
| # bats test_tags=slow | # bats test_tags=slow | ||||||
| @ -274,3 +309,18 @@ setup(){ | |||||||
|  |  | ||||||
|   _undeploy_app |   _undeploy_app | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @test "error if specific version does not exist" { | ||||||
|  |   run $ABRA app deploy "$TEST_APP_DOMAIN" DOESNTEXIST --no-input --no-converge-checks | ||||||
|  |   assert_failure | ||||||
|  |   assert_output --partial "doesn't seem to have version DOESNTEXIST available" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # bats test_tags=slow | ||||||
|  | @test "deploy specific version" { | ||||||
|  |   run $ABRA app deploy "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input | ||||||
|  |   assert_success | ||||||
|  |   assert_output --partial "0.2.0+1.21.0" | ||||||
|  |  | ||||||
|  |   _undeploy_app | ||||||
|  | } | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "list without status" { | @test "list without status" { | ||||||
|   run $ABRA app ls |   run $ABRA app ls | ||||||
|   assert_success |   assert_success | ||||||
|  | |||||||
| @ -16,6 +16,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "create new app" { | @test "create new app" { | ||||||
|   run $ABRA app new "$TEST_RECIPE" \ |   run $ABRA app new "$TEST_RECIPE" \ | ||||||
|     --no-input \ |     --no-input \ | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app ps |   run $ABRA app ps | ||||||
|   assert_failure |   assert_failure | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app deploy |   run $ABRA app deploy | ||||||
|   assert_failure |   assert_failure | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app restart |   run $ABRA app restart | ||||||
|   assert_failure |   assert_failure | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app restore |   run $ABRA app restore | ||||||
|   assert_failure |   assert_failure | ||||||
|  | |||||||
| @ -8,6 +8,7 @@ setup_file(){ | |||||||
| } | } | ||||||
|  |  | ||||||
| teardown_file(){ | teardown_file(){ | ||||||
|  |   _rm_app | ||||||
|   _rm_server |   _rm_server | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -16,8 +17,12 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
| # TODO(d1): test "no available downgrades" when this is implemented | teardown(){ | ||||||
| # https://git.coopcloud.tech/coop-cloud/organising/issues/204 |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app rollback |   run $ABRA app rollback | ||||||
| @ -73,8 +78,11 @@ setup(){ | |||||||
|   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit" |   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit" | ||||||
|   assert_success |   assert_success | ||||||
|  |  | ||||||
|   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status |   # NOTE(d1): nuke it to ensure clean git state | ||||||
|   refute_output --partial 'behind 3' |   run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE" | ||||||
|  |   assert_success | ||||||
|  |   assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE" | ||||||
|  |   _fetch_recipe "$TEST_RECIPE" | ||||||
| } | } | ||||||
|  |  | ||||||
| @test "bail if unstaged changes and no --chaos" { | @test "bail if unstaged changes and no --chaos" { | ||||||
| @ -123,38 +131,21 @@ setup(){ | |||||||
|  |  | ||||||
| # bats test_tags=slow | # bats test_tags=slow | ||||||
| @test "ensure same commit if --chaos" { | @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)" |   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" \ |   run $ABRA app deploy "$TEST_APP_DOMAIN" \ | ||||||
|     --no-input --no-converge-checks --chaos |     --no-input --no-converge-checks --chaos | ||||||
|   assert_success |   assert_success | ||||||
|   refute_output --partial "$latestCommit" |   assert_output --partial "$latestCommit" | ||||||
|   assert_output --partial "$threeCommitsBack" |  | ||||||
|   assert_output --partial 'chaos' |   assert_output --partial 'chaos' | ||||||
|  |  | ||||||
|   run $ABRA app rollback "$TEST_APP_DOMAIN" \ |   run $ABRA app rollback "$TEST_APP_DOMAIN" \ | ||||||
|     --chaos --no-input --no-converge-checks |     --chaos --no-input --no-converge-checks | ||||||
|   assert_success |   assert_success | ||||||
|   refute_output --partial "$latestCommit" |   assert_output --partial "$latestCommit" | ||||||
|   assert_output --partial "$threeCommitsBack" |  | ||||||
|   assert_output --partial 'chaos' |   assert_output --partial 'chaos' | ||||||
|  |  | ||||||
|   _undeploy_app |   _undeploy_app | ||||||
|  |  | ||||||
|   run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit" |  | ||||||
|   assert_success |  | ||||||
|   refute_output --partial 'behind 3' |  | ||||||
| } | } | ||||||
|  |  | ||||||
| # bats test_tags=slow | # bats test_tags=slow | ||||||
| @ -164,7 +155,8 @@ setup(){ | |||||||
|   run sed -i '/traefik.enable=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" |   run sed -i '/traefik.enable=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" | ||||||
|   assert_success |   assert_success | ||||||
|  |  | ||||||
|   run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --chaos |   run $ABRA app rollback "$TEST_APP_DOMAIN" \ | ||||||
|  |     --no-input --chaos --chaos --no-converge-checks | ||||||
|   assert_failure |   assert_failure | ||||||
|   assert_output --partial 'failed lint checks' |   assert_output --partial 'failed lint checks' | ||||||
|  |  | ||||||
| @ -174,59 +166,59 @@ setup(){ | |||||||
| } | } | ||||||
|  |  | ||||||
| @test "error if not already deployed" { | @test "error if not already deployed" { | ||||||
|   run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --chaos |   run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input | ||||||
|   assert_failure |   assert_failure | ||||||
|   assert_output --partial 'not deployed' |   assert_output --partial 'not deployed' | ||||||
| } | } | ||||||
|  |  | ||||||
| # bats test_tags=slow | # bats test_tags=slow | ||||||
| @test "error if no published release and no --chaos" { | @test "no rollback if on oldest version" { | ||||||
|   _deploy_app |   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 rollback "$TEST_APP_DOMAIN" --no-input |   run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks | ||||||
|  |   assert_success | ||||||
|  |   assert_output --partial "you're on oldest" | ||||||
|  |  | ||||||
|  |   _undeploy_app | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # bats test_tags=slow | ||||||
|  | @test "error if specific version is not downgrade" { | ||||||
|  |   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 rollback "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks | ||||||
|   assert_failure |   assert_failure | ||||||
|   assert_output --partial 'no published releases' |   assert_output --partial 'is not a downgrade' | ||||||
|  |  | ||||||
|   _undeploy_app |   _undeploy_app | ||||||
| } | } | ||||||
|  |  | ||||||
| # bats test_tags=slow | # bats test_tags=slow | ||||||
| @test "rollback to previous version" { | @test "rollback to previous version" { | ||||||
|   latestVersion=$(jq -r '.gitea.versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json") |   run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.1+1.20.2" --no-input --no-converge-checks | ||||||
|   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_success | ||||||
|   assert_exists "$ABRA_DIR/servers/$TEST_SERVER/gitea.$TEST_SERVER.env" |   assert_output --partial '0.1.1+1.20.2' | ||||||
|  |  | ||||||
|   run $ABRA app deploy "gitea.$TEST_SERVER" --no-input --no-converge-checks |   run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks | ||||||
|   assert_success |   assert_success | ||||||
|   assert_output --partial "$latestVersion" |   assert_output --partial "0.1.0+1.20.0" | ||||||
|  |  | ||||||
|   run $ABRA app rollback "gitea.$TEST_SERVER" --no-input --no-converge-checks |   _undeploy_app | ||||||
|   assert_success | } | ||||||
|   assert_output --partial "$rollbackVersion" |  | ||||||
|  | # bats test_tags=slow | ||||||
|   run $ABRA app undeploy "gitea.$TEST_SERVER" --no-input | @test "rollback to a version 2 tags behind" { | ||||||
|   assert_success |   run $ABRA app deploy "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input --no-converge-checks | ||||||
|  |   assert_success | ||||||
|   run $ABRA app secret remove "gitea.$TEST_SERVER" --all --no-input |   assert_output --partial "0.2.0+1.21.0" | ||||||
|   assert_success |  | ||||||
|  |   run $ABRA app rollback "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks | ||||||
|   # NOTE(d1): to let the stack come down before nuking volumes |   assert_success | ||||||
|   sleep 5 |   assert_output --partial "0.1.0+1.20.0" | ||||||
|  |  | ||||||
|   run $ABRA app volume remove "gitea.$TEST_SERVER" --no-input |   _undeploy_app | ||||||
|   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" |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app run |   run $ABRA app run | ||||||
|   assert_failure |   assert_failure | ||||||
|  | |||||||
| @ -18,6 +18,13 @@ teardown_file(){ | |||||||
|   _rm_server |   _rm_server | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| setup(){ | setup(){ | ||||||
|   load "$PWD/tests/integration/helpers/common" |   load "$PWD/tests/integration/helpers/common" | ||||||
|   _common_setup |   _common_setup | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app services |   run $ABRA app services | ||||||
|   assert_failure |   assert_failure | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app undeploy |   run $ABRA app undeploy | ||||||
|   assert_failure |   assert_failure | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app upgrade |   run $ABRA app upgrade | ||||||
|   assert_failure |   assert_failure | ||||||
| @ -28,49 +35,171 @@ setup(){ | |||||||
| } | } | ||||||
|  |  | ||||||
| # bats test_tags=slow | # bats test_tags=slow | ||||||
| @test "upgrade app" { | @test "error if specific version is not an upgrade" { | ||||||
|   latestVersion=$(jq -r '.gitea.versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json") |   run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks | ||||||
|   refute [ -z "$latestVersion" ]; |   assert_success | ||||||
|  |   assert_output --partial '0.1.0+1.20.0' | ||||||
|  |  | ||||||
|   rollbackVersion=$(jq -r '.gitea.versions[-2] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json") |   run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input | ||||||
|   refute [ -z "$rollbackVersion" ]; |   assert_failure | ||||||
|  |   assert_output --partial 'is not an upgrade' | ||||||
|  |  | ||||||
|   run $ABRA app new gitea \ |   _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' | ||||||
|  |  | ||||||
|  |   _checkout_recipe "$TEST_RECIPE" | ||||||
|  |  | ||||||
|  |   _undeploy_app | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # 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 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # bats test_tags=slow | ||||||
|  | @test "upgrade to latest catalogue published version" { | ||||||
|  |   appDomain="custom-html.$TEST_SERVER" | ||||||
|  |  | ||||||
|  |   run $ABRA app new custom-html \ | ||||||
|     --no-input \ |     --no-input \ | ||||||
|     --server "$TEST_SERVER" \ |     --server "$TEST_SERVER" \ | ||||||
|     --domain "gitea.$TEST_SERVER" \ |     --domain "$appDomain" | ||||||
|     --secrets |  | ||||||
|   assert_success |  | ||||||
|   assert_exists "$ABRA_DIR/servers/$TEST_SERVER/gitea.$TEST_SERVER.env" |  | ||||||
|  |  | ||||||
|   run $ABRA app deploy "gitea.$TEST_SERVER" --no-input |   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 | ||||||
|  |   assert_success | ||||||
|  |   assert_output --partial "$oneVersionsBack" | ||||||
|  |  | ||||||
|  |   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 | ||||||
|   assert_success |   assert_success | ||||||
|   assert_output --partial "$latestVersion" |   assert_output --partial "$latestVersion" | ||||||
|  |  | ||||||
|   run $ABRA app rollback "gitea.$TEST_SERVER" --no-input |   run $ABRA app undeploy "$appDomain" --no-input | ||||||
|   assert_success |  | ||||||
|   assert_output --partial "$rollbackVersion" |  | ||||||
|  |  | ||||||
|   # NOTE(d1): let runtime settle down before upgrade |  | ||||||
|   sleep 5 |  | ||||||
|  |  | ||||||
|   run $ABRA app upgrade "gitea.$TEST_SERVER" --no-input |  | ||||||
|   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 |   assert_success | ||||||
|  |  | ||||||
|  # NOTE(d1): to let the stack come down before nuking volumes |  # NOTE(d1): to let the stack come down before nuking volumes | ||||||
|   sleep 5 |   sleep 3 | ||||||
|  |  | ||||||
|   run $ABRA app volume remove "gitea.$TEST_SERVER" --no-input |   run $ABRA app volume remove "$appDomain" --no-input | ||||||
|   assert_success |   assert_success | ||||||
|  |  | ||||||
|   run $ABRA app remove "gitea.$TEST_SERVER" --no-input |   run $ABRA app remove "$appDomain" --no-input | ||||||
|   assert_success |   assert_success | ||||||
|   assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER/gitea.$TEST_SERVER.env" |   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 | ||||||
|  |   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' | ||||||
|  |  | ||||||
|  |   _undeploy_app | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # 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 | ||||||
|  |   assert_success | ||||||
|  |   assert_output --partial '0.1.0+1.20.0' | ||||||
|  |  | ||||||
|  |   run $ABRA app upgrade "$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' | ||||||
|  |   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 | ||||||
| } | } | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "validate app argument" { | @test "validate app argument" { | ||||||
|   run $ABRA app version |   run $ABRA app version | ||||||
|   assert_failure |   assert_failure | ||||||
| @ -61,38 +68,16 @@ setup(){ | |||||||
|   _undeploy_app |   _undeploy_app | ||||||
| } | } | ||||||
|  |  | ||||||
|  | # bats test_tags=slow | ||||||
| @test "list version" { | @test "list version" { | ||||||
|   latestVersion=$(jq -r '.gitea.versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json") |   _deploy_app | ||||||
|  |  | ||||||
|  |   latestVersion=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" git tag | tail -n 1) | ||||||
|   refute [ -z "$latestVersion" ]; |   refute [ -z "$latestVersion" ]; | ||||||
|  |  | ||||||
|   run $ABRA app new gitea \ |   run $ABRA app version "$TEST_APP_DOMAIN" | ||||||
|     --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_success | ||||||
|   assert_output --partial "$latestVersion" |   assert_output --partial "$latestVersion" | ||||||
|  |  | ||||||
|   run $ABRA app undeploy "gitea.$TEST_SERVER" --no-input |   _undeploy_app | ||||||
|   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" |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -17,6 +17,13 @@ setup(){ | |||||||
|   _common_setup |   _common_setup | ||||||
| } | } | ||||||
|  |  | ||||||
|  | teardown(){ | ||||||
|  |   # https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888 | ||||||
|  |   if [[ -z "${BATS_TEST_COMPLETED}" ]]; then | ||||||
|  |     _undeploy_app | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| @test "ls validate app argument" { | @test "ls validate app argument" { | ||||||
|   run $ABRA app volume ls |   run $ABRA app volume ls | ||||||
|   assert_failure |   assert_failure | ||||||
|  | |||||||
| @ -1,13 +1,13 @@ | |||||||
| #!/usr/bin/env bash | #!/usr/bin/env bash | ||||||
|  |  | ||||||
| setup_suite(){ | setup_suite(){ | ||||||
|   if [[ -z "${TEST_SERVER}" ]]; then |   if [[ -z "${ABRA_DIR}" ]]; then | ||||||
|     echo 'set $TEST_SERVER before running the test suite' >&3 |     echo 'set $ABRA_DIR before running the test suite' >&3 | ||||||
|     exit 1 |     exit 1 | ||||||
|   fi |   fi | ||||||
|  |  | ||||||
|   if [[ -z "${ABRA_DIR}" ]]; then |   if [[ -z "${TEST_SERVER}" ]]; then | ||||||
|     echo 'set $ABRA_DIR before running the test suite' >&3 |     echo 'set $TEST_SERVER before running the test suite' >&3 | ||||||
|     exit 1 |     exit 1 | ||||||
|   fi |   fi | ||||||
|  |  | ||||||
| @ -36,6 +36,11 @@ setup_suite(){ | |||||||
| } | } | ||||||
|  |  | ||||||
| teardown_suite(){ | teardown_suite(){ | ||||||
|  |   if [[ -z "${ABRA_DIR}" ]]; then | ||||||
|  |     echo 'set $ABRA_DIR before running the test suite' >&3 | ||||||
|  |     exit 1 | ||||||
|  |   fi | ||||||
|  |  | ||||||
|   if [[ -d "$ABRA_DIR" ]]; then |   if [[ -d "$ABRA_DIR" ]]; then | ||||||
|     rm -rf "$ABRA_DIR" |     rm -rf "$ABRA_DIR" | ||||||
|   fi |   fi | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user