blob: a15a5c04d95c14ea85fa722f8e49017771313eeb [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
Dean Troyer80756ea2012-02-01 18:01:01 -060055 # We need to run the keystone test as admin since there doesn't
56 # seem to be anything to test the cli vars that runs as a user
57 # tenant-list should do that, it isn't implemented (yet)
58 xOS_TENANT_NAME=$OS_TENANT_NAME
59 xOS_USERNAME=$OS_USERNAME
60 export OS_USERNAME=admin
61 export OS_TENANT_NAME=admin
Dean Troyer10670d12012-01-24 11:26:15 -060062
63 echo -e "\nTest Keystone"
64 if keystone service-list; then
65 STATUS_KEYSTONE="Succeeded"
66 else
67 STATUS_KEYSTONE="Failed"
68 RETURN=1
69 fi
Dean Troyer80756ea2012-02-01 18:01:01 -060070
71 OS_TENANT_NAME=$xOS_TENANT_NAME
72 OS_USERNAME=$xOS_USERNAME
Dean Troyer10670d12012-01-24 11:26:15 -060073 fi
74fi
75
76# Nova client
77# -----------
78
79if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
80 if [[ "$SKIP_EXERCISES" =~ "n-api" ]] ; then
81 STATUS_NOVA="Skipped"
82 else
Dean Troyer10670d12012-01-24 11:26:15 -060083 echo -e "\nTest Nova"
84 if nova flavor-list; then
85 STATUS_NOVA="Succeeded"
86 else
87 STATUS_NOVA="Failed"
88 RETURN=1
89 fi
90 fi
91fi
92
93# Glance client
94# -------------
95
96if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
97 if [[ "$SKIP_EXERCISES" =~ "g-api" ]] ; then
98 STATUS_GLANCE="Skipped"
99 else
Dean Troyer10670d12012-01-24 11:26:15 -0600100 echo -e "\nTest Glance"
101 if glance index; then
102 STATUS_GLANCE="Succeeded"
103 else
104 STATUS_GLANCE="Failed"
105 RETURN=1
106 fi
107 fi
108fi
109
110# Swift client
111# ------------
112
113if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
114 if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then
115 STATUS_SWIFT="Skipped"
116 else
117 echo -e "\nTest Swift"
Dean Troyer80756ea2012-02-01 18:01:01 -0600118 if swift stat; then
Dean Troyer10670d12012-01-24 11:26:15 -0600119 STATUS_SWIFT="Succeeded"
120 else
121 STATUS_SWIFT="Failed"
122 RETURN=1
123 fi
124 fi
125fi
126
127# Results
128# -------
129
130function report() {
131 if [[ -n "$2" ]]; then
132 echo "$1: $2"
133 fi
134}
135
136echo -e "\n"
137report "Keystone" $STATUS_KEYSTONE
138report "Nova" $STATUS_NOVA
139report "Glance" $STATUS_GLANCE
140report "Swift" $STATUS_SWIFT
141
142exit $RETURN