-
Notifications
You must be signed in to change notification settings - Fork 445
Expand file tree
/
Copy pathruntests.sh
More file actions
executable file
·43 lines (34 loc) · 1.27 KB
/
runtests.sh
File metadata and controls
executable file
·43 lines (34 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# Run tests against all supported databases
set -e
# Default settings
export TEST_DB_USER=${TEST_DB_USER:-testuser}
export TEST_DB_PASS=${TEST_DB_PASS:-testpass}
export TEST_DB_HOST=${TEST_DB_HOST:-127.0.0.1}
export TEST_DB_NAME=${TEST_DB_NAME:-auditlog}
# Cleanup on exit
trap 'docker compose -f auditlog_tests/docker-compose.yml down -v --remove-orphans 2>/dev/null || true' EXIT
echo "Starting containers..."
docker compose -f auditlog_tests/docker-compose.yml up -d
echo "Waiting for databases..."
echo "Waiting for PostgreSQL..."
until docker compose -f auditlog_tests/docker-compose.yml exec postgres pg_isready -U ${TEST_DB_USER} -d auditlog >/dev/null 2>&1; do
sleep 1
done
echo "Waiting for MySQL..."
until docker compose -f auditlog_tests/docker-compose.yml exec mysql mysqladmin ping -h 127.0.0.1 -u ${TEST_DB_USER} --password=${TEST_DB_PASS} --silent >/dev/null 2>&1; do
sleep 1
done
echo "Databases ready!"
# Run tests for each database
for backend in sqlite3 postgresql mysql; do
echo "Testing $backend..."
export TEST_DB_BACKEND=$backend
case $backend in
postgresql) export TEST_DB_PORT=5432 ;;
mysql) export TEST_DB_PORT=3306;;
sqlite3) unset TEST_DB_PORT ;;
esac
tox
done
echo "All tests completed!"