blob: 606f05ec8325b875cfef5b0b536b6cde0d5af4f5 [file] [log] [blame]
Sean Dagued0931212012-10-04 16:06:44 -04001# lib/tempest
2
3# Dependencies:
4# ``functions`` file
Attila Fazekas2aa35172012-12-05 20:03:40 +01005# ``lib/nova`` service is runing
Sean Dagued0931212012-10-04 16:06:44 -04006# <list other global vars that are assumed to be defined>
Attila Fazekas2aa35172012-12-05 20:03:40 +01007# - DEST
8# - ADMIN_PASSWORD
9# - OS_USERNAME
10# - DEFAULT_IMAGE_NAME
11# - S3_SERVICE_PORT
12# - SERVICE_HOST
13# - BASE_SQL_CONN ``lib/database`` declares
14# Optional Dependencies:
15# IDENTITY_*
16# ALT_* (similar vars exists in keystone_data.sh)
17# IMAGE_*
18# LIVE_MIGRATION_AVAILABLE
19# DEFAULT_INSTANCE_TYPE
20# DEFAULT_INSTANCE_USER
21# USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION
Sean Dagued0931212012-10-04 16:06:44 -040022# ``stack.sh`` calls the entry points in this order:
23#
Attila Fazekas2aa35172012-12-05 20:03:40 +010024# install_tempest
25# configure_tempest
26# init_tempest
27## start_tempest
28## stop_tempest
29## cleanup_tempest
Sean Dagued0931212012-10-04 16:06:44 -040030
31# Save trace setting
32XTRACE=$(set +o | grep xtrace)
33set +o xtrace
34
Sean Dagued0931212012-10-04 16:06:44 -040035# Defaults
36# --------
37
38# <define global variables here that belong to this project>
39
40# Set up default directories
Attila Fazekas2aa35172012-12-05 20:03:40 +010041NOVA_SOURCE_DIR=$DEST/nova
Sean Dagued0931212012-10-04 16:06:44 -040042TEMPEST_DIR=$DEST/tempest
Attila Fazekas2aa35172012-12-05 20:03:40 +010043TEMPEST_CONF_DIR=$TEMPEST_DIR/etc
44TEMPEST_CONF=$TEMPEST_CONF_DIR/tempest.conf
45
46BUILD_INTERVAL=3
47BUILD_TIMEOUT=400
Sean Dagued0931212012-10-04 16:06:44 -040048
49# Entry Points
50# ------------
51
52
53# configure_tempest() - Set config files, create data dirs, etc
54function configure_tempest() {
Attila Fazekas2aa35172012-12-05 20:03:40 +010055 local IMAGE_LINES
56 local IMAGES
57 local NUM_IMAGES
58 local IMAGE_UUID
59 local IMAGE_UUID_ALT
60 local errexit
61
62 #TODO(afazekas):
Sean Dagued0931212012-10-04 16:06:44 -040063 # sudo python setup.py deploy
Attila Fazekas2aa35172012-12-05 20:03:40 +010064
65 # This function exits on an error so that errors don't compound and you see
66 # only the first error that occured.
67 errexit=$(set +o | grep errexit)
68 set -o errexit
69
70 #Save IFS
71 ifs=$IFS
72
73 # Glance should already contain images to be used in tempest
74 # testing. Here we simply look for images stored in Glance
75 # and set the appropriate variables for use in the tempest config
76 # We ignore ramdisk and kernel images, look for the default image
77 # DEFAULT_IMAGE_NAME. If not found, we set the IMAGE_UUID to the
78 # first image returned and set IMAGE_UUID_ALT to the second,
79 # if there is more than one returned...
80 # ... Also ensure we only take active images, so we don't get snapshots in process
81 IMAGE_LINES=`glance image-list`
82 IFS=$'\n\r'
83 IMAGES=""
84 for line in $IMAGE_LINES; do
85 if [ -z $DEFAULT_IMAGE_NAME ]; then
86 IMAGES="$IMAGES `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | cut -d' ' -f2`"
87 else
88 IMAGES="$IMAGES `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | grep "$DEFAULT_IMAGE_NAME" | cut -d' ' -f2`"
89 fi
90 done
91 # Create array of image UUIDs...
92 IFS=" "
93 IMAGES=($IMAGES)
94 NUM_IMAGES=${#IMAGES[*]}
95 echo "Found $NUM_IMAGES images"
96 if [[ $NUM_IMAGES -eq 0 ]]; then
97 echo "Found no valid images to use!"
98 exit 1
99 fi
100 IMAGE_UUID=${IMAGES[0]}
101 IMAGE_UUID_ALT=$IMAGE_UUID
102 if [[ $NUM_IMAGES -gt 1 ]]; then
103 IMAGE_UUID_ALT=${IMAGES[1]}
104 fi
105
106 # Create tempest.conf from tempest.conf.sample
107 # copy every time, because the image UUIDS are going to change
108 cp $TEMPEST_CONF.sample $TEMPEST_CONF
109
110 IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
111 IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
112 IDENTITY_PORT=${IDENTITY_PORT:-5000}
113 # TODO(jaypipes): This is dumb and needs to be removed
114 # from the Tempest configuration file entirely...
115 IDENTITY_PATH=${IDENTITY_PATH:-tokens}
116
117 PASSWORD=${ADMIN_PASSWORD:-secrete}
118
119 # See files/keystone_data.sh where alt_demo user
120 # and tenant are set up...
121 ALT_USERNAME=${ALT_USERNAME:-alt_demo}
122 ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo}
123
124 # Check Nova for existing flavors and, if set, look for the
125 # DEFAULT_INSTANCE_TYPE and use that. Otherwise, just use the first flavor.
126 FLAVOR_LINES=`nova flavor-list`
127 IFS="$(echo -e "\n\r")"
128 FLAVORS=""
129 for line in $FLAVOR_LINES; do
130 if [ -z $DEFAULT_INSTANCE_TYPE ]; then
131 FLAVORS="$FLAVORS `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`"
132 else
133 FLAVORS="$FLAVORS `echo $line | grep -v "^\(|\s*ID\|+--\)" | grep "$DEFAULT_INSTANCE_TYPE" | cut -d' ' -f2`"
134 fi
135 done
136
137 IFS=" "
138 FLAVORS=($FLAVORS)
139 NUM_FLAVORS=${#FLAVORS[*]}
140 echo "Found $NUM_FLAVORS flavors"
141 if [[ $NUM_FLAVORS -eq 0 ]]; then
142 echo "Found no valid flavors to use!"
143 exit 1
144 fi
145 FLAVOR_REF=${FLAVORS[0]}
146 FLAVOR_REF_ALT=$FLAVOR_REF
147 if [[ $NUM_FLAVORS -gt 1 ]]; then
148 FLAVOR_REF_ALT=${FLAVORS[1]}
149 fi
150
151 # Timeouts
152 iniset $TEMPEST_CONF compute build_timeout $BUILD_TIMEOUT
153 iniset $TEMPEST_CONF volume build_timeout $BUILD_TIMEOUT
154 iniset $TEMPEST_CONF boto build_timeout $BUILD_TIMEOUT
155 iniset $TEMPEST_CONF compute build_interval $BUILD_INTERVAL
156 iniset $TEMPEST_CONF volume build_interval $BUILD_INTERVAL
157 iniset $TEMPEST_CONF boto build_interval $BUILD_INTERVAL
158 iniset $TEMPEST_CONF boto http_socket_timeout 5
159
160 iniset $TEMPEST_CONF identity use_ssl $IDENTITY_USE_SSL
161 iniset $TEMPEST_CONF identity host $IDENTITY_HOST
162 iniset $TEMPEST_CONF identity port $IDENTITY_PORT
163 iniset $TEMPEST_CONF identity path $IDENTITY_PATH
164
165 iniset $TEMPEST_CONF compute password "$PASSWORD"
166 iniset $TEMPEST_CONF compute alt_username $ALT_USERNAME
167 iniset $TEMPEST_CONF compute alt_password "$PASSWORD"
168 iniset $TEMPEST_CONF compute alt_tenant_name $ALT_TENANT_NAME
169 iniset $TEMPEST_CONF compute resize_available False
170 iniset $TEMPEST_CONF compute change_password_available False
171 iniset $TEMPEST_CONF compute compute_log_level ERROR
172 #Skip until #1074039 is fixed
173 iniset $TEMPEST_CONF compute run_ssh False
174 iniset $TEMPEST_CONF compute ssh_user ${DEFAULT_INSTANCE_USER:-$OS_USERNAME}
175 iniset $TEMPEST_CONF compute network_for_ssh private
176 iniset $TEMPEST_CONF compute ip_version_for_ssh 4
177 iniset $TEMPEST_CONF compute ssh_timeout 4
178 iniset $TEMPEST_CONF compute image_ref $IMAGE_UUID
179 iniset $TEMPEST_CONF compute image_ref_alt $IMAGE_UUID_ALT
180 iniset $TEMPEST_CONF compute flavor_ref $FLAVOR_REF
181 iniset $TEMPEST_CONF compute flavor_ref_alt $FLAVOR_REF_ALT
182 iniset $TEMPEST_CONF compute source_dir $NOVA_SOURCE_DIR
183 iniset $TEMPEST_CONF compute live_migration_available ${LIVE_MIGRATION_AVAILABLE:-False}
184 iniset $TEMPEST_CONF compute use_block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
185 # Inherited behavior, might be wrong
186 iniset $TEMPEST_CONF compute bin_dir $NOVA_BIN_DIR
187 # TODO(jaypipes): Create the key file here... right now, no whitebox
188 # tests actually use a key.
189 iniset $TEMPEST_CONF compute path_to_private_key $TEMPEST_DIR/id_rsa
190 iniset $TEMPEST_CONF compute db_uri $BASE_SQL_CONN/nova
191
192 # image
193 iniset $TEMPEST_CONF image host ${IMAGE_HOST:-127.0.0.1}
194 iniset $TEMPEST_CONF image port ${IMAGE_PORT:-9292}
195 iniset $TEMPEST_CONF image password "$PASSWORD"
196
197 # identity-admin
198 iniset $TEMPEST_CONF "identity-admin" password "$PASSWORD"
199
200 # compute admin
201 iniset $TEMPEST_CONF "compute-admin" password "$PASSWORD"
202
203 # network
204 iniset $TEMPEST_CONF network api_version 2.0
205
206 #boto
207 iniset $TEMPEST_CONF boto ec2_url "http://$SERVICE_HOST:8773/services/Cloud"
208 iniset $TEMPEST_CONF boto s3_url "http://$SERVICE_HOST:${S3_SERVICE_PORT:-3333}"
209
210 echo "Created tempest configuration file:"
211 cat $TEMPEST_CONF
212
213 # Restore IFS
214 IFS=$ifs
215 #Restore errexit
216 $errexit
Sean Dagued0931212012-10-04 16:06:44 -0400217}
218
219
220# install_tempest() - Collect source and prepare
221function install_tempest() {
222 git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH
Jeremy Stanley9a352da2012-11-28 17:22:39 +0000223
224 # Tempest doesn't satisfy its dependencies on its own, so
225 # install them here instead.
jiajun xud75bc1f2012-12-04 08:51:35 +0800226 pip_install -r $TEMPEST_DIR/tools/pip-requires
Sean Dagued0931212012-10-04 16:06:44 -0400227}
228
Sean Dagued0931212012-10-04 16:06:44 -0400229# Restore xtrace
230$XTRACE