forked from toolshed/abra
		
	
		
			
				
	
	
		
			257 lines
		
	
	
		
			7.7 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			257 lines
		
	
	
		
			7.7 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #!/usr/bin/env bash
 | |
| 
 | |
| setup_file(){
 | |
|   load "$PWD/tests/integration/helpers/common"
 | |
|   _common_setup
 | |
|   _add_server
 | |
|   _new_app
 | |
| }
 | |
| 
 | |
| teardown_file(){
 | |
|   _rm_app
 | |
|   _rm_server
 | |
|   _reset_recipe
 | |
| }
 | |
| 
 | |
| setup(){
 | |
|   load "$PWD/tests/integration/helpers/common"
 | |
|   _common_setup
 | |
| }
 | |
| 
 | |
| teardown(){
 | |
|   _reset_recipe
 | |
|   _undeploy_app
 | |
|   _reset_app
 | |
|   _reset_tags
 | |
| 
 | |
|   run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
 | |
|   assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
 | |
| }
 | |
| 
 | |
| @test "first deploy with empty env version" {
 | |
|   latestRelease=$(_latest_release)
 | |
| 
 | |
|   _wipe_env_version
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks
 | |
|   assert_success
 | |
| 
 | |
|   assert_output --partial 'NEW DEPLOY OVERVIEW'
 | |
|   assert_output --partial 'CURRENT DEPLOYMENT    N/A'
 | |
|   assert_output --partial 'ENV VERSION           N/A'
 | |
|   assert_output --partial "NEW DEPLOYMENT        ${latestRelease}"
 | |
| 
 | |
|   run grep -q "TYPE=$TEST_RECIPE:${latestRelease}" \
 | |
|     "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
 | |
|   assert_success
 | |
| }
 | |
| 
 | |
| @test "first deploy to latest version" {
 | |
|   latestRelease=$(_latest_release)
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks
 | |
|   assert_success
 | |
| 
 | |
|   assert_output --partial 'NEW DEPLOY OVERVIEW'
 | |
|   assert_output --partial "CURRENT DEPLOYMENT    N/A"
 | |
|   assert_output --partial "ENV VERSION           ${latestRelease}"
 | |
|   assert_output --partial "NEW DEPLOYMENT        ${latestRelease}"
 | |
| 
 | |
|   run grep -q "TYPE=$TEST_RECIPE:${latestRelease}" \
 | |
|     "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
 | |
|   assert_success
 | |
| }
 | |
| 
 | |
| # bats test_tags=slow
 | |
| @test "deploy, re-deploy, choose env version" {
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.1+1.20.2" \
 | |
|     --no-input --no-converge-checks
 | |
|   assert_success
 | |
| 
 | |
|   _undeploy_app
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks
 | |
|   assert_success
 | |
| 
 | |
|   assert_output --partial 'NEW DEPLOY OVERVIEW'
 | |
|   assert_output --partial "CURRENT DEPLOYMENT    N/A"
 | |
|   assert_output --partial "ENV VERSION           0.1.1+1.20.2"
 | |
|   assert_output --partial "NEW DEPLOYMENT        0.1.1+1.20.2"
 | |
| 
 | |
|   run grep -q "TYPE=$TEST_RECIPE:0.1.1+1.20.2" \
 | |
|     "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
 | |
|   assert_success
 | |
| }
 | |
| 
 | |
| @test "deploy, re-deploy, deploy latest" {
 | |
|   latestRelease=$(_latest_release)
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.1+1.20.2" \
 | |
|     --no-input --no-converge-checks
 | |
|   assert_success
 | |
| 
 | |
|   _undeploy_app
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks --latest
 | |
|   assert_success
 | |
| 
 | |
|   assert_output --partial 'NEW DEPLOY OVERVIEW'
 | |
|   assert_output --partial "CURRENT DEPLOYMENT    N/A"
 | |
|   assert_output --partial "ENV VERSION           0.1.1+1.20.2"
 | |
|   assert_output --partial "NEW DEPLOYMENT        ${latestRelease}"
 | |
| 
 | |
|   run grep -q "TYPE=$TEST_RECIPE:${latestRelease}" \
 | |
|     "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
 | |
|   assert_success
 | |
| }
 | |
| 
 | |
| @test "deploy then chaos deploy" {
 | |
|   headHash=$(_get_head_hash)
 | |
|   latestRelease=$(_latest_release)
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks
 | |
|   assert_success
 | |
| 
 | |
|   run bash -c 'echo "unstaged changes" >> "$ABRA_DIR/recipes/$TEST_RECIPE/foo"'
 | |
|   assert_success
 | |
|   assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks --chaos
 | |
|   assert_success
 | |
| 
 | |
|   assert_output --partial 'CHAOS DEPLOY OVERVIEW'
 | |
|   assert_output --partial "CURRENT DEPLOYMENT    ${latestRelease}"
 | |
|   assert_output --partial "ENV VERSION           ${latestRelease}"
 | |
|   assert_output --partial "NEW DEPLOYMENT        ${headHash:0:8}+U"
 | |
| 
 | |
|   run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
 | |
|   assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
 | |
| 
 | |
|   run grep -q "TYPE=$TEST_RECIPE:${headHash:0:8}" \
 | |
|     "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
 | |
|   assert_success
 | |
| }
 | |
