fix: don't always set chaos label, missing .env version N/A handling #479

Merged
decentral1se merged 4 commits from upgrade-old-version-fix into main 2025-01-09 11:03:39 +00:00
12 changed files with 121 additions and 14 deletions

View File

@ -179,7 +179,9 @@ checkout as-is. Recipe commit hashes are also supported as values for
appPkg.ExposeAllEnv(stackName, compose, app.Env) appPkg.ExposeAllEnv(stackName, compose, app.Env)
appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name) appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name)
appPkg.SetChaosLabel(compose, stackName, internal.Chaos) 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) appPkg.SetUpdateLabel(compose, stackName, app.Env)
envVars, err := appPkg.CheckEnv(app) envVars, err := appPkg.CheckEnv(app)

View File

@ -178,7 +178,9 @@ beforehand. See "abra app backup" for more.`,
appPkg.ExposeAllEnv(stackName, compose, app.Env) appPkg.ExposeAllEnv(stackName, compose, app.Env)
appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name) appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name)
appPkg.SetChaosLabel(compose, stackName, internal.Chaos) 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) appPkg.SetUpdateLabel(compose, stackName, app.Env)
chaosVersion := config.CHAOS_DEFAULT chaosVersion := config.CHAOS_DEFAULT

View File

@ -183,7 +183,9 @@ beforehand. See "abra app backup" for more.`,
appPkg.ExposeAllEnv(stackName, compose, app.Env) appPkg.ExposeAllEnv(stackName, compose, app.Env)
appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name) appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name)
appPkg.SetChaosLabel(compose, stackName, internal.Chaos) 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) appPkg.SetUpdateLabel(compose, stackName, app.Env)
envVars, err := appPkg.CheckEnv(app) envVars, err := appPkg.CheckEnv(app)

View File

@ -64,6 +64,15 @@ func NewVersionOverview(
upperKind := strings.ToUpper(kind) 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{ rows := [][]string{
{"DOMAIN", domain}, {"DOMAIN", domain},
{"RECIPE", app.Recipe.Name}, {"RECIPE", app.Recipe.Name},
@ -78,7 +87,7 @@ func NewVersionOverview(
{"VERSION", formatter.BoldDirtyDefault(toDeployVersion)}, {"VERSION", formatter.BoldDirtyDefault(toDeployVersion)},
{fmt.Sprintf("%s.ENV", strings.ToUpper(app.Domain)), "---"}, {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)}, {"NEW VERSION", formatter.BoldDirtyDefault(toDeployVersion)},
} }

View File

@ -21,8 +21,8 @@ setup(){
teardown(){ teardown(){
_reset_recipe _reset_recipe
_reset_app
_undeploy_app _undeploy_app
_reset_app
_reset_tags _reset_tags
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
@ -429,3 +429,12 @@ teardown(){
assert_success assert_success
assert_output --partial "$latestRelease" 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"
}

View File

@ -20,8 +20,8 @@ setup(){
teardown(){ teardown(){
_reset_recipe _reset_recipe
_reset_app
_undeploy_app _undeploy_app
_reset_app
_reset_tags _reset_tags
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"

View File

@ -20,8 +20,8 @@ setup(){
teardown(){ teardown(){
_reset_recipe _reset_recipe
_reset_app
_undeploy_app _undeploy_app
_reset_app
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"

View File

@ -21,8 +21,8 @@ setup(){
teardown(){ teardown(){
_reset_recipe _reset_recipe
_reset_app
_undeploy_app _undeploy_app
_reset_app
_reset_tags _reset_tags
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"

View File

@ -19,6 +19,7 @@ setup(){
} }
teardown(){ teardown(){
_reset_app
_undeploy_app _undeploy_app
_reset_recipe _reset_recipe
} }
@ -185,3 +186,16 @@ teardown(){
assert_failure assert_failure
assert_output --partial "not a known version" 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"
}

View File

@ -20,6 +20,7 @@ setup(){
teardown(){ teardown(){
_undeploy_app _undeploy_app
_reset_app
_reset_recipe _reset_recipe
} }
@ -36,9 +37,8 @@ teardown(){
assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0"
assert_output --regexp 'CHAOS.*false' assert_output --regexp 'CHAOS.*false'
# new deployment # rollback
assert_output --regexp 'VERSION.*' + "0.1.0+1.20.0" assert_output --regexp 'VERSION.*' + "0.1.0+1.20.0"
assert_output --regexp 'CHAOS.*false'
# env version # env version
assert_output --regexp 'CURRENT VERSION.*' + "0.2.0+1.21.0" 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 'VERSION.*' + "0.2.0+1.21.0"
assert_output --regexp 'CHAOS.*false' assert_output --regexp 'CHAOS.*false'
# new deployment # rollback
assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0"
assert_output --regexp 'CHAOS.*false'
# env version # env version
assert_output --regexp 'CURRENT VERSION.*' + "0.2.0+1.21.0" 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" "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_success 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
}

View File

@ -239,3 +239,16 @@ teardown(){
assert_failure assert_failure
assert_output --partial "not a known version" 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"
}

View File

@ -35,7 +35,7 @@ teardown(){
assert_output --regexp 'VERSION.*' + "0.1.0+1.20.0" assert_output --regexp 'VERSION.*' + "0.1.0+1.20.0"
assert_output --regexp 'CHAOS.*false' assert_output --regexp 'CHAOS.*false'
# new deployment # upgrade
assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0"
assert_output --regexp 'CHAOS.*false' assert_output --regexp 'CHAOS.*false'
@ -61,7 +61,7 @@ teardown(){
assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0"
assert_output --regexp 'CHAOS.*false' assert_output --regexp 'CHAOS.*false'
# new deployment # upgrade
assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0" assert_output --regexp 'VERSION.*' + "0.2.0+1.21.0"
assert_output --regexp 'CHAOS.*false' assert_output --regexp 'CHAOS.*false'
@ -73,3 +73,33 @@ teardown(){
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_success 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
}