From c88fc66c99d15916266ee98af3ffffdc195a5deb Mon Sep 17 00:00:00 2001 From: decentral1se Date: Sun, 5 Jan 2025 16:12:06 +0100 Subject: [PATCH] =?UTF-8?q?test:=20moar=20chaos=20stability=20=F0=9F=98=8C?= =?UTF-8?q?=20[ci=20skip]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/integration/app_check.bats | 6 +++++ tests/integration/app_cmd.bats | 6 +++++ tests/integration/app_cp.bats | 39 +++++++++++++++++++++++++++ tests/integration/app_deploy.bats | 6 +++++ tests/integration/app_env.bats | 13 +++++++++ tests/integration/app_labels.bats | 6 +++++ tests/integration/app_new.bats | 6 +++++ tests/integration/app_ps.bats | 6 +++++ tests/integration/app_secret.bats | 9 +++++++ tests/integration/catalogue.bats | 3 +++ tests/integration/helpers/git.bash | 4 +++ tests/integration/install.bats | 2 -- tests/integration/recipe_lint.bats | 6 +++++ tests/integration/recipe_sync.bats | 3 +++ tests/integration/recipe_upgrade.bats | 3 +++ 15 files changed, 116 insertions(+), 2 deletions(-) diff --git a/tests/integration/app_check.bats b/tests/integration/app_check.bats index b96b0215..13241508 100644 --- a/tests/integration/app_check.bats +++ b/tests/integration/app_check.bats @@ -50,6 +50,9 @@ teardown(){ assert_failure assert_output --partial 'locally unstaged changes' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } @@ -62,6 +65,9 @@ teardown(){ run $ABRA app check "$TEST_APP_DOMAIN" --chaos assert_success + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } diff --git a/tests/integration/app_cmd.bats b/tests/integration/app_cmd.bats index 60a4d745..9fc18c05 100644 --- a/tests/integration/app_cmd.bats +++ b/tests/integration/app_cmd.bats @@ -53,6 +53,9 @@ teardown(){ assert_failure assert_output --partial 'locally unstaged changes' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } @@ -66,6 +69,9 @@ teardown(){ assert_success assert_output --partial 'baz' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } diff --git a/tests/integration/app_cp.bats b/tests/integration/app_cp.bats index 9042d47b..2485b055 100644 --- a/tests/integration/app_cp.bats +++ b/tests/integration/app_cp.bats @@ -24,6 +24,9 @@ teardown(){ _rm_remote "/etc/*.txt" _rm "$BATS_TMPDIR/mydir" + + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } @test "validate app argument" { @@ -34,6 +37,42 @@ teardown(){ assert_failure } +@test "bail if unstaged changes and no --chaos" { + _mkdir "$BATS_TMPDIR/mydir" + _mkfile "$BATS_TMPDIR/mydir/myfile.txt" "foo" + + run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_success + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + + run $ABRA app cp "$TEST_APP_DOMAIN" "$BATS_TMPDIR/mydir" app:/etc + assert_failure + + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" +} + +@test "do not bail if unstaged changes and --chaos" { + _mkdir "$BATS_TMPDIR/mydir" + _mkfile "$BATS_TMPDIR/mydir/myfile.txt" "foo" + + run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_success + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + + run $ABRA app cp "$TEST_APP_DOMAIN" "$BATS_TMPDIR/mydir" app:/etc --chaos + assert_success + + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" +} + @test "error if missing src/dest arguments" { run $ABRA app cp "$TEST_APP_DOMAIN" assert_failure diff --git a/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index 2b0016f0..c2626628 100644 --- a/tests/integration/app_deploy.bats +++ b/tests/integration/app_deploy.bats @@ -46,6 +46,9 @@ teardown(){ assert_success assert_output --partial 'foo' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input assert_failure assert_output --partial 'locally unstaged changes' @@ -62,6 +65,9 @@ teardown(){ assert_success assert_output --partial 'foo' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run $ABRA app deploy "$TEST_APP_DOMAIN" \ --chaos --no-input --no-converge-checks assert_success diff --git a/tests/integration/app_env.bats b/tests/integration/app_env.bats index 926b9259..81733efa 100644 --- a/tests/integration/app_env.bats +++ b/tests/integration/app_env.bats @@ -22,6 +22,9 @@ teardown(){ _reset_recipe _reset_app _undeploy_app + + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } @test "validate app argument" { @@ -41,6 +44,16 @@ teardown(){ } @test "show env version despite --chaos" { + run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_success + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + run $ABRA app env "$TEST_APP_DOMAIN" assert_success + + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + + 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 b51e3bab..b5b22d23 100644 --- a/tests/integration/app_labels.bats +++ b/tests/integration/app_labels.bats @@ -46,6 +46,9 @@ teardown(){ assert_success assert_output --partial 'foo' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run $ABRA app labels "$TEST_APP_DOMAIN" --no-input assert_failure } @@ -59,6 +62,9 @@ teardown(){ assert_success assert_output --partial 'foo' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run $ABRA app labels "$TEST_APP_DOMAIN" --chaos assert_success } diff --git a/tests/integration/app_new.bats b/tests/integration/app_new.bats index 24068131..503cf4da 100644 --- a/tests/integration/app_new.bats +++ b/tests/integration/app_new.bats @@ -94,6 +94,9 @@ teardown(){ assert_success assert_output --partial 'foo' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run $ABRA app new "$TEST_RECIPE" \ --no-input \ --server "$TEST_SERVER" \ @@ -114,6 +117,9 @@ teardown(){ assert_success assert_output --partial 'foo' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run $ABRA app new "$TEST_RECIPE" \ --no-input \ --chaos \ diff --git a/tests/integration/app_ps.bats b/tests/integration/app_ps.bats index 62d53de0..17e0e5c5 100644 --- a/tests/integration/app_ps.bats +++ b/tests/integration/app_ps.bats @@ -55,6 +55,9 @@ teardown(){ assert_failure assert_output --partial 'locally unstaged changes' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } @@ -70,6 +73,9 @@ teardown(){ run $ABRA app ps --chaos "$TEST_APP_DOMAIN" assert_success + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } diff --git a/tests/integration/app_secret.bats b/tests/integration/app_secret.bats index f72df97f..e1f087c0 100644 --- a/tests/integration/app_secret.bats +++ b/tests/integration/app_secret.bats @@ -131,6 +131,9 @@ teardown(){ assert_failure assert_output --partial 'locally unstaged changes' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } @@ -271,6 +274,9 @@ teardown(){ assert_failure assert_output --partial 'locally unstaged changes' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } @@ -319,6 +325,9 @@ teardown(){ assert_failure assert_output --partial 'locally unstaged changes' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } diff --git a/tests/integration/catalogue.bats b/tests/integration/catalogue.bats index 0d4c25f7..a907bc9d 100644 --- a/tests/integration/catalogue.bats +++ b/tests/integration/catalogue.bats @@ -37,6 +37,9 @@ setup(){ run $ABRA catalogue generate gitea --chaos assert_success + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/catalogue/foo" assert_not_exists "$ABRA_DIR/catalogue/foo" } diff --git a/tests/integration/helpers/git.bash b/tests/integration/helpers/git.bash index 2c15bf96..637136f8 100644 --- a/tests/integration/helpers/git.bash +++ b/tests/integration/helpers/git.bash @@ -60,3 +60,7 @@ _get_current_hash() { _get_n_hash() { echo $(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" show -s --format="%H" "HEAD~$1") } + +_git_status() { + echo $(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status --porcelain) +} diff --git a/tests/integration/install.bats b/tests/integration/install.bats index d0d5fa9f..a92ce234 100644 --- a/tests/integration/install.bats +++ b/tests/integration/install.bats @@ -28,8 +28,6 @@ teardown(){ # bats test_tags=slow @test "install release candidate from script" { - skip "current RC is brokenly specified in the installer script" - run bash -c 'curl https://install.abra.coopcloud.tech | bash -s -- --rc' assert_success diff --git a/tests/integration/recipe_lint.bats b/tests/integration/recipe_lint.bats index 85657154..14b34520 100644 --- a/tests/integration/recipe_lint.bats +++ b/tests/integration/recipe_lint.bats @@ -41,6 +41,9 @@ teardown(){ assert_success assert_output --partial 'foo' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run $ABRA recipe lint "$TEST_RECIPE" assert_failure assert_output --partial 'locally unstaged changes' @@ -58,6 +61,9 @@ teardown(){ assert_success assert_output --partial 'foo' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run $ABRA recipe lint "$TEST_RECIPE" --chaos assert_success diff --git a/tests/integration/recipe_sync.bats b/tests/integration/recipe_sync.bats index 9914372e..05ace29f 100644 --- a/tests/integration/recipe_sync.bats +++ b/tests/integration/recipe_sync.bats @@ -40,6 +40,9 @@ teardown(){ run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch assert_success + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_success assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" diff --git a/tests/integration/recipe_upgrade.bats b/tests/integration/recipe_upgrade.bats index e7d4664e..8e7c949e 100644 --- a/tests/integration/recipe_upgrade.bats +++ b/tests/integration/recipe_upgrade.bats @@ -54,6 +54,9 @@ teardown(){ assert_failure assert_output --partial 'locally unstaged changes' + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_equal "$(_git_status)" "?? foo" + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" }