Repository navigation
Expand file tree
/
Copy pathhorizon_load_test.sh
More file actions
executable file
·230 lines (197 loc) · 6.72 KB
/
Copy pathhorizon_load_test.sh
File metadata and controls
executable file
·230 lines (197 loc) · 6.72 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/bash
# Test Horizon dashboard performance with 100+ resources
set -e
echo "=== Horizon Performance Load Test ==="
# Configuration
export OS_AUTH_URL=http://localhost:35357/v3
export OS_USERNAME=admin
export OS_PASSWORD=secret
export OS_PROJECT_NAME=default
export OS_DOMAIN_NAME=Default
echo "1. Authenticating..."
TOKEN=$(openstack token issue -f value -c id)
if [ -z "$TOKEN" ]; then
echo "✗ Failed to authenticate"
exit 1
fi
echo "✓ Authentication successful"
echo "2. Checking existing resource counts..."
INITIAL_SERVERS=$(openstack server list -f value | wc -l)
INITIAL_NETWORKS=$(openstack network list -f value | wc -l)
INITIAL_VOLUMES=$(openstack volume list -f value | wc -l)
echo " Current resources:"
echo " Servers: $INITIAL_SERVERS"
echo " Networks: $INITIAL_NETWORKS"
echo " Volumes: $INITIAL_VOLUMES"
echo "3. Creating test resources (this may take a few minutes)..."
# We'll create a moderate number of resources for testing
# 50 of each type = 150 total resources
echo " Creating networks..."
NETWORK_IDS=()
for i in $(seq 1 50); do
NET_ID=$(openstack network create "perf-test-net-$i" -f value -c id 2>/dev/null)
if [ -n "$NET_ID" ]; then
NETWORK_IDS+=("$NET_ID")
if [ $((i % 10)) -eq 0 ]; then
echo " Created $i networks..."
fi
fi
done
echo " ✓ Created ${#NETWORK_IDS[@]} networks"
echo " Creating volumes..."
VOLUME_IDS=()
for i in $(seq 1 50); do
VOL_ID=$(openstack volume create "perf-test-vol-$i" --size 1 -f value -c id 2>/dev/null)
if [ -n "$VOL_ID" ]; then
VOLUME_IDS+=("$VOL_ID")
if [ $((i % 10)) -eq 0 ]; then
echo " Created $i volumes..."
fi
fi
done
echo " ✓ Created ${#VOLUME_IDS[@]} volumes"
echo " Creating servers (in stub mode)..."
SERVER_IDS=()
FLAVOR_ID=$(openstack flavor list -f value -c ID | head -1)
for i in $(seq 1 50); do
# In stub mode, this is fast; in real mode, would be slower
SERVER_ID=$(openstack server create "perf-test-server-$i" \
--flavor "$FLAVOR_ID" \
--image test-image \
-f value -c id 2>/dev/null || echo "")
if [ -n "$SERVER_ID" ]; then
SERVER_IDS+=("$SERVER_ID")
if [ $((i % 10)) -eq 0 ]; then
echo " Created $i servers..."
fi
fi
done
echo " ✓ Created ${#SERVER_IDS[@]} servers"
TOTAL_CREATED=$((${#NETWORK_IDS[@]} + ${#VOLUME_IDS[@]} + ${#SERVER_IDS[@]}))
echo " Total resources created: $TOTAL_CREATED"
if [ $TOTAL_CREATED -lt 100 ]; then
echo " ⚠ Created fewer than 100 resources (may be expected)"
fi
echo "4. Testing API response times..."
# Test server list performance
START=$(date +%s%N)
SERVER_COUNT=$(openstack server list -f value | wc -l)
END=$(date +%s%N)
SERVER_TIME=$(( (END - START) / 1000000 )) # Convert to milliseconds
echo " Server list: ${SERVER_TIME}ms (${SERVER_COUNT} servers)"
# Test network list performance
START=$(date +%s%N)
NETWORK_COUNT=$(openstack network list -f value | wc -l)
END=$(date +%s%N)
NETWORK_TIME=$(( (END - START) / 1000000 ))
echo " Network list: ${NETWORK_TIME}ms (${NETWORK_COUNT} networks)"
# Test volume list performance
START=$(date +%s%N)
VOLUME_COUNT=$(openstack volume list -f value | wc -l)
END=$(date +%s%N)
VOLUME_TIME=$(( (END - START) / 1000000 ))
echo " Volume list: ${VOLUME_TIME}ms (${VOLUME_COUNT} volumes)"
# Test image list performance
START=$(date +%s%N)
IMAGE_COUNT=$(openstack image list -f value | wc -l)
END=$(date +%s%N)
IMAGE_TIME=$(( (END - START) / 1000000 ))
echo " Image list: ${IMAGE_TIME}ms (${IMAGE_COUNT} images)"
echo "5. Testing pagination support..."
# Test if pagination parameters work
LIMIT=10
START=$(date +%s%N)
LIMITED_SERVERS=$(openstack server list --limit $LIMIT -f value | wc -l)
END=$(date +%s%N)
PAGINATED_TIME=$(( (END - START) / 1000000 ))
echo " Paginated query (limit=$LIMIT): ${PAGINATED_TIME}ms (returned ${LIMITED_SERVERS} servers)"
if [ "$LIMITED_SERVERS" -le "$LIMIT" ]; then
echo " ✓ Pagination working correctly"
PAGINATION="PASS"
else
echo " ✗ Pagination not respecting limit"
PAGINATION="FAIL"
fi
echo "6. Testing concurrent API requests..."
# Simulate multiple Horizon dashboard panels loading simultaneously
START=$(date +%s%N)
(
openstack server list -f value > /dev/null 2>&1 &
openstack network list -f value > /dev/null 2>&1 &
openstack volume list -f value > /dev/null 2>&1 &
openstack image list -f value > /dev/null 2>&1 &
wait
)
END=$(date +%s%N)
CONCURRENT_TIME=$(( (END - START) / 1000000 ))
echo " Concurrent requests: ${CONCURRENT_TIME}ms (4 parallel queries)"
echo "7. Evaluating performance thresholds..."
# Horizon dashboard load target: < 3000ms for all initial API calls
THRESHOLD=3000
TOTAL_TIME=$((SERVER_TIME + NETWORK_TIME + VOLUME_TIME + IMAGE_TIME))
echo " Total time for 4 API calls: ${TOTAL_TIME}ms"
echo " Target threshold: ${THRESHOLD}ms"
if [ $TOTAL_TIME -lt $THRESHOLD ]; then
echo " ✓ Performance within acceptable range"
PERFORMANCE="PASS"
else
echo " ⚠ Performance slower than target (${TOTAL_TIME}ms > ${THRESHOLD}ms)"
PERFORMANCE="WARN"
fi
# Individual query thresholds
QUERY_THRESHOLD=2000
SLOW_QUERIES=()
if [ $SERVER_TIME -gt $QUERY_THRESHOLD ]; then
SLOW_QUERIES+=("server list: ${SERVER_TIME}ms")
fi
if [ $NETWORK_TIME -gt $QUERY_THRESHOLD ]; then
SLOW_QUERIES+=("network list: ${NETWORK_TIME}ms")
fi
if [ $VOLUME_TIME -gt $QUERY_THRESHOLD ]; then
SLOW_QUERIES+=("volume list: ${VOLUME_TIME}ms")
fi
if [ ${#SLOW_QUERIES[@]} -gt 0 ]; then
echo " ⚠ Slow queries detected:"
for query in "${SLOW_QUERIES[@]}"; do
echo " - $query"
done
fi
echo "8. Cleanup..."
echo " Deleting test resources..."
# Delete servers
for server_id in "${SERVER_IDS[@]}"; do
openstack server delete "$server_id" 2>/dev/null || true
done
# Delete volumes
for vol_id in "${VOLUME_IDS[@]}"; do
openstack volume delete "$vol_id" 2>/dev/null || true
done
# Delete networks
for net_id in "${NETWORK_IDS[@]}"; do
openstack network delete "$net_id" 2>/dev/null || true
done
echo " ✓ Cleanup complete"
echo ""
echo "=== Performance Test Results ==="
echo "Resources Created: $TOTAL_CREATED"
echo ""
echo "Query Performance:"
echo " Server list: ${SERVER_TIME}ms"
echo " Network list: ${NETWORK_TIME}ms"
echo " Volume list: ${VOLUME_TIME}ms"
echo " Image list: ${IMAGE_TIME}ms"
echo " Total time: ${TOTAL_TIME}ms"
echo ""
echo "Concurrent: ${CONCURRENT_TIME}ms (4 parallel)"
echo "Pagination: $PAGINATION"
echo ""
if [ "$PERFORMANCE" = "PASS" ] && [ "$PAGINATION" = "PASS" ]; then
echo "✓ Performance test PASSED"
echo " Horizon dashboard should load smoothly with 100+ resources"
exit 0
else
echo "⚠ Performance test completed with warnings"
echo " Dashboard may experience slowness with large resource counts"
echo " Consider database indexing and query optimization"
exit 0 # Don't fail, just warn
fi