From eb6fe4ba6e5bdd222eea53b9847bc2bb9e5f429d Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 9 Jan 2025 11:34:38 +0100 Subject: [PATCH 1/4] fix: dont set chaos label if no chaos See https://git.coopcloud.tech/toolshed/abra/issues/478 --- cli/app/deploy.go | 4 +++- cli/app/rollback.go | 4 +++- cli/app/upgrade.go | 4 +++- tests/integration/app_deploy.bats | 9 +++++++++ tests/integration/app_rollback.bats | 13 +++++++++++++ tests/integration/app_upgrade.bats | 13 +++++++++++++ 6 files changed, 44 insertions(+), 3 deletions(-) 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/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index c2626628..fd67fe7b 100644 --- a/tests/integration/app_deploy.bats +++ b/tests/integration/app_deploy.bats @@ -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_rollback.bats b/tests/integration/app_rollback.bats index b4d30b20..8658caa3 100644 --- a/tests/integration/app_rollback.bats +++ b/tests/integration/app_rollback.bats @@ -185,3 +185,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_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" +} -- 2.47.2 From ed263854d47828efb5f99aded8c563613f0a0ab2 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 9 Jan 2025 11:35:41 +0100 Subject: [PATCH 2/4] fix: show N/A if env version unknown See https://git.coopcloud.tech/toolshed/abra/issues/478 --- cli/internal/deploy.go | 11 ++++++- tests/integration/app_rollback.bats | 1 + tests/integration/app_rollback_overview.bats | 28 ++++++++++++++++++ tests/integration/app_upgrade_overview.bats | 30 ++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) 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_rollback.bats b/tests/integration/app_rollback.bats index 8658caa3..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 } diff --git a/tests/integration/app_rollback_overview.bats b/tests/integration/app_rollback_overview.bats index 9a739bfa..5f652980 100644 --- a/tests/integration/app_rollback_overview.bats +++ b/tests/integration/app_rollback_overview.bats @@ -19,6 +19,7 @@ setup(){ } teardown(){ + _reset_app _undeploy_app _reset_recipe } @@ -74,3 +75,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_overview.bats b/tests/integration/app_upgrade_overview.bats index a6bbc189..826ccc18 100644 --- a/tests/integration/app_upgrade_overview.bats +++ b/tests/integration/app_upgrade_overview.bats @@ -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 +} -- 2.47.2 From 086b4828ffa97ee529c9f73655816871a6c078f8 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 9 Jan 2025 11:35:58 +0100 Subject: [PATCH 3/4] docs: better comments, remove redundant output check --- tests/integration/app_rollback_overview.bats | 6 ++---- tests/integration/app_upgrade_overview.bats | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/integration/app_rollback_overview.bats b/tests/integration/app_rollback_overview.bats index 5f652980..9690c31c 100644 --- a/tests/integration/app_rollback_overview.bats +++ b/tests/integration/app_rollback_overview.bats @@ -37,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" @@ -63,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" diff --git a/tests/integration/app_upgrade_overview.bats b/tests/integration/app_upgrade_overview.bats index 826ccc18..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' -- 2.47.2 From 41e514ae9ad2d606ada43fb61a783ef519510095 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 9 Jan 2025 11:48:35 +0100 Subject: [PATCH 4/4] test: reset after deploy --- tests/integration/app_deploy.bats | 2 +- tests/integration/app_deploy_overview.bats | 2 +- tests/integration/app_env.bats | 2 +- tests/integration/app_labels.bats | 2 +- tests/integration/app_rollback_overview.bats | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index fd67fe7b..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" 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_overview.bats b/tests/integration/app_rollback_overview.bats index 9690c31c..2111c9ca 100644 --- a/tests/integration/app_rollback_overview.bats +++ b/tests/integration/app_rollback_overview.bats @@ -19,8 +19,8 @@ setup(){ } teardown(){ - _reset_app _undeploy_app + _reset_app _reset_recipe } -- 2.47.2