The postgresql container initializes DB files e.a. in these tests, this can take a couple of seconds. Try contacting it for up to 20 seconds, and only then run the tests: create a table, store something in it and retrieve it again.
65 lines
2.1 KiB
YAML
65 lines
2.1 KiB
YAML
document: modularity-testing
|
|
version: 1
|
|
name: postgresql
|
|
modulemd-url: https://src.fedoraproject.org/cgit/modules/postgresql.git/tree/postgresql.yaml?h=f26
|
|
service:
|
|
port: 5432
|
|
packages:
|
|
rpms:
|
|
- postgresql-server
|
|
# seq
|
|
- coreutils
|
|
testdependecies:
|
|
rpms:
|
|
- postgresql
|
|
- systemd
|
|
module:
|
|
docker:
|
|
start: "docker run -it -p 5432:5432 -e POSTGRESQL_USER=mtftest -e POSTGRESQL_PASSWORD=mtftest -e POSTGRESQL_DATABASE=mtftest"
|
|
labels:
|
|
description: "PostgreSQL is an advanced Object-Relational database management system (DBMS)."
|
|
io.k8s.description: "PostgreSQL is an advanced Object-Relational database management system (DBMS)."
|
|
source: https://github.com/container-images/postgresql.git
|
|
container: docker.io/modularitycontainers/postgresql
|
|
rpm:
|
|
start: systemctl start postgresql
|
|
stop: systemctl stop postgresql
|
|
status: systemctl status postgresql
|
|
repos:
|
|
- https://kojipkgs.fedoraproject.org/repos/module-d87b0b15567e47f3-build/latest/x86_64/
|
|
test:
|
|
process_running:
|
|
- |
|
|
up=0
|
|
for i in `seq 20`; do
|
|
echo "Checking for /usr/bin/postgres process... ($i)"
|
|
if ls /proc/*/exe -alh 2>/dev/null | grep /usr/bin/postgres; then
|
|
echo "Found."
|
|
up=1
|
|
break
|
|
else
|
|
sleep 1
|
|
fi
|
|
done
|
|
test "$up" -ne 0
|
|
testhost:
|
|
db_usable:
|
|
- |
|
|
export PGPASSWORD=mtftest
|
|
PSQL="psql -h localhost -U mtftest -q"
|
|
up=0
|
|
for i in `seq 20`; do
|
|
echo "Pinging PostgreSQL ($i)"
|
|
if $PSQL -c "" >&/dev/null; then
|
|
up=1
|
|
break
|
|
else
|
|
sleep 1
|
|
fi
|
|
done
|
|
if [ "$up" -eq 1 ]; then
|
|
$PSQL -f test.sql | egrep "anything|something"
|
|
else
|
|
echo "Unable to connect to database." >&2
|
|
false
|
|
fi
|