22
33set -e
44
5+ # Function to cleanup processes
6+ cleanup () {
7+ echo " 🧹 Cleaning up processes..."
8+ for pid in $CSV_PID $TRANSACTION_PID $PARQUET_PID $RBAC_PID $SSL_PID ; do
9+ if [ ! -z " $pid " ]; then
10+ kill -9 $pid 2> /dev/null || true
11+ fi
12+ done
13+ }
14+
15+ # Trap to cleanup on exit
16+ trap cleanup EXIT
17+
18+ # Function to wait for port to be available
19+ wait_for_port () {
20+ local port=$1
21+ local timeout=30
22+ local count=0
23+
24+ # Use netstat as fallback if lsof is not available
25+ while (lsof -Pi :$port -sTCP:LISTEN -t > /dev/null 2>&1 ) || (netstat -ln 2> /dev/null | grep " :$port " > /dev/null 2>&1 ); do
26+ if [ $count -ge $timeout ]; then
27+ echo " ❌ Port $port still in use after ${timeout} s timeout"
28+ exit 1
29+ fi
30+ sleep 1
31+ count=$(( count + 1 ))
32+ done
33+ }
34+
535echo " 🚀 Running DataFusion PostgreSQL Integration Tests"
636echo " =================================================="
737
@@ -28,6 +58,7 @@ pip install -q psycopg
2858echo " "
2959echo " 📊 Test 1: Enhanced CSV Data Loading & PostgreSQL Compatibility"
3060echo " ----------------------------------------------------------------"
61+ wait_for_port 5433
3162../target/debug/datafusion-postgres-cli -p 5433 --csv delhi:delhiclimate.csv &
3263CSV_PID=$!
3364sleep 5
@@ -53,9 +84,10 @@ sleep 3
5384echo " "
5485echo " 🔐 Test 2: Transaction Support"
5586echo " ------------------------------"
87+ wait_for_port 5433
5688../target/debug/datafusion-postgres-cli -p 5433 --csv delhi:delhiclimate.csv &
5789TRANSACTION_PID=$!
58- sleep 3
90+ sleep 5
5991
6092if python3 test_transactions.py; then
6193 echo " ✅ Transaction test passed"
@@ -72,9 +104,10 @@ sleep 3
72104echo " "
73105echo " 📦 Test 3: Enhanced Parquet Data Loading & Advanced Data Types"
74106echo " --------------------------------------------------------------"
107+ wait_for_port 5434
75108../target/debug/datafusion-postgres-cli -p 5434 --parquet all_types:all_types.parquet &
76109PARQUET_PID=$!
77- sleep 3
110+ sleep 5
78111
79112if python3 test_parquet.py; then
80113 echo " ✅ Enhanced Parquet test passed"
@@ -85,11 +118,13 @@ else
85118fi
86119
87120kill -9 $PARQUET_PID 2> /dev/null || true
121+ sleep 3
88122
89123# Test 4: Role-Based Access Control
90124echo " "
91125echo " 🔐 Test 4: Role-Based Access Control (RBAC)"
92126echo " --------------------------------------------"
127+ wait_for_port 5435
93128../target/debug/datafusion-postgres-cli -p 5435 --csv delhi:delhiclimate.csv &
94129RBAC_PID=$!
95130sleep 5
@@ -115,6 +150,7 @@ sleep 3
115150echo " "
116151echo " 🔒 Test 5: SSL/TLS Security Features"
117152echo " ------------------------------------"
153+ wait_for_port 5436
118154../target/debug/datafusion-postgres-cli -p 5436 --csv delhi:delhiclimate.csv &
119155SSL_PID=$!
120156sleep 5
0 commit comments