| 
 | |
| @test "can not redeploy chaos version without --chaos" {
 | |
|   headHash=$(_get_head_hash)
 | |
|   latestRelease=$(_latest_release)
 | |
| 
 | |
|   run bash -c 'echo "unstaged changes" >> "$ABRA_DIR/recipes/$TEST_RECIPE/foo"'
 | |
|   assert_success
 | |
|   assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks --chaos
 | |
|   assert_success
 | |
| 
 | |
|   run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
 | |
|   assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks --force --debug
 | |
|   assert_failure
 | |
|   assert_output --regexp 'can not redeploy chaos version .*' + "${headHash:0:8}+U"
 | |
| }
 | |
| 
 | |
| @test "deploy then force commit deploy" {
 | |
|   headHash=$(_get_head_hash)
 | |
|   latestRelease=$(_latest_release)
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks
 | |
|   assert_success
 | |
| 
 | |
|   run grep -q "TYPE=$TEST_RECIPE:${latestRelease}" \
 | |
|     "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
 | |
|   assert_success
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" "${headHash:0:8}" \
 | |
|     --no-input --no-converge-checks --force
 | |
|   assert_success
 | |
| 
 | |
|   assert_output --partial 'DEPLOY OVERVIEW'
 | |
|   assert_output --partial "CURRENT DEPLOYMENT    ${latestRelease}"
 | |
|   assert_output --partial "ENV VERSION           ${latestRelease}"
 | |
|   assert_output --partial "NEW DEPLOYMENT        ${headHash:0:8}"
 | |
| 
 | |
|   run grep -q "TYPE=$TEST_RECIPE:${headHash:0:8}" \
 | |
|     "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
 | |
|   assert_success
 | |
| }
 | |
| 
 | |
| @test "chaos deploy then chaos deploy with unstaged" {
 | |
|   headHash=$(_get_head_hash)
 | |
|   latestRelease=$(_latest_release)
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks --chaos
 | |
|   assert_success
 | |
| 
 | |
|   assert_output --partial 'NEW DEPLOY OVERVIEW'
 | |
|   assert_output --partial "CURRENT DEPLOYMENT    N/A"
 | |
|   assert_output --partial "ENV VERSION           ${latestRelease}"
 | |
|   assert_output --partial "NEW DEPLOYMENT        ${headHash:0:8}"
 | |
| 
 | |
|   run bash -c 'echo "unstaged changes" >> "$ABRA_DIR/recipes/$TEST_RECIPE/foo"'
 | |
|   assert_success
 | |
|   assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks --chaos
 | |
|   assert_success
 | |
| 
 | |
|   assert_output --partial 'CHAOS DEPLOY OVERVIEW'
 | |
|   assert_output --partial "CURRENT DEPLOYMENT    ${headHash:0:8}"
 | |
|   assert_output --partial "ENV VERSION           ${headHash:0:8}"
 | |
|   assert_output --partial "NEW DEPLOYMENT        ${headHash:0:8}+U"
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks --chaos
 | |
|   assert_success
 | |
| 
 | |
|   assert_output --partial 'CHAOS DEPLOY OVERVIEW'
 | |
|   assert_output --partial "CURRENT DEPLOYMENT    ${headHash:0:8}+U"
 | |
|   assert_output --partial "ENV VERSION           ${headHash:0:8}+U"
 | |
|   assert_output --partial "NEW DEPLOYMENT        ${headHash:0:8}+U"
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks --chaos
 | |
|   assert_success
 | |
| 
 | |
|   assert_output --partial 'CHAOS DEPLOY OVERVIEW'
 | |
|   assert_output --partial "CURRENT DEPLOYMENT    ${headHash:0:8}+U"
 | |
|   assert_output --partial "ENV VERSION           ${headHash:0:8}+U"
 | |
|   assert_output --partial "NEW DEPLOYMENT        ${headHash:0:8}+U"
 | |
| 
 | |
|   run grep -q "TYPE=$TEST_RECIPE:${headHash:0:8}" \
 | |
|     "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
 | |
|   assert_success
 | |
| 
 | |
|   run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
 | |
|   assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
 | |
| }
 | |
| 
 | |
| @test "hash deploy then force deploy" {
 | |
|   headHash=$(_get_head_hash)
 | |
|   latestRelease=$(_latest_release)
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" "${headHash:0:8}" \
 | |
|     --no-input --no-converge-checks
 | |
|   assert_success
 | |
| 
 | |
|   run $ABRA app deploy "$TEST_APP_DOMAIN" \
 | |
|     --no-input --no-converge-checks --force
 | |
|   assert_success
 | |
| 
 | |
|   assert_output --partial 'REDEPLOY OVERVIEW'
 | |
|   assert_output --partial "CURRENT DEPLOYMENT    ${headHash:0:8}"
 | |
|   assert_output --partial "ENV VERSION           ${headHash:0:8}"
 | |
|   assert_output --partial "NEW DEPLOYMENT        ${headHash:0:8}"
 | |
| }
 |