-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-data-loading.sh
More file actions
executable file
·118 lines (92 loc) · 3.02 KB
/
test-data-loading.sh
File metadata and controls
executable file
·118 lines (92 loc) · 3.02 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# Test script for Mini Data Cloud data loading functionality
set -e
echo "🧪 Testing Mini Data Cloud Data Loading..."
echo ""
# Function to wait for service to be ready
wait_for_service() {
local port=$1
local service_name=$2
local max_attempts=30
local attempt=0
echo "Waiting for $service_name to start on port $port..."
while [ $attempt -lt $max_attempts ]; do
if curl -s "http://localhost:$port/actuator/health" > /dev/null 2>&1; then
echo "✅ $service_name is ready!"
return 0
fi
sleep 1
attempt=$((attempt + 1))
echo -n "."
done
echo "❌ $service_name failed to start within $max_attempts seconds"
return 1
}
# Function to make API calls with error handling
api_call() {
local method=$1
local url=$2
local data=$3
local description=$4
echo ""
echo "📡 $description"
echo " $method $url"
if [ -n "$data" ]; then
response=$(curl -s -X "$method" "$url" \
-H "Content-Type: application/json" \
-d "$data")
else
response=$(curl -s -X "$method" "$url")
fi
echo " Response: $response"
echo "$response"
}
echo "1. Starting Control Plane..."
cd minicloud-control-plane
mvn spring-boot:run > /tmp/control-plane.log 2>&1 &
CONTROL_PLANE_PID=$!
cd ..
# Wait for control plane to start
wait_for_service 8080 "Control Plane"
echo ""
echo "2. Testing Data Loading API..."
# Load sample bank transactions
api_call "POST" "http://localhost:8080/api/v1/data/load/sample/bank-transactions" "" "Loading sample bank transactions"
echo ""
echo "3. Checking loaded tables..."
# List loaded tables
api_call "GET" "http://localhost:8080/api/v1/data/tables" "" "Listing loaded tables"
echo ""
echo "4. Testing SQL queries..."
# Test basic count query
api_call "POST" "http://localhost:8080/api/v1/queries" \
'{"sql": "SELECT COUNT(*) FROM bank_transactions"}' \
"Running COUNT query"
# Test category aggregation
api_call "POST" "http://localhost:8080/api/v1/queries" \
'{"sql": "SELECT category, COUNT(*) as transaction_count FROM bank_transactions GROUP BY category"}' \
"Running GROUP BY query"
# Test simple select
api_call "POST" "http://localhost:8080/api/v1/queries" \
'{"sql": "SELECT * FROM bank_transactions LIMIT 5"}' \
"Running SELECT with LIMIT"
echo ""
echo "5. Testing metadata endpoints..."
# Get table metadata
api_call "GET" "http://localhost:8080/api/v1/metadata/tables" "" "Getting table metadata"
echo ""
echo "6. Cleanup..."
# Stop control plane
kill $CONTROL_PLANE_PID 2>/dev/null || true
wait $CONTROL_PLANE_PID 2>/dev/null || true
echo ""
echo "🎉 Data loading test completed!"
echo ""
echo "✅ What worked:"
echo " - CSV data loading"
echo " - Table registration"
echo " - SQL query parsing"
echo " - Metadata management"
echo ""
echo "📊 Check the logs for detailed execution information:"
echo " - Control plane logs: /tmp/control-plane.log"