Skip to content

Commit a28bef7

Browse files
committed
Add script back
1 parent e62a0cf commit a28bef7

1 file changed

Lines changed: 98 additions & 0 deletions

File tree

scripts/run_integration_tests.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Get the directory of this script
5+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
6+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
7+
8+
# Docker compose file path
9+
COMPOSE_FILE="$SCRIPT_DIR/docker-compose.test.yml"
10+
11+
# Initialize variables
12+
DEBUG_MODE=false
13+
STOP_MODE=false
14+
SERVICES=()
15+
PYTEST_ARGS=()
16+
17+
# Parse arguments
18+
while [[ $# -gt 0 ]]; do
19+
case $1 in
20+
--debug)
21+
DEBUG_MODE=true
22+
shift
23+
;;
24+
--stop)
25+
STOP_MODE=true
26+
shift
27+
;;
28+
--postgres)
29+
SERVICES+=("postgres")
30+
shift
31+
;;
32+
--mysql)
33+
SERVICES+=("mysql")
34+
shift
35+
;;
36+
*)
37+
# Preserve other arguments for pytest
38+
PYTEST_ARGS+=("$1")
39+
shift
40+
;;
41+
esac
42+
done
43+
44+
# Handle --stop
45+
if [[ "$STOP_MODE" == "true" ]]; then
46+
echo "Stopping test databases..."
47+
docker compose -f "$COMPOSE_FILE" down
48+
exit 0
49+
fi
50+
51+
# Default to running both databases if none specified
52+
if [[ ${#SERVICES[@]} -eq 0 ]]; then
53+
SERVICES=("postgres" "mysql")
54+
fi
55+
56+
# Cleanup function to stop docker containers
57+
cleanup() {
58+
echo "Stopping test databases..."
59+
docker compose -f "$COMPOSE_FILE" down
60+
}
61+
62+
# Start the databases
63+
echo "Starting/Verifying databases: ${SERVICES[*]}..."
64+
docker compose -f "$COMPOSE_FILE" up -d --wait "${SERVICES[@]}"
65+
66+
# Set up environment variables based on active services
67+
# Only export DSNs for started services so tests skip missing ones
68+
for service in "${SERVICES[@]}"; do
69+
if [[ "$service" == "postgres" ]]; then
70+
export POSTGRES_TEST_DSN="postgresql+asyncpg://a2a:a2a_password@localhost:5432/a2a_test"
71+
elif [[ "$service" == "mysql" ]]; then
72+
export MYSQL_TEST_DSN="mysql+aiomysql://a2a:a2a_password@localhost:3306/a2a_test"
73+
fi
74+
done
75+
76+
# Handle --debug mode
77+
if [[ "$DEBUG_MODE" == "true" ]]; then
78+
echo "---------------------------------------------------"
79+
echo "Debug mode enabled. Databases are running."
80+
echo "You can connect to them using the following DSNs:"
81+
[[ -n "$POSTGRES_TEST_DSN" ]] && echo "Postgres: $POSTGRES_TEST_DSN"
82+
[[ -n "$MYSQL_TEST_DSN" ]] && echo "MySQL: $MYSQL_TEST_DSN"
83+
echo "---------------------------------------------------"
84+
echo "Run ./scripts/run_integration_tests.sh --stop to shut them down."
85+
exit 0
86+
fi
87+
88+
# Register cleanup trap for normal test run
89+
trap cleanup EXIT
90+
91+
# Run the tests
92+
echo "Running integration tests..."
93+
cd "$PROJECT_ROOT"
94+
95+
uv run --extra all pytest -v \
96+
tests/server/tasks/test_database_task_store.py \
97+
tests/server/tasks/test_database_push_notification_config_store.py \
98+
"${PYTEST_ARGS[@]}"

0 commit comments

Comments
 (0)