blob: f4172bcb9d8d1c765f903d778977fef606658c18 [file] [log] [blame]
Dean Troyer10670d12012-01-24 11:26:15 -06001#!/usr/bin/env bash
2
3# Test OpenStack client enviroment variable handling
4
5# Verify client workage
6VERIFY=${1:-""}
7
8# Settings
9# ========
10
11# Use openrc + stackrc + localrc for settings
12pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null
13source ./openrc
14popd >/dev/null
15
16# Unset all of the known NOVA_ vars
17unset NOVA_API_KEY
18unset NOVA_ENDPOINT_NAME
19unset NOVA_PASSWORD
20unset NOVA_PROJECT_ID
21unset NOVA_REGION_NAME
22unset NOVA_URL
23unset NOVA_USERNAME
24unset NOVA_VERSION
25
26# Make sure we have the vars we are expecting
27function is_set() {
28 local var=\$"$1"
29 eval echo $1=$var
30 if eval "[ -z $var ]"; then
31 return 1
32 fi
33 return 0
34}
35
36for i in OS_TENANT_NAME OS_USERNAME OS_PASSWORD OS_AUTH_URL; do
37 is_set $i
38 if [[ $? -ne 0 ]]; then
39 ABORT=1
40 fi
41done
42if [[ -n "$ABORT" ]]; then
43 exit 1
44fi
45
46# Set global return
47RETURN=0
48
49# Keystone client
50# ---------------
51if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
52 if [[ "$SKIP_EXERCISES" =~ "key" ]] ; then
53 STATUS_KEYSTONE="Skipped"
54 else
55 if [[ -n "$VERIFY" ]]; then
56 # Save original environment
57 xOS_AUTH_URL=$OS_AUTH_URL
58 xOS_TENANT_NAME=$OS_TENANT_NAME
59 xOS_USERNAME=$OS_USERNAME
60 xOS_PASSWORD=$OS_PASSWORD
61 # keystone can't handle a trailing '/'
62 export OS_AUTH_URL=${OS_AUTH_URL%/}
63 # does any non-admin request work?
64 export OS_USERNAME=admin
65 export OS_TENANT_NAME=admin
66 fi
67
68 echo -e "\nTest Keystone"
69 if keystone service-list; then
70 STATUS_KEYSTONE="Succeeded"
71 else
72 STATUS_KEYSTONE="Failed"
73 RETURN=1
74 fi
75 if [[ -n "$VERIFY" ]]; then
76 # Save original environment
77 OS_AUTH_URL=$xOS_AUTH_URL
78 OS_TENANT_NAME=$xOS_TENANT_NAME
79 OS_USERNAME=$xOS_USERNAME
80 OS_PASSWORD=$xOS_PASSWORD
81 fi
82 fi
83fi
84
85# Nova client
86# -----------
87
88if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
89 if [[ "$SKIP_EXERCISES" =~ "n-api" ]] ; then
90 STATUS_NOVA="Skipped"
91 else
92 if [[ -n "$VERIFY" ]]; then
93 # Known novaclient breakage:
94 # NOVA_VERSION must be set or nova silently fails
95 export NOVA_VERSION=2
96 fi
97
98 echo -e "\nTest Nova"
99 if nova flavor-list; then
100 STATUS_NOVA="Succeeded"
101 else
102 STATUS_NOVA="Failed"
103 RETURN=1
104 fi
105 fi
106fi
107
108# Glance client
109# -------------
110
111if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
112 if [[ "$SKIP_EXERCISES" =~ "g-api" ]] ; then
113 STATUS_GLANCE="Skipped"
114 else
115 if [[ -n "$VERIFY" ]]; then
116 # Known glance client differage:
117 export OS_AUTH_TENANT=$OS_TENANT_NAME
118 export OS_AUTH_USER=$OS_USERNAME
119 export OS_AUTH_KEY=$OS_PASSWORD
120 export OS_AUTH_STRATEGY=keystone
121 fi
122
123 echo -e "\nTest Glance"
124 if glance index; then
125 STATUS_GLANCE="Succeeded"
126 else
127 STATUS_GLANCE="Failed"
128 RETURN=1
129 fi
130 fi
131fi
132
133# Swift client
134# ------------
135
136if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
137 if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then
138 STATUS_SWIFT="Skipped"
139 else
140 echo -e "\nTest Swift"
141 # FIXME(dtroyer): implement swift test
142 if true; then
143 STATUS_SWIFT="Succeeded"
144 else
145 STATUS_SWIFT="Failed"
146 RETURN=1
147 fi
148 fi
149fi
150
151# Results
152# -------
153
154function report() {
155 if [[ -n "$2" ]]; then
156 echo "$1: $2"
157 fi
158}
159
160echo -e "\n"
161report "Keystone" $STATUS_KEYSTONE
162report "Nova" $STATUS_NOVA
163report "Glance" $STATUS_GLANCE
164report "Swift" $STATUS_SWIFT
165
166exit $RETURN