Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4db15d8530 | ||
|
|
fd15aeab9a | ||
|
|
5d503319e3 |
+1
-1
@@ -29,7 +29,7 @@ steps:
|
||||
event: tag
|
||||
|
||||
- name: release
|
||||
image: goreleaser/goreleaser:v1.24.0
|
||||
image: goreleaser/goreleaser:v1.18.2
|
||||
environment:
|
||||
GITEA_TOKEN:
|
||||
from_secret: goreleaser_gitea_token
|
||||
|
||||
@@ -51,6 +51,12 @@ builds:
|
||||
- "-X 'main.Commit={{ .Commit }}'"
|
||||
- "-X 'main.Version={{ .Version }}'"
|
||||
|
||||
archives:
|
||||
- replacements:
|
||||
386: i386
|
||||
amd64: x86_64
|
||||
format: binary
|
||||
|
||||
checksum:
|
||||
name_template: "checksums.txt"
|
||||
|
||||
|
||||
+5
-19
@@ -54,17 +54,9 @@ var appNewCommand = cli.Command{
|
||||
internal.OfflineFlag,
|
||||
internal.ChaosFlag,
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
ArgsUsage: "[<recipe>] [<version>]",
|
||||
BashComplete: func(ctx *cli.Context) {
|
||||
args := ctx.Args()
|
||||
switch len(args) {
|
||||
case 0:
|
||||
autocomplete.RecipeNameComplete(ctx)
|
||||
case 1:
|
||||
autocomplete.RecipeVersionComplete(ctx.Args().Get(0))
|
||||
}
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
ArgsUsage: "[<recipe>]",
|
||||
BashComplete: autocomplete.RecipeNameComplete,
|
||||
Action: func(c *cli.Context) error {
|
||||
recipe := internal.ValidateRecipe(c)
|
||||
|
||||
@@ -77,14 +69,8 @@ var appNewCommand = cli.Command{
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
if c.Args().Get(1) == "" {
|
||||
if err := recipePkg.EnsureLatest(recipe.Name); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
if err := recipePkg.EnsureVersion(recipe.Name, c.Args().Get(1)); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
if err := recipePkg.EnsureLatest(recipe.Name); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-24
@@ -3,9 +3,7 @@ package app
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
@@ -126,11 +124,9 @@ flag.
|
||||
|
||||
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
|
||||
})
|
||||
err := cl.VolumeRemove(context.Background(), vol, internal.Force) // last argument is for force removing
|
||||
if err != nil {
|
||||
log.Fatalf("removing volumes failed: %s", err)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Info(fmt.Sprintf("volume %s removed", vol))
|
||||
}
|
||||
@@ -147,21 +143,3 @@ 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,26 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRetryFunc(t *testing.T) {
|
||||
err := retryFunc(1, func() error { return nil })
|
||||
if err != nil {
|
||||
t.Errorf("should not return an error: %s", err)
|
||||
}
|
||||
|
||||
i := 0
|
||||
fn := func() error {
|
||||
i++
|
||||
return fmt.Errorf("oh no, something went wrong!")
|
||||
}
|
||||
err = retryFunc(2, fn)
|
||||
if err == nil {
|
||||
t.Error("should return an error")
|
||||
}
|
||||
if i != 2 {
|
||||
t.Errorf("The function should have been called 1 times, got %d", i)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -169,7 +169,7 @@ var NewAppServerFlag = &cli.StringFlag{
|
||||
var NoDomainChecks bool
|
||||
var NoDomainChecksFlag = &cli.BoolFlag{
|
||||
Name: "no-domain-checks, D",
|
||||
Usage: "Disable app domain sanity checks",
|
||||
Usage: "Disable domain sanity checks",
|
||||
Destination: &NoDomainChecks,
|
||||
}
|
||||
|
||||
|
||||
+8
-14
@@ -3,7 +3,6 @@ package recipe
|
||||
import (
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
"coopcloud.tech/abra/pkg/formatter"
|
||||
"coopcloud.tech/abra/pkg/recipe"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
@@ -18,31 +17,26 @@ var recipeFetchCommand = cli.Command{
|
||||
Flags: []cli.Flag{
|
||||
internal.DebugFlag,
|
||||
internal.NoInputFlag,
|
||||
internal.OfflineFlag,
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
BashComplete: autocomplete.RecipeNameComplete,
|
||||
Action: func(c *cli.Context) error {
|
||||
recipeName := c.Args().First()
|
||||
|
||||
if recipeName != "" {
|
||||
internal.ValidateRecipe(c)
|
||||
if err := recipe.Ensure(recipeName); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
catalogue, err := recipe.ReadRecipeCatalogue(internal.Offline)
|
||||
if err != nil {
|
||||
if err := recipe.EnsureExists(recipeName); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
catlBar := formatter.CreateProgressbar(len(catalogue), "fetching latest recipes...")
|
||||
for recipeName := range catalogue {
|
||||
if err := recipe.Ensure(recipeName); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
catlBar.Add(1)
|
||||
if err := recipe.EnsureUpToDate(recipeName); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := recipe.EnsureLatest(recipeName); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
+24
-13
@@ -53,7 +53,7 @@ func cleanUp(domainName string) {
|
||||
// Docker manages SSH connection details. These are stored to disk in
|
||||
// ~/.docker. Abra can manage this completely for the user, so it's an
|
||||
// implementation detail.
|
||||
func newContext(c *cli.Context, domainName, username, port string) error {
|
||||
func newContext(c *cli.Context, name, host, username, port string) error {
|
||||
store := contextPkg.NewDefaultDockerContextStore()
|
||||
contexts, err := store.Store.List()
|
||||
if err != nil {
|
||||
@@ -61,15 +61,15 @@ func newContext(c *cli.Context, domainName, username, port string) error {
|
||||
}
|
||||
|
||||
for _, context := range contexts {
|
||||
if context.Name == domainName {
|
||||
logrus.Debugf("context for %s already exists", domainName)
|
||||
if context.Name == name {
|
||||
logrus.Debugf("context for %s already exists", name)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Debugf("creating context with domain %s, username %s and port %s", domainName, username, port)
|
||||
logrus.Debugf("creating context with name %s, host %s, username %s and port %s", name, host, username, port)
|
||||
|
||||
if err := client.CreateContext(domainName, username, port); err != nil {
|
||||
if err := client.CreateContext(name, host, username, port); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -112,11 +112,16 @@ Abra can then load SSH connection details from this configuratiion with:
|
||||
If "--local" is passed, then Abra assumes that the current local server is
|
||||
intended as the target server. This is useful when you want to have your entire
|
||||
Co-op Cloud config located on the server itself, and not on your local
|
||||
developer machine.
|
||||
developer machine. The domain is then set to "default".
|
||||
|
||||
You can also pass "--no-domain-checks" flag to use any arbitrary name instead
|
||||
of a real domain. Host will be resolved with the "hostname" entry of your SSH
|
||||
configuration. Checks for a valid online domain will be skipped.
|
||||
`,
|
||||
Flags: []cli.Flag{
|
||||
internal.DebugFlag,
|
||||
internal.NoInputFlag,
|
||||
internal.NoDomainChecksFlag,
|
||||
localFlag,
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
@@ -150,20 +155,26 @@ developer machine.
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err := dns.EnsureIPv4(domainName); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := createServerDir(domainName); err != nil {
|
||||
logrus.Fatal(err)
|
||||
if !internal.NoDomainChecks {
|
||||
if _, err := dns.EnsureIPv4(domainName); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
hostConfig, err := sshPkg.GetHostConfig(domainName)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
if hostConfig.Host == "" {
|
||||
hostConfig.Host = domainName
|
||||
}
|
||||
|
||||
if err := newContext(c, domainName, hostConfig.User, hostConfig.Port); err != nil {
|
||||
if err := createServerDir(domainName); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := newContext(c, domainName, hostConfig.Host, hostConfig.User, hostConfig.Port); err != nil {
|
||||
cleanUp(domainName)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,20 +51,6 @@ func RecipeNameComplete(c *cli.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// RecipeVersionComplete completes versions for the recipe.
|
||||
func RecipeVersionComplete(recipeName string) {
|
||||
catl, err := recipe.ReadRecipeCatalogue(false)
|
||||
if err != nil {
|
||||
logrus.Warn(err)
|
||||
}
|
||||
|
||||
for _, v := range catl[recipeName].Versions {
|
||||
for v2 := range v {
|
||||
fmt.Println(v2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ServerNameComplete completes server names.
|
||||
func ServerNameComplete(c *cli.Context) {
|
||||
files, err := config.LoadAppFiles("")
|
||||
|
||||
@@ -14,8 +14,7 @@ import (
|
||||
|
||||
type Context = contextStore.Metadata
|
||||
|
||||
func CreateContext(contextName string, user string, port string) error {
|
||||
host := contextName
|
||||
func CreateContext(contextName string, host string, user string, port string) error {
|
||||
if user != "" {
|
||||
host = fmt.Sprintf("%s@%s", user, host)
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import (
|
||||
func EnsureIPv4(domainName string) (string, error) {
|
||||
ipv4, err := net.ResolveIPAddr("ip4", domainName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", fmt.Errorf("unable to resolve ipv4 address for %s, %s", domainName, err)
|
||||
}
|
||||
|
||||
// NOTE(d1): e.g. when there is only an ipv6 record available
|
||||
|
||||
@@ -264,20 +264,6 @@ func (r Recipe) SampleEnv() (map[string]string, error) {
|
||||
return sampleEnv, nil
|
||||
}
|
||||
|
||||
// Ensure makes sure the recipe exists, is up to date and has the latest version checked out.
|
||||
func Ensure(recipeName string) error {
|
||||
if err := EnsureExists(recipeName); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := EnsureUpToDate(recipeName); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := EnsureLatest(recipeName); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EnsureExists ensures that a recipe is locally cloned
|
||||
func EnsureExists(recipeName string) error {
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
ABRA_VERSION="0.9.0-beta"
|
||||
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
|
||||
@@ -65,19 +65,17 @@ function install_abra_release {
|
||||
|
||||
checksums=$(wget -q -O- $checksums_url)
|
||||
checksum=$(echo "$checksums" | grep "$FILENAME" - | sed -En 's/([0-9a-f]{64})\s+'"$FILENAME"'.*/\1/p')
|
||||
abra_download="/tmp/abra-download"
|
||||
|
||||
echo "downloading $ABRA_VERSION $PLATFORM binary release for abra..."
|
||||
|
||||
wget -q "$release_url" -O $abra_download
|
||||
localsum=$(sha256sum $abra_download | sed -En 's/([0-9a-f]{64})\s+.*/\1/p')
|
||||
wget -q "$release_url" -O "$HOME/.local/bin/.abra-download"
|
||||
localsum=$(sha256sum $HOME/.local/bin/.abra-download | sed -En 's/([0-9a-f]{64})\s+.*/\1/p')
|
||||
echo "checking if checksums match..."
|
||||
if [[ "$localsum" != "$checksum" ]]; then
|
||||
print_checksum_error
|
||||
exit 1
|
||||
fi
|
||||
echo "$(tput setaf 2)check successful!$(tput sgr0)"
|
||||
mv "$abra_download" "$HOME/.local/bin/abra"
|
||||
mv "$HOME/.local/bin/.abra-download" "$HOME/.local/bin/abra"
|
||||
chmod +x "$HOME/.local/bin/abra"
|
||||
|
||||
x=$(echo $PATH | grep $HOME/.local/bin)
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -18,24 +18,9 @@ setup(){
|
||||
}
|
||||
|
||||
teardown(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_rm_app
|
||||
}
|
||||
|
||||
@test "autocomplete" {
|
||||
run $ABRA app new --generate-bash-completion
|
||||
assert_success
|
||||
assert_output --partial "traefik"
|
||||
assert_output --partial "abra-test-recipe"
|
||||
|
||||
# Note: this test needs to be updated when a new version of the test recipe is published.
|
||||
run $ABRA app new abra-test-recipe --generate-bash-completion
|
||||
assert_success
|
||||
assert_output "0.1.0+1.20.0
|
||||
0.1.1+1.20.2
|
||||
0.2.0+1.21.0"
|
||||
}
|
||||
|
||||
@test "create new app" {
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
@@ -43,29 +28,10 @@ teardown(){
|
||||
--domain "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
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"
|
||||
}
|
||||
|
||||
@test "create new app with version" {
|
||||
run $ABRA app new "$TEST_RECIPE" 0.1.1+1.20.2 \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" log -1
|
||||
assert_output --partial "453db7121c0a56a7a8f15378f18fe3bf21ccfdef"
|
||||
}
|
||||
|
||||
@test "does not overwrite existing env files" {
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
_new_app
|
||||
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
@@ -108,7 +74,8 @@ teardown(){
|
||||
--no-input \
|
||||
--chaos \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$TEST_APP_DOMAIN"
|
||||
--domain "$TEST_APP_DOMAIN" \
|
||||
--secrets
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
@@ -121,17 +88,18 @@ 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 new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$TEST_APP_DOMAIN"
|
||||
--domain "$TEST_APP_DOMAIN" \
|
||||
--secrets
|
||||
assert_success
|
||||
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"
|
||||
refute_output --partial 'behind 3'
|
||||
|
||||
_reset_recipe
|
||||
}
|
||||
@@ -141,7 +109,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 new "$TEST_RECIPE" \
|
||||
@@ -149,12 +117,13 @@ teardown(){
|
||||
--offline \
|
||||
--chaos \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$TEST_APP_DOMAIN"
|
||||
--domain "$TEST_APP_DOMAIN" \
|
||||
--secrets
|
||||
assert_success
|
||||
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 'behind 3'
|
||||
|
||||
_reset_recipe
|
||||
}
|
||||
|
||||
@@ -104,10 +104,10 @@ teardown(){
|
||||
|
||||
_undeploy_app
|
||||
|
||||
# TODO: should wait as long as volume is no longer in use
|
||||
sleep 10
|
||||
# NOTE(d1): to let the stack come down before nuking volumes
|
||||
sleep 5
|
||||
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN" --no-input
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force
|
||||
assert_success
|
||||
|
||||
run $ABRA app volume ls "$TEST_APP_DOMAIN"
|
||||
@@ -132,6 +132,9 @@ teardown(){
|
||||
|
||||
_undeploy_app
|
||||
|
||||
# NOTE(d1): to let the stack come down before nuking volumes
|
||||
sleep 5
|
||||
|
||||
run $ABRA app rm "$TEST_APP_DOMAIN" --no-input
|
||||
assert_success
|
||||
assert_output --partial 'test-volume'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -79,7 +79,7 @@ teardown(){
|
||||
_undeploy_app
|
||||
|
||||
# NOTE(d1): to let the stack come down before nuking volumes
|
||||
sleep 10
|
||||
sleep 5
|
||||
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force
|
||||
assert_success
|
||||
@@ -93,7 +93,7 @@ teardown(){
|
||||
_undeploy_app
|
||||
|
||||
# NOTE(d1): to let the stack come down before nuking volumes
|
||||
sleep 10
|
||||
sleep 5
|
||||
|
||||
run $ABRA app volume rm "$TEST_APP_DOMAIN" --force
|
||||
assert_success
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -5,17 +5,7 @@ setup() {
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "recipe fetch all" {
|
||||
run rm -rf "$ABRA_DIR/recipes/matrix-synapse"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/recipes/matrix-synapse"
|
||||
|
||||
run $ABRA recipe fetch
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/recipes/matrix-synapse"
|
||||
}
|
||||
|
||||
@test "recipe fetch single recipe" {
|
||||
@test "recipe fetch" {
|
||||
run rm -rf "$ABRA_DIR/recipes/matrix-synapse"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/recipes/matrix-synapse"
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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