diff --git a/cli/app/deploy.go b/cli/app/deploy.go index 5d91f704..8ae945e8 100644 --- a/cli/app/deploy.go +++ b/cli/app/deploy.go @@ -179,7 +179,9 @@ checkout as-is. Recipe commit hashes are also supported as values for appPkg.ExposeAllEnv(stackName, compose, app.Env) appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name) appPkg.SetChaosLabel(compose, stackName, internal.Chaos) - appPkg.SetChaosVersionLabel(compose, stackName, toDeployChaosVersionLabel) + if internal.Chaos { + appPkg.SetChaosVersionLabel(compose, stackName, toDeployChaosVersionLabel) + } appPkg.SetUpdateLabel(compose, stackName, app.Env) envVars, err := appPkg.CheckEnv(app) diff --git a/cli/app/rollback.go b/cli/app/rollback.go index 9213562d..9adc854e 100644 --- a/cli/app/rollback.go +++ b/cli/app/rollback.go @@ -178,7 +178,9 @@ beforehand. See "abra app backup" for more.`, appPkg.ExposeAllEnv(stackName, compose, app.Env) appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name) appPkg.SetChaosLabel(compose, stackName, internal.Chaos) - appPkg.SetChaosVersionLabel(compose, stackName, chosenDowngrade) + if internal.Chaos { + appPkg.SetChaosVersionLabel(compose, stackName, chosenDowngrade) + } appPkg.SetUpdateLabel(compose, stackName, app.Env) chaosVersion := config.CHAOS_DEFAULT diff --git a/cli/app/upgrade.go b/cli/app/upgrade.go index 6d8ec37c..ce116c04 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -183,7 +183,9 @@ beforehand. See "abra app backup" for more.`, appPkg.ExposeAllEnv(stackName, compose, app.Env) appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name) appPkg.SetChaosLabel(compose, stackName, internal.Chaos) - appPkg.SetChaosVersionLabel(compose, stackName, chosenUpgrade) + if internal.Chaos { + appPkg.SetChaosVersionLabel(compose, stackName, chosenUpgrade) + } appPkg.SetUpdateLabel(compose, stackName, app.Env) envVars, err := appPkg.CheckEnv(app) diff --git a/cli/internal/deploy.go b/cli/internal/deploy.go index 3d895128..b4a369ff 100644 --- a/cli/internal/deploy.go +++ b/cli/internal/deploy.go @@ -64,6 +64,15 @@ func NewVersionOverview( upperKind := strings.ToUpper(kind) + envVersion, err := recipe.GetEnvVersionRaw(app.Recipe.Name) + if err != nil { + return err + } + + if envVersion == "" { + envVersion = config.NO_VERSION_DEFAULT + } + rows := [][]string{ {"DOMAIN", domain}, {"RECIPE", app.Recipe.Name}, @@ -78,7 +87,7 @@ func NewVersionOverview( {"VERSION", formatter.BoldDirtyDefault(toDeployVersion)}, {fmt.Sprintf("%s.ENV", strings.ToUpper(app.Domain)), "---"}, - {"CURRENT VERSION", formatter.BoldDirtyDefault(app.Recipe.EnvVersion)}, + {"CURRENT VERSION", formatter.BoldDirtyDefault(envVersion)}, {"NEW VERSION", formatter.BoldDirtyDefault(toDeployVersion)}, } diff --git a/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index c2626628..3c1aa0f9 100644 --- a/tests/integration/app_deploy.bats +++ b/tests/integration/app_deploy.bats @@ -21,8 +21,8 @@ setup(){ teardown(){ _reset_recipe - _reset_app _undeploy_app + _reset_app _reset_tags run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" @@ -429,3 +429,12 @@ teardown(){ assert_success assert_output --partial "$latestRelease" } + +# bats test_tags=slow +@test "no chaos version label if no chaos" { + _deploy_app + + run $ABRA app labels "$TEST_APP_DOMAIN" --no-input + assert_success + refute_output --regexp "coop-cloud.abra-test-recipe.$TEST_SERVER.chaos-version" +} diff --git a/tests/integration/app_deploy_overview.bats b/tests/integration/app_deploy_overview.bats index baca1376..ce5b91b8 100644 --- a/tests/integration/app_deploy_overview.bats +++ b/tests/integration/app_deploy_overview.bats @@ -20,8 +20,8 @@ setup(){ teardown(){ _reset_recipe - _reset_app _undeploy_app + _reset_app _reset_tags run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" diff --git a/tests/integration/app_env.bats b/tests/integration/app_env.bats index 81733efa..8bb55c10 100644 --- a/tests/integration/app_env.bats +++ b/tests/integration/app_env.bats @@ -20,8 +20,8 @@ setup(){ teardown(){ _reset_recipe - _reset_app _undeploy_app + _reset_app run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" diff --git a/tests/integration/app_labels.bats b/tests/integration/app_labels.bats index b5b22d23..ad8abb21 100644 --- a/tests/integration/app_labels.bats +++ b/tests/integration/app_labels.bats @@ -21,8 +21,8 @@ setup(){ teardown(){ _reset_recipe - _reset_app _undeploy_app + _reset_app _reset_tags run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" diff --git a/tests/integration/app_rollback.bats b/tests/integration/app_rollback.bats index b4d30b20..ac29270d 100644 --- a/tests/integration/app_rollback.bats +++ b/tests/integration/app_rollback.bats @@ -19,6 +19,7 @@ setup(){ } teardown(){ + _reset_app _undeploy_app _reset_recipe } @@ -185,3 +186,16 @@ teardown(){ assert_failure assert_output --partial "not a known version" } + +# bats test_tags=slow +@test "no chaos version label if no chaos" { + _deploy_app + + run $ABRA app rollback "$TEST_APP_DOMAIN" \ + --no-input --no-converge-checks + assert_success + + run $ABRA app labels "$TEST_APP_DOMAIN" --no-input + assert_success + refute_output --regexp "coop-cloud.abra-test-recipe.$TEST_SERVER.chaos-version" +} diff --git a/tests/integration/app_rollback_overview.bats b/tests/integration/app_rollback_overview.bats index 9a739bfa..2111c9ca 100644 --- a/tests/integration/app_rollback_overview.bats +++ b/tests/integration/app_rollback_overview.bats @@ -20,6 +20,7 @@ setup(){ teardown(){ _undeploy_app + _reset_app _reset_recipe } @@ -36,9 +37,8 @@ teardown(){ assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" assert_output --regexp 'CHAOS.*false' - # new deployment + # rollback assert_output --regexp 'VERSION.*' + "0.1.0+1.20.0" - assert_output --regexp 'CHAOS.*false' # env version assert_output --regexp 'CURRENT VERSION.*' + "0.2.0+1.21.0" @@ -62,9 +62,8 @@ teardown(){ assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" assert_output --regexp 'CHAOS.*false' - # new deployment + # rollback assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" - assert_output --regexp 'CHAOS.*false' # env version assert_output --regexp 'CURRENT VERSION.*' + "0.2.0+1.21.0" @@ -74,3 +73,30 @@ teardown(){ "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" assert_success } + +@test "app rollback no .env version" { + run $ABRA app deploy "$TEST_APP_DOMAIN" "0.2.0+1.21.0" \ + --no-input --no-converge-checks + assert_success + + _wipe_env_version + + run $ABRA app rollback "$TEST_APP_DOMAIN" "0.1.0+1.20.0" \ + --no-input --no-converge-checks + assert_success + + # current deployment + assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" + assert_output --regexp 'CHAOS.*false' + + # rollback + assert_output --regexp 'VERSION.*' + "0.1.0+1.20.0" + + # env version + assert_output --regexp 'CURRENT VERSION.*N/A' + assert_output --regexp 'NEW VERSION.*' + "0.2.0+1.21.0" + + run grep -q "TYPE=$TEST_RECIPE:${latestRelease}" \ + "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" + assert_success +} diff --git a/tests/integration/app_upgrade.bats b/tests/integration/app_upgrade.bats index 8e3c0b2e..100f33ad 100644 --- a/tests/integration/app_upgrade.bats +++ b/tests/integration/app_upgrade.bats @@ -239,3 +239,16 @@ teardown(){ assert_failure assert_output --partial "not a known version" } + +# bats test_tags=slow +@test "no chaos version label if no chaos" { + _deploy_app + + run $ABRA app upgrade "$TEST_APP_DOMAIN" \ + --no-input --no-converge-checks + assert_success + + run $ABRA app labels "$TEST_APP_DOMAIN" --no-input + assert_success + refute_output --regexp "coop-cloud.abra-test-recipe.$TEST_SERVER.chaos-version" +} diff --git a/tests/integration/app_upgrade_overview.bats b/tests/integration/app_upgrade_overview.bats index a6bbc189..4b906b90 100644 --- a/tests/integration/app_upgrade_overview.bats +++ b/tests/integration/app_upgrade_overview.bats @@ -35,7 +35,7 @@ teardown(){ assert_output --regexp 'VERSION.*' + "0.1.0+1.20.0" assert_output --regexp 'CHAOS.*false' - # new deployment + # upgrade assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" assert_output --regexp 'CHAOS.*false' @@ -61,7 +61,7 @@ teardown(){ assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" assert_output --regexp 'CHAOS.*false' - # new deployment + # upgrade assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" assert_output --regexp 'CHAOS.*false' @@ -73,3 +73,33 @@ teardown(){ "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" assert_success } + +@test "app upgrade no .env version" { + latestRelease=$(_latest_release) + + run $ABRA app deploy "$TEST_APP_DOMAIN" "0.2.0+1.21.0" \ + --no-input --no-converge-checks + assert_success + + _wipe_env_version + + run $ABRA app upgrade "$TEST_APP_DOMAIN" \ + --no-input --no-converge-checks --force + assert_success + + # current deployment + assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" + assert_output --regexp 'CHAOS.*false' + + # upgrade + assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" + assert_output --regexp 'CHAOS.*false' + + # env version + assert_output --regexp 'CURRENT VERSION.*N/A' + assert_output --regexp 'NEW VERSION.*' + "0.2.0+1.21.0" + + run grep -q "TYPE=$TEST_RECIPE:${latestRelease}" \ + "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" + assert_success +}