continuous-integration/drone/push Build is passing
This PR adds a declarative integration testing setup which includes 2 local VMs client and server which can be started and stopped via a command. The VMs are run with QEMU and created by https://github.com/microvm-nix/microvm.nix The key pair is generated for this use case and is safe to commit, it resolves the problem that the readFile function can only be used with git tracked files. --------- Co-authored-by: devydave <yannick-dev@tutanota.com> Reviewed-on: #902 Reviewed-by: p4u1 <133+p4u1@noreply.git.coopcloud.tech> Co-authored-by: devydave <bittedanke@tutanota.com>
140 lines
3.6 KiB
Bash
140 lines
3.6 KiB
Bash
#!/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 "deploy commit written to env and redeploy keeps that version" {
|
|
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
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--force --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'
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "specific version overrides 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 --debug
|
|
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 "takes deployed version when no .env version is present " {
|
|
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 sed -i 's/TYPE=abra-test-recipe:.*/TYPE=abra-test-recipe/g' \
|
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
|
--force --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 "new env version written to container env" {
|
|
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input
|
|
assert_success
|
|
|
|
_inspect_env_test_app
|
|
assert_success
|
|
assert_output --partial "$TEST_RECIIPE:0.1.0+1.20.0"
|
|
}
|