fix: env version fixups #441
@ -71,7 +71,6 @@ steps:
|
|||||||
port: 22
|
port: 22
|
||||||
command_timeout: 60m
|
command_timeout: 60m
|
||||||
script_stop: true
|
script_stop: true
|
||||||
envs: [ DRONE_SOURCE_BRANCH ]
|
|
||||||
request_pty: true
|
request_pty: true
|
||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"coopcloud.tech/abra/cli/internal"
|
"coopcloud.tech/abra/cli/internal"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
|
"coopcloud.tech/abra/pkg/config"
|
||||||
"coopcloud.tech/abra/pkg/envfile"
|
"coopcloud.tech/abra/pkg/envfile"
|
||||||
"coopcloud.tech/abra/pkg/secret"
|
"coopcloud.tech/abra/pkg/secret"
|
||||||
|
|
||||||
@ -54,13 +55,15 @@ EXAMPLE:
|
|||||||
stackName := app.StackName()
|
stackName := app.StackName()
|
||||||
|
|
||||||
specificVersion := c.Args().Get(1)
|
specificVersion := c.Args().Get(1)
|
||||||
if specificVersion == "" {
|
|
||||||
specificVersion = app.Recipe.Version
|
|
||||||
}
|
|
||||||
if specificVersion != "" && internal.Chaos {
|
if specificVersion != "" && internal.Chaos {
|
||||||
log.Fatal("cannot use <version> and --chaos together")
|
log.Fatal("cannot use <version> and --chaos together")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if specificVersion == "" && app.Recipe.Version != "" {
|
||||||
|
log.Debugf("retrieved %s as version from env file", app.Recipe.Version)
|
||||||
|
specificVersion = app.Recipe.Version
|
||||||
|
}
|
||||||
|
|
||||||
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -146,7 +149,7 @@ EXAMPLE:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
chaosVersion := "false"
|
chaosVersion := config.CHAOS_DEFAULT
|
||||||
if internal.Chaos {
|
if internal.Chaos {
|
||||||
warnMessages = append(warnMessages, "chaos mode engaged")
|
warnMessages = append(warnMessages, "chaos mode engaged")
|
||||||
|
|
||||||
@ -245,12 +248,15 @@ EXAMPLE:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.Recipe.Version != "" && specificVersion != "" && specificVersion != app.Recipe.Version {
|
app.Recipe.Version = version
|
||||||
err := app.WriteRecipeVersion(specificVersion)
|
if chaosVersion != config.CHAOS_DEFAULT {
|
||||||
if err != nil {
|
app.Recipe.Version = chaosVersion
|
||||||
log.Fatalf("writing new recipe version in env file: %s", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
log.Debugf("choosing %s as version to save to env file", app.Recipe.Version)
|
||||||
|
if err := app.WriteRecipeVersion(app.Recipe.Version); err != nil {
|
||||||
|
log.Fatalf("writing new recipe version in env file: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"coopcloud.tech/abra/cli/internal"
|
"coopcloud.tech/abra/cli/internal"
|
||||||
|
"coopcloud.tech/abra/pkg/app"
|
||||||
appPkg "coopcloud.tech/abra/pkg/app"
|
appPkg "coopcloud.tech/abra/pkg/app"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
"coopcloud.tech/abra/pkg/client"
|
"coopcloud.tech/abra/pkg/client"
|
||||||
@ -28,6 +29,8 @@ deploy <domain>" to do so.
|
|||||||
You can see what recipes are available (i.e. values for the <recipe> argument)
|
You can see what recipes are available (i.e. values for the <recipe> argument)
|
||||||
by running "abra recipe ls".
|
by running "abra recipe ls".
|
||||||
|
|
||||||
|
Recipe commit hashes are supported values for "[<version>]".
|
||||||
|
|
||||||
Passing the "--secrets/-S" flag will automatically generate secrets for your
|
Passing the "--secrets/-S" flag will automatically generate secrets for your
|
||||||
app and store them encrypted at rest on the chosen target server. These
|
app and store them encrypted at rest on the chosen target server. These
|
||||||
generated secrets are only visible at generation time, so please take care to
|
generated secrets are only visible at generation time, so please take care to
|
||||||
@ -66,6 +69,7 @@ var appNewCommand = cli.Command{
|
|||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
recipe := internal.ValidateRecipe(c)
|
recipe := internal.ValidateRecipe(c)
|
||||||
|
|
||||||
|
var version string
|
||||||
if !internal.Chaos {
|
if !internal.Chaos {
|
||||||
if err := recipe.EnsureIsClean(); err != nil {
|
if err := recipe.EnsureIsClean(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -75,16 +79,13 @@ var appNewCommand = cli.Command{
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c.Args().Get(1) == "" {
|
|
||||||
var version string
|
|
||||||
|
|
||||||
|
if c.Args().Get(1) == "" {
|
||||||
recipeVersions, err := recipe.GetRecipeVersions()
|
recipeVersions, err := recipe.GetRecipeVersions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(d1): determine whether recipe versions exist or not and check
|
|
||||||
// out the latest version or current HEAD
|
|
||||||
if len(recipeVersions) > 0 {
|
if len(recipeVersions) > 0 {
|
||||||
latest := recipeVersions[len(recipeVersions)-1]
|
latest := recipeVersions[len(recipeVersions)-1]
|
||||||
for tag := range latest {
|
for tag := range latest {
|
||||||
@ -100,7 +101,8 @@ var appNewCommand = cli.Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if _, err := recipe.EnsureVersion(c.Args().Get(1)); err != nil {
|
version = c.Args().Get(1)
|
||||||
|
if _, err := recipe.EnsureVersion(version); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,10 +182,10 @@ var appNewCommand = cli.Command{
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
headers := []string{"SERVER", "RECIPE", "DOMAIN"}
|
headers := []string{"SERVER", "DOMAIN", "RECIPE", "VERSION"}
|
||||||
table.Headers(headers...)
|
table.Headers(headers...)
|
||||||
|
|
||||||
table.Row(internal.NewAppServer, recipe.Name, internal.Domain)
|
table.Row(internal.NewAppServer, internal.Domain, recipe.Name, version)
|
||||||
|
|
||||||
log.Infof("new app '%s' created 🌞", recipe.Name)
|
log.Infof("new app '%s' created 🌞", recipe.Name)
|
||||||
|
|
||||||
@ -211,6 +213,16 @@ var appNewCommand = cli.Command{
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app, err := app.Get(internal.Domain)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("choosing %s as version to save to env file", version)
|
||||||
|
if err := app.WriteRecipeVersion(version); err != nil {
|
||||||
|
log.Fatalf("writing new recipe version in env file: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
appPkg "coopcloud.tech/abra/pkg/app"
|
appPkg "coopcloud.tech/abra/pkg/app"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
"coopcloud.tech/abra/pkg/client"
|
"coopcloud.tech/abra/pkg/client"
|
||||||
|
"coopcloud.tech/abra/pkg/config"
|
||||||
"coopcloud.tech/abra/pkg/formatter"
|
"coopcloud.tech/abra/pkg/formatter"
|
||||||
"coopcloud.tech/abra/pkg/log"
|
"coopcloud.tech/abra/pkg/log"
|
||||||
abraService "coopcloud.tech/abra/pkg/service"
|
abraService "coopcloud.tech/abra/pkg/service"
|
||||||
@ -52,7 +53,7 @@ var appPsCommand = cli.Command{
|
|||||||
log.Fatalf("%s is not deployed?", app.Name)
|
log.Fatalf("%s is not deployed?", app.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
chaosVersion := "false"
|
chaosVersion := config.CHAOS_DEFAULT
|
||||||
statuses, err := appPkg.GetAppStatuses([]appPkg.App{app}, true)
|
statuses, err := appPkg.GetAppStatuses([]appPkg.App{app}, true)
|
||||||
if statusMeta, ok := statuses[app.StackName()]; ok {
|
if statusMeta, ok := statuses[app.StackName()]; ok {
|
||||||
isChaos, exists := statusMeta["chaos"]
|
isChaos, exists := statusMeta["chaos"]
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
appPkg "coopcloud.tech/abra/pkg/app"
|
appPkg "coopcloud.tech/abra/pkg/app"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
|
"coopcloud.tech/abra/pkg/config"
|
||||||
"coopcloud.tech/abra/pkg/envfile"
|
"coopcloud.tech/abra/pkg/envfile"
|
||||||
"coopcloud.tech/abra/pkg/lint"
|
"coopcloud.tech/abra/pkg/lint"
|
||||||
stack "coopcloud.tech/abra/pkg/upstream/stack"
|
stack "coopcloud.tech/abra/pkg/upstream/stack"
|
||||||
@ -197,7 +198,7 @@ EXAMPLE:
|
|||||||
appPkg.SetChaosVersionLabel(compose, stackName, chosenDowngrade)
|
appPkg.SetChaosVersionLabel(compose, stackName, chosenDowngrade)
|
||||||
appPkg.SetUpdateLabel(compose, stackName, app.Env)
|
appPkg.SetUpdateLabel(compose, stackName, app.Env)
|
||||||
|
|
||||||
chaosVersion := "false"
|
chaosVersion := config.CHAOS_DEFAULT
|
||||||
if deployMeta.IsChaos {
|
if deployMeta.IsChaos {
|
||||||
chaosVersion = deployMeta.ChaosVersion
|
chaosVersion = deployMeta.ChaosVersion
|
||||||
}
|
}
|
||||||
@ -218,11 +219,10 @@ EXAMPLE:
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.Recipe.Version != "" {
|
app.Recipe.Version = chosenDowngrade
|
||||||
err := app.WriteRecipeVersion(chosenDowngrade)
|
log.Debugf("choosing %s as version to save to env file", app.Recipe.Version)
|
||||||
if err != nil {
|
if err := app.WriteRecipeVersion(app.Recipe.Version); err != nil {
|
||||||
log.Fatalf("writing new recipe version in env file: %s", err)
|
log.Fatalf("writing new recipe version in env file: %s", err)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
appPkg "coopcloud.tech/abra/pkg/app"
|
appPkg "coopcloud.tech/abra/pkg/app"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
"coopcloud.tech/abra/pkg/client"
|
"coopcloud.tech/abra/pkg/client"
|
||||||
|
"coopcloud.tech/abra/pkg/config"
|
||||||
"coopcloud.tech/abra/pkg/formatter"
|
"coopcloud.tech/abra/pkg/formatter"
|
||||||
"coopcloud.tech/abra/pkg/log"
|
"coopcloud.tech/abra/pkg/log"
|
||||||
stack "coopcloud.tech/abra/pkg/upstream/stack"
|
stack "coopcloud.tech/abra/pkg/upstream/stack"
|
||||||
@ -102,7 +103,7 @@ Passing "-p/--prune" does not remove those volumes.`,
|
|||||||
log.Fatalf("%s is not deployed?", app.Name)
|
log.Fatalf("%s is not deployed?", app.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
chaosVersion := "false"
|
chaosVersion := config.CHAOS_DEFAULT
|
||||||
if deployMeta.IsChaos {
|
if deployMeta.IsChaos {
|
||||||
chaosVersion = deployMeta.ChaosVersion
|
chaosVersion = deployMeta.ChaosVersion
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
appPkg "coopcloud.tech/abra/pkg/app"
|
appPkg "coopcloud.tech/abra/pkg/app"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
"coopcloud.tech/abra/pkg/client"
|
"coopcloud.tech/abra/pkg/client"
|
||||||
|
"coopcloud.tech/abra/pkg/config"
|
||||||
"coopcloud.tech/abra/pkg/envfile"
|
"coopcloud.tech/abra/pkg/envfile"
|
||||||
"coopcloud.tech/abra/pkg/lint"
|
"coopcloud.tech/abra/pkg/lint"
|
||||||
"coopcloud.tech/abra/pkg/log"
|
"coopcloud.tech/abra/pkg/log"
|
||||||
@ -244,7 +245,7 @@ EXAMPLE:
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
chaosVersion := "false"
|
chaosVersion := config.CHAOS_DEFAULT
|
||||||
if deployMeta.IsChaos {
|
if deployMeta.IsChaos {
|
||||||
chaosVersion = deployMeta.ChaosVersion
|
chaosVersion = deployMeta.ChaosVersion
|
||||||
}
|
}
|
||||||
@ -278,11 +279,10 @@ EXAMPLE:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.Recipe.Version != "" {
|
app.Recipe.Version = chosenUpgrade
|
||||||
err := app.WriteRecipeVersion(chosenUpgrade)
|
log.Debugf("choosing %s as version to save to env file", app.Recipe.Version)
|
||||||
if err != nil {
|
if err := app.WriteRecipeVersion(app.Recipe.Version); err != nil {
|
||||||
log.Fatalf("writing new recipe version in env file: %s", err)
|
log.Fatalf("writing new recipe version in env file: %s", err)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -85,6 +85,7 @@ var recipeVersionCommand = cli.Command{
|
|||||||
if !internal.MachineReadable {
|
if !internal.MachineReadable {
|
||||||
fmt.Println(table)
|
fmt.Println(table)
|
||||||
log.Infof("VERSION: %s", version)
|
log.Infof("VERSION: %s", version)
|
||||||
|
fmt.Println()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -584,6 +584,12 @@ func (a App) WriteRecipeVersion(version string) error {
|
|||||||
lines = append(lines, line)
|
lines = append(lines, line)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(line, "#") {
|
||||||
|
lines = append(lines, line)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
splitted := strings.Split(line, ":")
|
splitted := strings.Split(line, ":")
|
||||||
line = fmt.Sprintf("%s:%s", splitted[0], version)
|
line = fmt.Sprintf("%s:%s", splitted[0], version)
|
||||||
lines = append(lines, line)
|
lines = append(lines, line)
|
||||||
|
@ -107,4 +107,5 @@ var (
|
|||||||
REPOS_BASE_URL = "https://git.coopcloud.tech/coop-cloud"
|
REPOS_BASE_URL = "https://git.coopcloud.tech/coop-cloud"
|
||||||
CATALOGUE_JSON_REPO_NAME = "recipes-catalogue-json"
|
CATALOGUE_JSON_REPO_NAME = "recipes-catalogue-json"
|
||||||
SSH_URL_TEMPLATE = "ssh://git@git.coopcloud.tech:2222/coop-cloud/%s.git"
|
SSH_URL_TEMPLATE = "ssh://git@git.coopcloud.tech:2222/coop-cloud/%s.git"
|
||||||
|
CHAOS_DEFAULT = "false"
|
||||||
)
|
)
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
# destroys resources on the swarm server you run it against. This is for
|
# destroys resources on the swarm server you run it against. This is for
|
||||||
# setup/teardown for the integration test suite.
|
# setup/teardown for the integration test suite.
|
||||||
#
|
#
|
||||||
# export DRONE_SOURCE_BRANCH=<your-branch-name>
|
|
||||||
# ./run-ci-int
|
# ./run-ci-int
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
@ -45,17 +44,7 @@ echo "========================================================================"
|
|||||||
rm -rf abra
|
rm -rf abra
|
||||||
git clone ssh://git@git.coopcloud.tech:2222/coop-cloud/abra.git
|
git clone ssh://git@git.coopcloud.tech:2222/coop-cloud/abra.git
|
||||||
cd abra
|
cd abra
|
||||||
echo "========================================================================"
|
git checkout main
|
||||||
|
|
||||||
echo "========================================================================"
|
|
||||||
echo "FETCHING ABRA BRANCH FOR TESTING"
|
|
||||||
echo "========================================================================"
|
|
||||||
if [ -z "$DRONE_SOURCE_BRANCH" ]; then
|
|
||||||
DRONE_SOURCE_BRANCH="main"
|
|
||||||
fi
|
|
||||||
|
|
||||||
git fetch --all
|
|
||||||
git checkout $DRONE_SOURCE_BRANCH
|
|
||||||
echo "========================================================================"
|
echo "========================================================================"
|
||||||
|
|
||||||
echo "========================================================================"
|
echo "========================================================================"
|
||||||
|
@ -355,34 +355,3 @@ teardown(){
|
|||||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all --chaos
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all --chaos
|
||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
# bats test_tags=slow
|
|
||||||
@test "deploy chaos commit" {
|
|
||||||
tagHash=$(_get_tag_hash "0.1.0+1.20.0")
|
|
||||||
|
|
||||||
run $ABRA app deploy "$TEST_APP_DOMAIN" "$tagHash" --no-input --no-converge-checks
|
|
||||||
assert_success
|
|
||||||
assert_output --partial 'chaos mode'
|
|
||||||
}
|
|
||||||
|
|
||||||
# bats test_tags=slow
|
|
||||||
@test "deploy remote recipe" {
|
|
||||||
run sed -i 's/TYPE=abra-test-recipe/RECIPE=git.coopcloud.tech\/coop-cloud\/abra-test-recipe/g' \
|
|
||||||
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
|
||||||
assert_success
|
|
||||||
assert_output --partial "git.coopcloud.tech/coop-cloud/abra-test-recipe"
|
|
||||||
}
|
|
||||||
|
|
||||||
# bats test_tags=slow
|
|
||||||
@test "deploy remote recipe with version" {
|
|
||||||
run sed -i 's/TYPE=abra-test-recipe/RECIPE=git.coopcloud.tech\/coop-cloud\/abra-test-recipe:0.2.0+1.21.0/g' \
|
|
||||||
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
|
||||||
assert_success
|
|
||||||
assert_output --partial '0.2.0+1.21.0'
|
|
||||||
}
|
|
||||||
|
80
tests/integration/app_deploy_env_version.bats
Normal file
80
tests/integration/app_deploy_env_version.bats
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#!/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
|
||||||
|
_ensure_catalogue
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown(){
|
||||||
|
_reset_recipe
|
||||||
|
_undeploy_app
|
||||||
|
_reset_app
|
||||||
|
}
|
||||||
|
|
||||||
|
# bats test_tags=slow
|
||||||
|
@test "deploy version written to env" {
|
||||||
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run grep -q "TYPE=$TEST_RECIPE:0.1.0+1.20.0" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
# bats test_tags=slow
|
||||||
|
@test "redeploy overwrites env version" {
|
||||||
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run grep -q "TYPE=$TEST_RECIPE:0.1.0+1.20.0" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.2.0+1.21.0" \
|
||||||
|
--no-input --no-converge-checks --force
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run grep -q "TYPE=$TEST_RECIPE:0.2.0+1.21.0" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
# bats test_tags=slow
|
||||||
|
@test "chaos commit written to env" {
|
||||||
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "1e83340e" --no-input --no-converge-checks
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run grep -q "TYPE=$TEST_RECIPE:1e83340e" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
# bats test_tags=slow
|
||||||
|
@test "redeploy reads from env version" {
|
||||||
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run grep -q "TYPE=$TEST_RECIPE:0.1.0+1.20.0" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
_undeploy_app
|
||||||
|
|
||||||
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||||
|
assert_success
|
||||||
|
assert_output --partial '0.1.0+1.20.0'
|
||||||
|
}
|
74
tests/integration/app_deploy_remote_recipes.bats
Normal file
74
tests/integration/app_deploy_remote_recipes.bats
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#!/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
|
||||||
|
_ensure_catalogue
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown(){
|
||||||
|
_reset_recipe
|
||||||
|
_undeploy_app
|
||||||
|
_reset_app
|
||||||
|
}
|
||||||
|
|
||||||
|
# bats test_tags=slow
|
||||||
|
@test "deploy remote recipe" {
|
||||||
|
run sed -i 's/TYPE=abra-test-recipe/TYPE=git.coopcloud.tech\/coop-cloud\/abra-test-recipe/g' \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||||
|
assert_success
|
||||||
|
assert_output --partial "git.coopcloud.tech/coop-cloud/abra-test-recipe"
|
||||||
|
}
|
||||||
|
|
||||||
|
# bats test_tags=slow
|
||||||
|
@test "deploy remote recipe with version" {
|
||||||
|
run sed -i 's/TYPE=abra-test-recipe/TYPE=git.coopcloud.tech\/coop-cloud\/abra-test-recipe:0.2.0+1.21.0/g' \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||||
|
assert_success
|
||||||
|
assert_output --partial '0.2.0+1.21.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
# bats test_tags=slow
|
||||||
|
@test "deploy remote recipe with chaos commit" {
|
||||||
|
run sed -i 's/TYPE=abra-test-recipe/TYPE=git.coopcloud.tech\/coop-cloud\/abra-test-recipe:1e83340e/g' \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||||
|
assert_success
|
||||||
|
assert_output --partial '1e83340e'
|
||||||
|
}
|
||||||
|
|
||||||
|
# bats test_tags=slow
|
||||||
|
@test "remote recipe version written to env" {
|
||||||
|
run sed -i 's/TYPE=abra-test-recipe/TYPE=git.coopcloud.tech\/coop-cloud\/abra-test-recipe/g' \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
latestRelease=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | tail -n 1)
|
||||||
|
run grep -q "TYPE=git.coopcloud.tech\/coop-cloud\/abra-test-recipe:$latestRelease" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
}
|
@ -39,17 +39,42 @@ teardown(){
|
|||||||
_get_head_hash
|
_get_head_hash
|
||||||
_get_current_hash
|
_get_current_hash
|
||||||
assert_equal "$headHash" "$currentHash"
|
assert_equal "$headHash" "$currentHash"
|
||||||
|
|
||||||
|
latestRelease=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | tail -n 1)
|
||||||
|
run grep -q "TYPE=$TEST_RECIPE:$latestRelease" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "create new app with version" {
|
@test "create new app with version" {
|
||||||
run $ABRA app new "$TEST_RECIPE" 0.1.1+1.20.2 \
|
run $ABRA app new "$TEST_RECIPE" 0.3.0+1.21.0 \
|
||||||
--no-input \
|
--no-input \
|
||||||
--server "$TEST_SERVER" \
|
--server "$TEST_SERVER" \
|
||||||
--domain "$TEST_APP_DOMAIN"
|
--domain "$TEST_APP_DOMAIN"
|
||||||
assert_success
|
assert_success
|
||||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
|
||||||
assert_equal $(_get_tag_hash 0.1.1+1.20.2) $(_get_current_hash)
|
assert_equal $(_get_tag_hash 0.3.0+1.21.0) $(_get_current_hash)
|
||||||
|
|
||||||
|
run grep -q "TYPE=$TEST_RECIPE:0.3.0+1.21.0" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "create new app with chaos commit" {
|
||||||
|
run $ABRA app new "$TEST_RECIPE" 1e83340e \
|
||||||
|
--no-input \
|
||||||
|
--server "$TEST_SERVER" \
|
||||||
|
--domain "$TEST_APP_DOMAIN"
|
||||||
|
assert_success
|
||||||
|
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
|
||||||
|
currentHash=$(_get_current_hash)
|
||||||
|
assert_equal 1e83340e ${currentHash:0:8}
|
||||||
|
|
||||||
|
run grep -q "TYPE=$TEST_RECIPE:1e83340e" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "does not overwrite existing env files" {
|
@test "does not overwrite existing env files" {
|
||||||
|
42
tests/integration/app_rollback_env_version.bats
Normal file
42
tests/integration/app_rollback_env_version.bats
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#!/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(){
|
||||||
|
_undeploy_app
|
||||||
|
_reset_recipe
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "rollback writes version to env file" {
|
||||||
|
run $ABRA app deploy "$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"
|
||||||
|
|
||||||
|
run grep -q "TYPE=abra-test-recipe:0.2.0+1.21.0" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run $ABRA app rollback "$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 grep -q "TYPE=abra-test-recipe:0.1.0+1.20.0" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
}
|
41
tests/integration/app_upgrade_env_version.bats
Normal file
41
tests/integration/app_upgrade_env_version.bats
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
setup_file(){
|
||||||
|
load "$PWD/tests/integration/helpers/common"
|
||||||
|
_common_setup
|
||||||
|
_add_server
|
||||||
|
_new_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown_file(){
|
||||||
|
_rm_app
|
||||||
|
_rm_server
|
||||||
|
}
|
||||||
|
|
||||||
|
setup(){
|
||||||
|
load "$PWD/tests/integration/helpers/common"
|
||||||
|
_common_setup
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown(){
|
||||||
|
_undeploy_app
|
||||||
|
_reset_recipe
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "upgrade writes version to env file" {
|
||||||
|
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 grep -q "TYPE=abra-test-recipe:0.1.0+1.20.0" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
run grep -q "TYPE=abra-test-recipe:0.2.0+1.21.0" \
|
||||||
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_success
|
||||||
|
}
|
Reference in New Issue
Block a user