Repository navigation
Expand file tree
/
Copy pathquick_test.sh
More file actions
executable file
·256 lines (220 loc) · 7.55 KB
/
Copy pathquick_test.sh
File metadata and controls
executable file
·256 lines (220 loc) · 7.55 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#!/bin/bash
# Simple Lightstack Integration Test
# Quick validation of all services
# Note: NOT using set -e because we explicitly track pass/fail counts
# and don't want the script to exit on first failure
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
PASSED=0
FAILED=0
test_endpoint() {
local name=$1
local url=$2
if curl -s -f "$url" > /dev/null 2>&1; then
echo -e "${GREEN}✓${NC} $name"
((PASSED++))
else
echo -e "${RED}✗${NC} $name"
((FAILED++))
fi
}
test_auth() {
echo "Testing Keystone Authentication..."
response=$(curl -s -i -X POST "http://localhost:35357/v3/auth/tokens" \
-H "Content-Type: application/json" \
-d '{
"auth": {
"identity": {
"methods": ["password"],
"password": {
"user": {
"name": "admin",
"domain": {"name": "Default"},
"password": "secret"
}
}
},
"scope": {
"project": {
"name": "default",
"domain": {"name": "Default"}
}
}
}
}')
TOKEN=$(echo "$response" | grep -i "X-Subject-Token:" | awk '{print $2}' | tr -d '\r')
if [ -n "$TOKEN" ]; then
echo -e "${GREEN}✓${NC} Scoped authentication"
((PASSED++))
export OS_TOKEN=$TOKEN
# Check for catalog
if echo "$response" | grep -q "catalog"; then
echo -e "${GREEN}✓${NC} Service catalog present"
((PASSED++))
else
echo -e "${RED}✗${NC} Service catalog missing"
((FAILED++))
fi
else
echo -e "${RED}✗${NC} Authentication failed"
((FAILED++))
return 1
fi
}
test_nova() {
echo -e "\nTesting Nova..."
# List servers
response=$(curl -s -H "X-Auth-Token: $OS_TOKEN" "http://localhost:8774/v2.1/servers")
if echo "$response" | grep -q "servers"; then
echo -e "${GREEN}✓${NC} List servers"
((PASSED++))
else
echo -e "${RED}✗${NC} List servers"
((FAILED++))
fi
# List flavors
response=$(curl -s -H "X-Auth-Token: $OS_TOKEN" "http://localhost:8774/v2.1/flavors")
if echo "$response" | grep -q "flavors"; then
echo -e "${GREEN}✓${NC} List flavors"
((PASSED++))
else
echo -e "${RED}✗${NC} List flavors"
((FAILED++))
fi
# List hypervisors
response=$(curl -s -H "X-Auth-Token: $OS_TOKEN" "http://localhost:8774/v2.1/os-hypervisors")
if echo "$response" | grep -q "hypervisors"; then
echo -e "${GREEN}✓${NC} List hypervisors"
((PASSED++))
else
echo -e "${RED}✗${NC} List hypervisors"
((FAILED++))
fi
}
test_neutron() {
echo -e "\nTesting Neutron..."
# List networks
response=$(curl -s -H "X-Auth-Token: $OS_TOKEN" "http://localhost:9696/v2.0/networks")
if echo "$response" | grep -q "networks"; then
echo -e "${GREEN}✓${NC} List networks"
((PASSED++))
else
echo -e "${RED}✗${NC} List networks"
((FAILED++))
fi
# Create network
response=$(curl -s -X POST -H "X-Auth-Token: $OS_TOKEN" \
-H "Content-Type: application/json" \
"http://localhost:9696/v2.0/networks" \
-d '{"network": {"name": "quick-test-net", "admin_state_up": true}}')
if echo "$response" | grep -q "quick-test-net"; then
NETWORK_ID=$(echo "$response" | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
echo -e "${GREEN}✓${NC} Create network ($NETWORK_ID)"
((PASSED++))
# Delete network
curl -s -X DELETE -H "X-Auth-Token: $OS_TOKEN" \
"http://localhost:9696/v2.0/networks/$NETWORK_ID" > /dev/null
echo -e "${GREEN}✓${NC} Delete network"
((PASSED++))
else
echo -e "${RED}✗${NC} Create network"
((FAILED++))
fi
}
test_cinder() {
echo -e "\nTesting Cinder..."
echo "⚠️ Note: Cinder tests skipped - volume backend not available in docker-compose"
# All Cinder tests skipped in docker-compose environment
echo -e "\033[0;33m⊘\033[0m List volumes (skipped - no backend)"
echo -e "\033[0;33m⊘\033[0m Create volume (skipped - no backend)"
echo -e "\033[0;33m⊘\033[0m Delete volume (skipped - no backend)"
}
test_glance() {
echo -e "\nTesting Glance..."
# List images
response=$(curl -s -H "X-Auth-Token: $OS_TOKEN" "http://localhost:9292/v2/images")
if echo "$response" | grep -q "images"; then
echo -e "${GREEN}✓${NC} List images"
((PASSED++))
else
echo -e "${RED}✗${NC} List images"
((FAILED++))
fi
# Create image metadata
response=$(curl -s -X POST -H "X-Auth-Token: $OS_TOKEN" \
-H "Content-Type: application/json" \
"http://localhost:9292/v2/images" \
-d '{"name": "quick-test-img", "disk_format": "raw", "container_format": "bare"}')
if echo "$response" | grep -q "quick-test-img"; then
IMAGE_ID=$(echo "$response" | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
echo -e "${GREEN}✓${NC} Create image metadata ($IMAGE_ID)"
((PASSED++))
# Upload image data (small file)
dd if=/dev/zero of=/tmp/test.raw bs=1M count=1 2>/dev/null
http_code=$(curl -s -w "%{http_code}" -o /dev/null -X PUT \
-H "X-Auth-Token: $OS_TOKEN" \
-H "Content-Type: application/octet-stream" \
"http://localhost:9292/v2/images/${IMAGE_ID}/file" \
--data-binary @/tmp/test.raw)
rm -f /tmp/test.raw
if [ "$http_code" = "204" ]; then
echo -e "${GREEN}✓${NC} Upload image data"
((PASSED++))
else
echo -e "${RED}✗${NC} Upload image data (HTTP $http_code)"
((FAILED++))
fi
# Download image data
http_code=$(curl -s -w "%{http_code}" -o /tmp/downloaded.raw \
-H "X-Auth-Token: $OS_TOKEN" \
"http://localhost:9292/v2/images/${IMAGE_ID}/file")
if [ "$http_code" = "200" ]; then
echo -e "${GREEN}✓${NC} Download image data"
((PASSED++))
else
echo -e "${RED}✗${NC} Download image data (HTTP $http_code)"
((FAILED++))
fi
rm -f /tmp/downloaded.raw
# Delete image
curl -s -X DELETE -H "X-Auth-Token: $OS_TOKEN" \
"http://localhost:9292/v2/images/$IMAGE_ID" > /dev/null
echo -e "${GREEN}✓${NC} Delete image"
((PASSED++))
else
echo -e "${RED}✗${NC} Create image"
((FAILED++))
fi
}
# Main
echo "=========================================="
echo " Lightstack Quick Integration Test"
echo "=========================================="
echo ""
# Version discovery
echo "Testing Version Discovery..."
test_endpoint "Keystone /v3" "http://localhost:35357/v3"
test_endpoint "Nova /v2.1" "http://localhost:8774/v2.1"
test_endpoint "Neutron /v2.0" "http://localhost:9696/v2.0"
test_endpoint "Glance /v2" "http://localhost:9292/v2"
echo ""
test_auth
test_nova
test_neutron
test_cinder
test_glance
echo ""
echo "=========================================="
echo " Test Summary"
echo "=========================================="
echo "Total Passed: $PASSED"
echo "Total Failed: $FAILED"
echo ""
if [ $FAILED -eq 0 ]; then
echo -e "${GREEN}✓ All tests passed!${NC}"
exit 0
else
echo -e "${RED}✗ Some tests failed${NC}"
exit 1
fi