Basic database test
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 41s
Deploy Test / Run deploy test suite (pull_request) Successful in 3m30s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m32s
Smoke Test / Run basic test suite (pull_request) Successful in 2m41s
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 41s
Deploy Test / Run deploy test suite (pull_request) Successful in 3m30s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m32s
Smoke Test / Run basic test suite (pull_request) Successful in 2m41s
This commit is contained in:
parent
c36f1e430f
commit
7b5f720593
@ -1,4 +1,5 @@
|
||||
services:
|
||||
|
||||
database:
|
||||
image: cerc/test-database-container:local
|
||||
restart: always
|
||||
@ -11,6 +12,9 @@ services:
|
||||
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
|
||||
ports:
|
||||
- "5432"
|
||||
|
||||
test-client:
|
||||
image: cerc/test-database-client:local
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
|
@ -0,0 +1,12 @@
|
||||
FROM ubuntu:latest
|
||||
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && export DEBCONF_NOWARNINGS="yes" && \
|
||||
apt-get install -y software-properties-common && \
|
||||
apt-get install -y postgresql-client && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
COPY run.sh /app/run.sh
|
||||
|
||||
ENTRYPOINT ["/app/run.sh"]
|
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/test-container
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
docker build -t cerc/test-database-client:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR
|
42
stack_orchestrator/data/container-build/cerc-test-database-client/run.sh
Executable file
42
stack_orchestrator/data/container-build/cerc-test-database-client/run.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# TODO derive this from config
|
||||
database_url="postgresql://test-user:password@localhost:5432/test-db"
|
||||
psql_command="psql ${database_url}"
|
||||
|
||||
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 ' ')
|
||||
if [[ "${query_result}" == "1" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
create_test_data () {
|
||||
${psql_command} -c "create table test_table_1 (key_column text, value_column text, primary key(key_column));"
|
||||
${psql_command} -c "insert into test_table_1 values ('test_key_1', 'test_value_1');"
|
||||
}
|
||||
|
||||
wait_forever() {
|
||||
# Loop to keep docker/k8s happy since this is the container entrypoint
|
||||
while :; do sleep 600; done
|
||||
}
|
||||
|
||||
# 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"
|
||||
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"
|
||||
# then create it
|
||||
create_test_data
|
||||
fi
|
||||
|
||||
wait_forever
|
@ -4,5 +4,6 @@ description: "A test database stack"
|
||||
repos:
|
||||
containers:
|
||||
- cerc/test-database-container
|
||||
- cerc/test-database-client
|
||||
pods:
|
||||
- test-database
|
||||
|
Loading…
Reference in New Issue
Block a user