-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created test to check availability of postgres
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
VKPR_HOME=~/.vkpr | ||
|
||
setup_file() { | ||
load 'common-setup' | ||
_common_setup | ||
if [ "$VKPR_TEST_SKIP_SETUP" == "true" ]; then | ||
echo "setup: skipping setup due to VKPR_TEST_SKIP_SETUP=true" >&3 | ||
else | ||
echo "setup: installing postgres...." >&3 | ||
rit vkpr postgres install | ||
kubectl wait --for=condition=ready --timeout=1m pod --all | ||
sleep 2 | ||
fi | ||
} | ||
|
||
setup() { | ||
load $VKPR_HOME/bats/bats-support/load.bash | ||
load $VKPR_HOME/bats/bats-assert/load.bash | ||
} | ||
|
||
@test "Ping in DB and must show if is accepting connections" { | ||
run ping_db | ||
actual="${lines[0]}" | ||
expected="postgres-postgresql:5432 - accepting connections" | ||
assert_equal "$actual" "$expected" | ||
} | ||
|
||
teardown_file() { | ||
if [ "$VKPR_TEST_SKIP_TEARDOWN" == "true" ]; then | ||
echo "teardown: skipping teardown due to VKPR_TEST_SKIP_TEARDOWN=true" >&3 | ||
else | ||
echo "teardown: uninstalling postgres...." >&3 | ||
rit vkpr postgres remove | ||
rit vkpr infra down | ||
fi | ||
} | ||
|
||
ping_db(){ | ||
$VKPR_HOME/bin/kubectl run test-db --rm -it --restart='Never' --image docker.io/bitnami/postgresql:11.13.0-debian-10-r12 --env="PGUSER=postgres" --env="PGPASSWORD=123" --env="PGHOST=postgres-postgresql" --env="PGPORT=5432" --command -- pg_isready | ||
} |