forked from toolshed/abra
Compare commits
1 Commits
app-volume
...
recipe-ini
Author | SHA1 | Date | |
---|---|---|---|
c23d2d34b9 |
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
@ -12,6 +13,7 @@ import (
|
||||
stack "coopcloud.tech/abra/pkg/upstream/stack"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
@ -110,19 +112,28 @@ flag.
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
volumeList, err := client.GetVolumes(cl, context.Background(), app.Server, fs)
|
||||
volumeListOptions := volume.ListOptions{fs}
|
||||
volumeListOKBody, err := cl.VolumeList(context.Background(), volumeListOptions)
|
||||
volumeList := volumeListOKBody.Volumes
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
volumeNames := client.GetVolumeNames(volumeList)
|
||||
|
||||
if len(volumeNames) > 0 {
|
||||
err := client.RemoveVolumes(cl, context.Background(), volumeNames, internal.Force, 5)
|
||||
if err != nil {
|
||||
log.Fatalf("removing volumes failed: %s", err)
|
||||
var vols []string
|
||||
for _, vol := range volumeList {
|
||||
vols = append(vols, vol.Name)
|
||||
}
|
||||
|
||||
if len(vols) > 0 {
|
||||
for _, vol := range vols {
|
||||
err = retryFunc(5, func() error {
|
||||
return cl.VolumeRemove(context.Background(), vol, internal.Force) // last argument is for force removing
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("removing volumes failed: %s", err)
|
||||
}
|
||||
logrus.Info(fmt.Sprintf("volume %s removed", vol))
|
||||
}
|
||||
|
||||
logrus.Infof("%d volumes removed successfully", len(volumeNames))
|
||||
} else {
|
||||
logrus.Info("no volumes to remove")
|
||||
}
|
||||
@ -136,3 +147,21 @@ flag.
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// retryFunc retries the given function for the given retries. After the nth
|
||||
// retry it waits (n + 1)^2 seconds before the next retry (starting with n=0).
|
||||
// It returns an error if the function still failed after the last retry.
|
||||
func retryFunc(retries int, fn func() error) error {
|
||||
for i := 0; i < retries; i++ {
|
||||
err := fn()
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if i+1 < retries {
|
||||
sleep := time.Duration(i+1) * time.Duration(i+1)
|
||||
logrus.Infof("%s: waiting %d seconds before next retry", err, sleep)
|
||||
time.Sleep(sleep * time.Second)
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("%d retries failed", retries)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package client
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -2,7 +2,6 @@ package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
@ -132,12 +131,12 @@ Passing "--force/-f" will select all volumes for removal. Be careful.
|
||||
}
|
||||
|
||||
if len(volumesToRemove) > 0 {
|
||||
err := client.RemoveVolumes(cl, context.Background(), volumesToRemove, internal.Force, 5)
|
||||
err = client.RemoveVolumes(cl, context.Background(), app.Server, volumesToRemove, internal.Force)
|
||||
if err != nil {
|
||||
log.Fatalf("removing volumes failed: %s", err)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
logrus.Infof("%d volumes removed successfully", len(volumesToRemove))
|
||||
logrus.Info("volumes removed successfully")
|
||||
} else {
|
||||
logrus.Info("no volumes removed")
|
||||
}
|
||||
|
@ -238,6 +238,22 @@ var RemoteUserFlag = &cli.StringFlag{
|
||||
Destination: &RemoteUser,
|
||||
}
|
||||
|
||||
var GitName string
|
||||
var GitNameFlag = &cli.StringFlag{
|
||||
Name: "git-name, gn",
|
||||
Value: "",
|
||||
Usage: "Git (user) name to do commits with",
|
||||
Destination: &GitName,
|
||||
}
|
||||
|
||||
var GitEmail string
|
||||
var GitEmailFlag = &cli.StringFlag{
|
||||
Name: "git-email, ge",
|
||||
Value: "",
|
||||
Usage: "Git email name to do commits with",
|
||||
Destination: &GitEmail,
|
||||
}
|
||||
|
||||
// SubCommandBefore wires up pre-action machinery (e.g. --debug handling).
|
||||
func SubCommandBefore(c *cli.Context) error {
|
||||
if Debug {
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"text/template"
|
||||
@ -37,6 +36,8 @@ var recipeNewCommand = cli.Command{
|
||||
internal.DebugFlag,
|
||||
internal.NoInputFlag,
|
||||
internal.OfflineFlag,
|
||||
internal.GitNameFlag,
|
||||
internal.GitEmailFlag,
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
Usage: "Create a new recipe",
|
||||
@ -92,14 +93,14 @@ recipe and domain in the sample environment config).
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(path, templated.Bytes(), 0644); err != nil {
|
||||
if err := os.WriteFile(path, templated.Bytes(), 0644); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
newGitRepo := path.Join(config.RECIPES_DIR, recipeName)
|
||||
if err := git.Init(newGitRepo, true); err != nil {
|
||||
if err := git.Init(newGitRepo, true, internal.GitName, internal.GitEmail); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -2,17 +2,15 @@ package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func GetVolumes(cl *client.Client, ctx context.Context, server string, fs filters.Args) ([]*volume.Volume, error) {
|
||||
volumeListOKBody, err := cl.VolumeList(ctx, volume.ListOptions{Filters: fs})
|
||||
volumeListOptions := volume.ListOptions{fs}
|
||||
volumeListOKBody, err := cl.VolumeList(ctx, volumeListOptions)
|
||||
volumeList := volumeListOKBody.Volumes
|
||||
if err != nil {
|
||||
return volumeList, err
|
||||
@ -31,32 +29,13 @@ func GetVolumeNames(volumes []*volume.Volume) []string {
|
||||
return volumeNames
|
||||
}
|
||||
|
||||
func RemoveVolumes(cl *client.Client, ctx context.Context, volumeNames []string, force bool, retries int) error {
|
||||
func RemoveVolumes(cl *client.Client, ctx context.Context, server string, volumeNames []string, force bool) error {
|
||||
for _, volName := range volumeNames {
|
||||
err := retryFunc(5, func() error {
|
||||
return cl.VolumeRemove(context.Background(), volName, force)
|
||||
})
|
||||
err := cl.VolumeRemove(ctx, volName, force)
|
||||
if err != nil {
|
||||
return fmt.Errorf("volume %s: %s", volName, err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// retryFunc retries the given function for the given retries. After the nth
|
||||
// retry it waits (n + 1)^2 seconds before the next retry (starting with n=0).
|
||||
// It returns an error if the function still failed after the last retry.
|
||||
func retryFunc(retries int, fn func() error) error {
|
||||
for i := 0; i < retries; i++ {
|
||||
err := fn()
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if i+1 < retries {
|
||||
sleep := time.Duration(i+1) * time.Duration(i+1)
|
||||
logrus.Infof("%s: waiting %d seconds before next retry", err, sleep)
|
||||
time.Sleep(sleep * time.Second)
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("%d retries failed", retries)
|
||||
}
|
||||
|
@ -1,35 +1,41 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
gitPkg "github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Init inits a new repo and commits all the stuff if you want
|
||||
func Init(repoPath string, commit bool) error {
|
||||
if _, err := gitPkg.PlainInit(repoPath, false); err != nil {
|
||||
logrus.Fatal(err)
|
||||
func Init(repoPath string, commit bool, gitName, gitEmail string) error {
|
||||
if _, err := git.PlainInit(repoPath, false); err != nil {
|
||||
return fmt.Errorf("git init: %s", err)
|
||||
}
|
||||
logrus.Debugf("initialised new git repo in %s", repoPath)
|
||||
|
||||
if commit {
|
||||
commitRepo, err := git.PlainOpen(repoPath)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
return fmt.Errorf("git open: %s", err)
|
||||
}
|
||||
|
||||
commitWorktree, err := commitRepo.Worktree()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
return fmt.Errorf("git worktree: %s", err)
|
||||
}
|
||||
|
||||
if err := commitWorktree.AddWithOptions(&git.AddOptions{All: true}); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("git add: %s", err)
|
||||
}
|
||||
|
||||
if _, err = commitWorktree.Commit("init", &git.CommitOptions{}); err != nil {
|
||||
return err
|
||||
var author *object.Signature
|
||||
if gitName != "" && gitEmail != "" {
|
||||
author = &object.Signature{Name: gitName, Email: gitEmail}
|
||||
}
|
||||
if _, err = commitWorktree.Commit("init", &git.CommitOptions{Author: author}); err != nil {
|
||||
return fmt.Errorf("git commit: %s", err)
|
||||
}
|
||||
logrus.Debugf("init committed all files for new git repo in %s", repoPath)
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
ABRA_VERSION="0.8.1-beta"
|
||||
ABRA_RELEASE_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$ABRA_VERSION"
|
||||
RC_VERSION="0.8.0-rc1-beta"
|
||||
RC_VERSION="0.8.1-beta"
|
||||
RC_VERSION_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$RC_VERSION"
|
||||
|
||||
for arg in "$@"; do
|
||||
|
@ -70,13 +70,13 @@ setup(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA app check "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
refute_output --partial 'behind 3'
|
||||
|
||||
_reset_recipe
|
||||
}
|
||||
@ -86,7 +86,7 @@ setup(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial "Your branch is behind 'origin/main' by 1 commit"
|
||||
assert_output --partial 'behind 1'
|
||||
|
||||
# NOTE(d1): we can't quite tell if this will fail or not in the future, so,
|
||||
# since it isn't an important part of what we're testing here, we don't check
|
||||
@ -94,7 +94,7 @@ setup(){
|
||||
run $ABRA app check "$TEST_APP_DOMAIN" --offline
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial "Your branch is behind 'origin/main' by 1 commit"
|
||||
assert_output --partial 'behind 1'
|
||||
|
||||
_reset_recipe
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ test_cmd_export"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
|
||||
run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local
|
||||
assert_success
|
||||
assert_output --partial 'baz'
|
||||
|
||||
@ -70,7 +70,7 @@ test_cmd_export"
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
|
||||
run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local
|
||||
assert_failure
|
||||
assert_output --partial 'locally unstaged changes'
|
||||
|
||||
@ -83,7 +83,7 @@ test_cmd_export"
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
|
||||
run $ABRA app cmd --local --chaos "$TEST_APP_DOMAIN" test_cmd
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local --chaos
|
||||
assert_success
|
||||
assert_output --partial 'baz'
|
||||
|
||||
@ -96,14 +96,14 @@ test_cmd_export"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local
|
||||
assert_success
|
||||
assert_output --partial 'baz'
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial "up to date"
|
||||
refute_output --partial 'behind 3'
|
||||
|
||||
_reset_recipe "$TEST_RECIPE"
|
||||
}
|
||||
@ -113,14 +113,14 @@ test_cmd_export"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA app cmd --local --offline "$TEST_APP_DOMAIN" test_cmd
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local --offline
|
||||
assert_success
|
||||
assert_output --partial 'baz'
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
_reset_recipe "$TEST_RECIPE"
|
||||
}
|
||||
@ -132,13 +132,13 @@ test_cmd_export"
|
||||
}
|
||||
|
||||
@test "error if missing arguments when passing --local" {
|
||||
run $ABRA app cmd --local "$TEST_APP_DOMAIN"
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" --local
|
||||
assert_failure
|
||||
assert_output --partial 'missing arguments'
|
||||
}
|
||||
|
||||
@test "cannot use --local and --user at same time" {
|
||||
run $ABRA app cmd --local --user root "$TEST_APP_DOMAIN" test_cmd
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local --user root
|
||||
assert_failure
|
||||
assert_output --partial 'cannot use --local & --user together'
|
||||
}
|
||||
@ -147,7 +147,7 @@ test_cmd_export"
|
||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/abra.sh"
|
||||
assert_success
|
||||
|
||||
run $ABRA app cmd --local --chaos "$TEST_APP_DOMAIN" test_cmd
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local --chaos
|
||||
assert_failure
|
||||
assert_output --partial "$ABRA_DIR/recipes/$TEST_RECIPE/abra.sh does not exist"
|
||||
|
||||
@ -155,25 +155,25 @@ test_cmd_export"
|
||||
}
|
||||
|
||||
@test "error if missing command" {
|
||||
run $ABRA app cmd --local "$TEST_APP_DOMAIN" doesnt_exist
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" doesnt_exist --local
|
||||
assert_failure
|
||||
assert_output --partial "doesn't have a doesnt_exist function"
|
||||
}
|
||||
|
||||
@test "run --local command" {
|
||||
run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd --local
|
||||
assert_success
|
||||
assert_output --partial 'baz'
|
||||
}
|
||||
|
||||
@test "run command with single arg" {
|
||||
run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd_arg -- bing
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd_arg --local -- bing
|
||||
assert_success
|
||||
assert_output --partial 'bing'
|
||||
}
|
||||
|
||||
@test "run command with several args" {
|
||||
run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd_args -- bong bang
|
||||
run $ABRA app cmd "$TEST_APP_DOMAIN" test_cmd_args --local -- bong bang
|
||||
assert_success
|
||||
assert_output --partial 'bong bang'
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ teardown_file(){
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_reset_recipe
|
||||
}
|
||||
|
||||
teardown(){
|
||||
@ -83,13 +82,13 @@ teardown(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
refute_output --regexp 'behind .* 3 commits'
|
||||
refute_output --partial 'behind 3'
|
||||
|
||||
_reset_recipe
|
||||
_undeploy_app
|
||||
@ -101,7 +100,7 @@ teardown(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
# NOTE(d1): need to use --chaos to force same commit
|
||||
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
||||
@ -109,7 +108,7 @@ teardown(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
_undeploy_app
|
||||
_reset_recipe
|
||||
@ -117,9 +116,6 @@ teardown(){
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "deploy latest commit if no published versions and no --chaos" {
|
||||
# TODO(d1): fix with a new test recipe which has no published versions?
|
||||
skip "known issue, abra-test-recipe has published versions now"
|
||||
|
||||
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
|
||||
|
||||
_remove_tags
|
||||
@ -144,7 +140,7 @@ teardown(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
threeCommitsBack="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
|
||||
|
||||
@ -277,10 +273,6 @@ teardown(){
|
||||
}
|
||||
|
||||
@test "ensure domain is checked" {
|
||||
if [[ "$TEST_SERVER" == "default" ]]; then
|
||||
skip "domain checks are disabled for local server"
|
||||
fi
|
||||
|
||||
appDomain="custom-html.DOESNTEXIST"
|
||||
|
||||
run $ABRA app new custom-html \
|
||||
|
@ -45,7 +45,7 @@ teardown(){
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial "up to date"
|
||||
assert_output --partial "Your branch is up to date with 'origin/main'."
|
||||
}
|
||||
|
||||
@test "create new app with version" {
|
||||
@ -121,7 +121,7 @@ teardown(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial "Your branch is behind 'origin/main' by 3 commits, and can be fast-forwarded."
|
||||
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
@ -131,7 +131,7 @@ teardown(){
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial "up to date"
|
||||
assert_output --partial "Your branch is up to date with 'origin/main'."
|
||||
|
||||
_reset_recipe
|
||||
}
|
||||
@ -141,7 +141,7 @@ teardown(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial "Your branch is behind 'origin/main' by 3 commits, and can be fast-forwarded."
|
||||
|
||||
# NOTE(d1): need to use --chaos to force same commit
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
@ -154,7 +154,7 @@ teardown(){
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial "Your branch is behind 'origin/main' by 3 commits, and can be fast-forwarded."
|
||||
|
||||
_reset_recipe
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ teardown(){
|
||||
|
||||
_undeploy_app
|
||||
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN" --no-input
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
|
||||
run $ABRA app volume ls "$TEST_APP_DOMAIN"
|
||||
|
@ -109,13 +109,13 @@ teardown(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA app restore "$TEST_APP_DOMAIN" app
|
||||
run $ABRA app restore "$TEST_APP_DOMAIN" app DOESNTEXIST
|
||||
assert_failure
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial "up to date"
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
||||
|
||||
@test "ensure recipe not up to date if --offline" {
|
||||
@ -126,19 +126,19 @@ teardown(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA app restore "$TEST_APP_DOMAIN" app --offline
|
||||
run $ABRA app restore "$TEST_APP_DOMAIN" app DOESNTEXIST --offline
|
||||
assert_failure
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial "HEAD detached at $latestCommit"
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
||||
|
||||
@test "error if missing service" {
|
||||
|
@ -50,13 +50,13 @@ teardown(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||
assert_failure
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial "up to date"
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
||||
|
||||
@test "ensure recipe not up to date if --offline" {
|
||||
@ -67,14 +67,14 @@ teardown(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA app rollback "$TEST_APP_DOMAIN" \
|
||||
--no-input --no-converge-checks --offline
|
||||
assert_failure
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
||||
assert_success
|
||||
@ -131,7 +131,7 @@ teardown(){
|
||||
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
|
||||
|
||||
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
||||
--no-input --chaos
|
||||
--no-input --no-converge-checks --chaos
|
||||
assert_success
|
||||
assert_output --partial "$latestCommit"
|
||||
assert_output --partial 'chaos'
|
||||
|
@ -8,7 +8,7 @@ setup_file(){
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$TEST_APP_DOMAIN"
|
||||
--domain "$TEST_APP_DOMAIN" \
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
}
|
||||
@ -19,6 +19,13 @@ teardown_file(){
|
||||
_reset_recipe
|
||||
}
|
||||
|
||||
teardown(){
|
||||
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
|
||||
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
|
||||
_undeploy_app
|
||||
fi
|
||||
}
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
|
@ -59,8 +59,6 @@ teardown(){
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "error if not in catalogue" {
|
||||
skip "known issue, see https://git.coopcloud.tech/coop-cloud/recipes-catalogue-json/issues/6"
|
||||
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app version "$TEST_APP_DOMAIN"
|
||||
@ -94,7 +92,7 @@ teardown(){
|
||||
assert_success
|
||||
|
||||
# NOTE(d1): to let the stack come down before nuking volumes
|
||||
sleep 5
|
||||
sleep 3
|
||||
|
||||
run $ABRA app volume remove "$appDomain" --no-input
|
||||
assert_success
|
||||
|
@ -78,6 +78,9 @@ teardown(){
|
||||
|
||||
_undeploy_app
|
||||
|
||||
# NOTE(d1): to let the stack come down before nuking volumes
|
||||
sleep 5
|
||||
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force
|
||||
assert_success
|
||||
assert_output --partial 'volumes removed successfully'
|
||||
@ -89,6 +92,9 @@ teardown(){
|
||||
|
||||
_undeploy_app
|
||||
|
||||
# NOTE(d1): to let the stack come down before nuking volumes
|
||||
sleep 5
|
||||
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force
|
||||
assert_success
|
||||
assert_output --partial 'volumes removed successfully'
|
||||
|
@ -49,7 +49,7 @@ _reset_app(){
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$TEST_APP_DOMAIN"
|
||||
--domain "$TEST_APP_DOMAIN" \
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
}
|
||||
|
@ -11,11 +11,7 @@ _add_server() {
|
||||
}
|
||||
|
||||
_rm_server() {
|
||||
if [[ "$TEST_SERVER" == "default" ]]; then
|
||||
run rm -rf "$ABRA_DIR/servers/default"
|
||||
else
|
||||
run $ABRA server remove --no-input "$TEST_SERVER"
|
||||
fi
|
||||
run $ABRA server remove --no-input "$TEST_SERVER"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER"
|
||||
}
|
||||
|
@ -66,13 +66,13 @@ setup() {
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA recipe lint "$TEST_RECIPE"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
refute_output --partial 'behind 3'
|
||||
|
||||
_reset_recipe
|
||||
}
|
||||
@ -82,13 +82,13 @@ setup() {
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA recipe lint "$TEST_RECIPE" --offline
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
_reset_recipe
|
||||
}
|
||||
|
@ -23,14 +23,14 @@ teardown(){
|
||||
}
|
||||
|
||||
@test "create new recipe" {
|
||||
run $ABRA recipe new foobar
|
||||
run $ABRA recipe new foobar --git-name foo --git-email foo@example.com
|
||||
assert_success
|
||||
assert_output --partial 'Your new foobar recipe has been created'
|
||||
assert_exists "$ABRA_DIR/recipes/foobar"
|
||||
}
|
||||
|
||||
@test "create new app from new recipe" {
|
||||
run $ABRA recipe new foobar
|
||||
run $ABRA recipe new foobar --git-name foo --git-email foo@example.com
|
||||
assert_success
|
||||
|
||||
run $ABRA app new foobar \
|
||||
|
@ -61,14 +61,14 @@ setup(){
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
assert_output --partial 'behind 3'
|
||||
|
||||
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input
|
||||
assert_success
|
||||
assert_output --partial 'can upgrade service: app'
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
refute_output --partial 'behind 3'
|
||||
|
||||
_reset_recipe
|
||||
}
|
||||
|
@ -12,8 +12,6 @@ setup() {
|
||||
}
|
||||
|
||||
@test "error if not present in catalogue" {
|
||||
skip "known issue, see https://git.coopcloud.tech/coop-cloud/recipes-catalogue-json/issues/6"
|
||||
|
||||
run $ABRA recipe versions "$TEST_RECIPE"
|
||||
assert_failure
|
||||
assert_output --partial "is not published on the catalogue"
|
||||
|
Reference in New Issue
Block a user