Test complete
Some checks failed
Lint Checks / Run linter (pull_request) Failing after 42s
Webapp Test / Run webapp test suite (pull_request) Successful in 3m10s
Deploy Test / Run deploy test suite (pull_request) Successful in 4m14s
Smoke Test / Run basic test suite (pull_request) Successful in 5m4s

This commit is contained in:
David Boreham 2024-02-14 21:49:16 -07:00
parent d49f366b56
commit 43be190fe6
2 changed files with 39 additions and 10 deletions

View File

@ -7,6 +7,32 @@ fi
# TODO derive this from config
database_url="postgresql://test-user:password@localhost:5432/test-db"
psql_command="psql ${database_url}"
program_name="Database test client:"
wait_for_database_up () {
for i in {1..50}
do
${psql_command} -c "select 1;"
psql_succeeded=$?
if [[ ${psql_succeeded} == 0 ]]; then
# if ready, return
echo "${program_name} database up"
return
else
# if not ready, wait
echo "${program_name} waiting for database: ${i}"
sleep 5
fi
done
# Timed out, error exit
echo "${program_name} waiting for database: FAILED"
exit 1
}
# Used to synchronize with the test runner
notify_test_complete () {
echo "${program_name} test complete"
}
does_test_data_exist () {
query_result=$(${psql_command} -t -c "select count(*) from test_table_1 where key_column = 'test_key_1';" | head -1 | tr -d ' ')
@ -27,16 +53,19 @@ wait_forever() {
while :; do sleep 600; done
}
wait_for_database_up
# Check if the test database content exists already
if does_test_data_exist; then
# If so, log saying so. Test harness will look for this log output
echo "Database test client: test data already exists"
echo "${program_name} test data already exists"
else
# Otherwise log saying the content was not present
echo "Database test client: test data does not exist"
echo "Database test client: creating test data"
echo "${program_name} test data does not exist"
echo "${program_name} creating test data"
# then create it
create_test_data
fi
notify_test_complete
wait_forever

View File

@ -36,13 +36,13 @@ wait_for_pods_started () {
delete_cluster_exit
}
wait_for_log_output () {
wait_for_test_complete () {
for i in {1..50}
do
local log_output=$( $TEST_TARGET_SO deployment --dir $test_deployment_dir logs )
if [[ ! -z "$log_output" ]]; then
if [[ "${log_output}" == *"Database test client: test complete"* ]]; then
# if ready, return
return
else
@ -51,7 +51,7 @@ wait_for_log_output () {
fi
done
# Timed out, error exit
echo "waiting for pods log content: FAILED"
echo "waiting for test complete: FAILED"
delete_cluster_exit
}
@ -98,12 +98,12 @@ echo "deploy create test: passed"
$TEST_TARGET_SO deployment --dir $test_deployment_dir start
wait_for_pods_started
# Check logs command works
wait_for_log_output
wait_for_test_complete
log_output_1=$( $TEST_TARGET_SO deployment --dir $test_deployment_dir logs )
if [[ "$log_output_1" == *"Database test client: test data does not exist"* ]]; then
echo "deployment logs test: passed"
echo "Create database content test: passed"
else
echo "deployment logs test: FAILED"
echo "Create database content test: FAILED"
delete_cluster_exit
fi
@ -113,7 +113,7 @@ $TEST_TARGET_SO deployment --dir $test_deployment_dir stop
sleep 20
$TEST_TARGET_SO deployment --dir $test_deployment_dir start
wait_for_pods_started
wait_for_log_output
wait_for_test_complete
log_output_2=$( $TEST_TARGET_SO deployment --dir $test_deployment_dir logs )
if [[ "$log_output_2" == *"Database test client: test data already exists"* ]]; then