Repository navigation
Expand file tree
/
Copy pathhorizon_dashboard_access_test.sh
More file actions
executable file
·165 lines (140 loc) · 6.46 KB
/
Copy pathhorizon_dashboard_access_test.sh
File metadata and controls
executable file
·165 lines (140 loc) · 6.46 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
#!/bin/bash
# Test Horizon dashboard access and service panel availability
set -euo pipefail
echo "=== Horizon Dashboard Access Test ==="
# Configuration
# Parameter defaults, so a caller who already sourced ~/.lightstack-env (or exported OS_* vars)
# keeps their own values instead of having them overwritten.
export OS_AUTH_URL="${OS_AUTH_URL:-http://localhost:35357/v3}"
export OS_USERNAME="${OS_USERNAME:-admin}"
export OS_PASSWORD="${OS_PASSWORD:-secret}"
export OS_PROJECT_NAME="${OS_PROJECT_NAME:-default}"
export OS_DOMAIN_NAME="${OS_DOMAIN_NAME:-Default}"
echo "1. Authenticating to lightstack..."
TOKEN=$(openstack token issue -f value -c id)
if [ -z "$TOKEN" ]; then
echo "✗ Failed to get authentication token"
exit 1
fi
echo "✓ Authentication successful"
echo "2. Verifying service catalog..."
CATALOG=$(openstack catalog list -f json)
# Check all 5 required services
REQUIRED_SERVICES=("identity" "compute" "network" "volume" "image")
MISSING_SERVICES=()
for service in "${REQUIRED_SERVICES[@]}"; do
if echo "$CATALOG" | jq -e ".[] | select(.Type == \"$service\")" > /dev/null; then
echo " ✓ Service '$service' found in catalog"
else
echo " ✗ Service '$service' NOT found in catalog"
MISSING_SERVICES+=("$service")
fi
done
if [ ${#MISSING_SERVICES[@]} -gt 0 ]; then
echo "✗ Missing services: ${MISSING_SERVICES[*]}"
exit 1
fi
echo "3. Verifying service endpoints..."
# Check each service has public endpoint
for service in "${REQUIRED_SERVICES[@]}"; do
ENDPOINT=$(printf '%s' "$CATALOG" | jq -r --arg s "$service" 'first(.[] | select(.Type == $s) | .Endpoints[] | select(.interface == "public") | .url) // empty')
if [ -z "$ENDPOINT" ]; then
echo " ✗ Service '$service' missing public endpoint"
exit 1
else
echo " ✓ Service '$service' public endpoint: $ENDPOINT"
fi
done
echo "4. Testing endpoint connectivity..."
# Test each service endpoint responds
NOVA_ENDPOINT=$(printf '%s' "$CATALOG" | jq -r 'first(.[] | select(.Type == "compute") | .Endpoints[] | select(.interface == "public") | .url) // empty')
NEUTRON_ENDPOINT=$(printf '%s' "$CATALOG" | jq -r 'first(.[] | select(.Type == "network") | .Endpoints[] | select(.interface == "public") | .url) // empty')
CINDER_ENDPOINT=$(printf '%s' "$CATALOG" | jq -r 'first(.[] | select(.Type == "volume") | .Endpoints[] | select(.interface == "public") | .url) // empty')
GLANCE_ENDPOINT=$(printf '%s' "$CATALOG" | jq -r 'first(.[] | select(.Type == "image") | .Endpoints[] | select(.interface == "public") | .url) // empty')
# Nova version check
NOVA_RESPONSE=$(curl -s -H "X-Auth-Token: $TOKEN" "$NOVA_ENDPOINT")
if echo "$NOVA_RESPONSE" | jq -e '.versions' > /dev/null 2>&1 || echo "$NOVA_RESPONSE" | jq -e '.version' > /dev/null 2>&1; then
echo " ✓ Nova endpoint responding"
else
echo " ✗ Nova endpoint not responding properly"
echo " Response: $NOVA_RESPONSE"
exit 1
fi
# Neutron version check
NEUTRON_RESPONSE=$(curl -s -H "X-Auth-Token: $TOKEN" "$NEUTRON_ENDPOINT")
if echo "$NEUTRON_RESPONSE" | jq -e '.versions' > /dev/null 2>&1 || echo "$NEUTRON_RESPONSE" | jq -e '.version' > /dev/null 2>&1 || echo "$NEUTRON_RESPONSE" | jq -e '.networks' > /dev/null 2>&1; then
echo " ✓ Neutron endpoint responding"
else
echo " ✗ Neutron endpoint not responding properly"
echo " Response: $NEUTRON_RESPONSE"
exit 1
fi
# Cinder version check
CINDER_RESPONSE=$(curl -s -H "X-Auth-Token: $TOKEN" "$CINDER_ENDPOINT")
if echo "$CINDER_RESPONSE" | jq -e '.versions' > /dev/null 2>&1 || echo "$CINDER_RESPONSE" | jq -e '.version' > /dev/null 2>&1; then
echo " ✓ Cinder endpoint responding"
else
echo " ✗ Cinder endpoint not responding properly"
echo " Response: $CINDER_RESPONSE"
exit 1
fi
# Glance version check
GLANCE_RESPONSE=$(curl -s -H "X-Auth-Token: $TOKEN" "$GLANCE_ENDPOINT")
if echo "$GLANCE_RESPONSE" | jq -e '.versions' > /dev/null 2>&1 || echo "$GLANCE_RESPONSE" | jq -e '.version' > /dev/null 2>&1; then
echo " ✓ Glance endpoint responding"
else
echo " ✗ Glance endpoint not responding properly"
echo " Response: $GLANCE_RESPONSE"
exit 1
fi
echo "5. Verifying Horizon-required service names..."
# Check service names match Horizon expectations
KEYSTONE_NAME=$(echo "$CATALOG" | jq -r '.[] | select(.Type == "identity") | .Name')
NOVA_NAME=$(echo "$CATALOG" | jq -r '.[] | select(.Type == "compute") | .Name')
NEUTRON_NAME=$(echo "$CATALOG" | jq -r '.[] | select(.Type == "network") | .Name')
CINDER_NAME=$(echo "$CATALOG" | jq -r '.[] | select(.Type == "volume") | .Name')
GLANCE_NAME=$(echo "$CATALOG" | jq -r '.[] | select(.Type == "image") | .Name')
EXPECTED_NAMES=("keystone:identity" "nova:compute" "neutron:network" "cinder:volume" "glance:image")
NAME_CHECK_FAILED=false
for name_pair in "${EXPECTED_NAMES[@]}"; do
IFS=: read -r expected_name service_type <<< "$name_pair"
actual_name=$(echo "$CATALOG" | jq -r ".[] | select(.Type == \"$service_type\") | .Name")
if [ "$actual_name" = "$expected_name" ]; then
echo " ✓ Service '$service_type' has correct name '$expected_name'"
else
echo " ✗ Service '$service_type' has name '$actual_name' (expected '$expected_name')"
NAME_CHECK_FAILED=true
fi
done
if [ "$NAME_CHECK_FAILED" = true ]; then
echo "⚠ Service name mismatch detected (may affect Horizon compatibility)"
# Don't fail the test, just warn
fi
echo "6. Testing project/tenant switching..."
# Verify token has project info (required for Horizon project switcher)
PROJECT_INFO=$(openstack token issue -f json)
PROJECT_ID=$(echo "$PROJECT_INFO" | jq -r '.project_id')
PROJECT_NAME=$(echo "$PROJECT_INFO" | jq -r '.project_name // .project')
if [ -z "$PROJECT_ID" ] || [ "$PROJECT_ID" = "null" ]; then
echo "✗ Token missing project_id (required for Horizon)"
exit 1
fi
echo " ✓ Token has project context: $PROJECT_NAME ($PROJECT_ID)"
echo "7. Verifying user role information..."
# Horizon needs role information for UI display
ROLES=$(openstack role assignment list --user $OS_USERNAME --project $OS_PROJECT_NAME -f json)
ROLE_COUNT=$(echo "$ROLES" | jq '. | length')
if [ "$ROLE_COUNT" -gt 0 ]; then
echo " ✓ User has $ROLE_COUNT role(s) assigned"
else
echo " ✗ User has no roles assigned (Horizon may not function properly)"
exit 1
fi
echo ""
echo "=== Test Result: PASS ==="
echo "✓ All service catalog checks passed"
echo "✓ All endpoints responding correctly"
echo "✓ Service naming compatible with Horizon"
echo "✓ Authentication and RBAC working"
echo ""
echo "Lightstack is ready for Horizon dashboard integration"