blob: 185992198f0d30ab1289a2e9e2a311fc618eb45a [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 Fazekas65c08462012-12-07 14:20:51 +01007# - ``DEST``
8# - ``ADMIN_PASSWORD``
9# - ``DEFAULT_IMAGE_NAME``
10# - ``S3_SERVICE_PORT``
11# - ``SERVICE_HOST``
12# - ``BASE_SQL_CONN`` ``lib/database`` declares
Attila Fazekas2aa35172012-12-05 20:03:40 +010013# Optional Dependencies:
Attila Fazekas65c08462012-12-07 14:20:51 +010014# IDENTITY_USE_SSL, IDENTITY_HOST, IDENTITY_PORT, IDENTITY_PATH
Attila Fazekas2aa35172012-12-05 20:03:40 +010015# ALT_* (similar vars exists in keystone_data.sh)
Attila Fazekas65c08462012-12-07 14:20:51 +010016# ``OS_USERNAME``
17# ``IMAGE_PORT``, ``IMAGE_HOST``
18# ``LIVE_MIGRATION_AVAILABLE``
19# ``USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION``
20# ``DEFAULT_INSTANCE_TYPE``
21# ``DEFAULT_INSTANCE_USER``
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 Fazekas65c08462012-12-07 14:20:51 +010055 local image_lines
56 local images
57 local num_images
58 local image_uuid
59 local image_uuid_alt
Attila Fazekas2aa35172012-12-05 20:03:40 +010060 local errexit
Attila Fazekas65c08462012-12-07 14:20:51 +010061 local password
62 local line
63 local flavors
64 local flavors_ref
65 local flavor_lines
Maru Newbya5c774e2012-12-10 10:40:01 +000066 local public_network_id
67 local tenant_networks_reachable
Attila Fazekas2aa35172012-12-05 20:03:40 +010068
69 #TODO(afazekas):
Sean Dagued0931212012-10-04 16:06:44 -040070 # sudo python setup.py deploy
Attila Fazekas2aa35172012-12-05 20:03:40 +010071
72 # This function exits on an error so that errors don't compound and you see
73 # only the first error that occured.
74 errexit=$(set +o | grep errexit)
75 set -o errexit
76
77 #Save IFS
78 ifs=$IFS
79
80 # Glance should already contain images to be used in tempest
81 # testing. Here we simply look for images stored in Glance
82 # and set the appropriate variables for use in the tempest config
83 # We ignore ramdisk and kernel images, look for the default image
Attila Fazekas65c08462012-12-07 14:20:51 +010084 # ``DEFAULT_IMAGE_NAME``. If not found, we set the ``image_uuid`` to the
85 # first image returned and set ``image_uuid_alt`` to the second,
Attila Fazekas2aa35172012-12-05 20:03:40 +010086 # if there is more than one returned...
87 # ... Also ensure we only take active images, so we don't get snapshots in process
Attila Fazekas65c08462012-12-07 14:20:51 +010088 image_lines=`glance image-list`
Attila Fazekas2aa35172012-12-05 20:03:40 +010089 IFS=$'\n\r'
Attila Fazekas65c08462012-12-07 14:20:51 +010090 images=""
91 for line in $image_lines; do
Attila Fazekas2aa35172012-12-05 20:03:40 +010092 if [ -z $DEFAULT_IMAGE_NAME ]; then
Attila Fazekas65c08462012-12-07 14:20:51 +010093 images="$images `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | cut -d' ' -f2`"
Attila Fazekas2aa35172012-12-05 20:03:40 +010094 else
Attila Fazekas65c08462012-12-07 14:20:51 +010095 images="$images `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | grep "$DEFAULT_IMAGE_NAME" | cut -d' ' -f2`"
Attila Fazekas2aa35172012-12-05 20:03:40 +010096 fi
97 done
98 # Create array of image UUIDs...
99 IFS=" "
Attila Fazekas65c08462012-12-07 14:20:51 +0100100 images=($images)
101 num_images=${#images[*]}
102 echo "Found $num_images images"
103 if [[ $num_images -eq 0 ]]; then
Attila Fazekas2aa35172012-12-05 20:03:40 +0100104 echo "Found no valid images to use!"
105 exit 1
106 fi
Attila Fazekas65c08462012-12-07 14:20:51 +0100107 image_uuid=${images[0]}
108 image_uuid_alt=$image_uuid
109 if [[ $num_images -gt 1 ]]; then
110 image_uuid_alt=${images[1]}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100111 fi
112
113 # Create tempest.conf from tempest.conf.sample
114 # copy every time, because the image UUIDS are going to change
115 cp $TEMPEST_CONF.sample $TEMPEST_CONF
116
117 IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
118 IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
119 IDENTITY_PORT=${IDENTITY_PORT:-5000}
120 # TODO(jaypipes): This is dumb and needs to be removed
121 # from the Tempest configuration file entirely...
122 IDENTITY_PATH=${IDENTITY_PATH:-tokens}
123
Attila Fazekas65c08462012-12-07 14:20:51 +0100124 password=${ADMIN_PASSWORD:-secrete}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100125
126 # See files/keystone_data.sh where alt_demo user
127 # and tenant are set up...
128 ALT_USERNAME=${ALT_USERNAME:-alt_demo}
129 ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo}
130
131 # Check Nova for existing flavors and, if set, look for the
Attila Fazekas65c08462012-12-07 14:20:51 +0100132 # ``DEFAULT_INSTANCE_TYPE`` and use that. Otherwise, just use the first flavor.
133 flavor_lines=`nova flavor-list`
134 IFS=$'\r\n'
135 flavors=""
136 for line in $flavor_lines; do
Attila Fazekas2aa35172012-12-05 20:03:40 +0100137 if [ -z $DEFAULT_INSTANCE_TYPE ]; then
Attila Fazekas65c08462012-12-07 14:20:51 +0100138 flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100139 else
Attila Fazekas65c08462012-12-07 14:20:51 +0100140 flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | grep "$DEFAULT_INSTANCE_TYPE" | cut -d' ' -f2`"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100141 fi
142 done
143
144 IFS=" "
Attila Fazekas65c08462012-12-07 14:20:51 +0100145 flavors=($flavors)
146 num_flavors=${#flavors[*]}
147 echo "Found $num_flavors flavors"
148 if [[ $num_flavors -eq 0 ]]; then
Attila Fazekas2aa35172012-12-05 20:03:40 +0100149 echo "Found no valid flavors to use!"
150 exit 1
151 fi
Attila Fazekas65c08462012-12-07 14:20:51 +0100152 flavor_ref=${flavors[0]}
153 flavor_ref_alt=$flavor_ref
154 if [[ $num_flavors -gt 1 ]]; then
155 flavor_ref_alt=${flavors[1]}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100156 fi
157
Maru Newbya5c774e2012-12-10 10:40:01 +0000158 if [ "$Q_USE_NAMESPACE" != "False" ]; then
159 tenant_networks_reachable=false
160 else
161 tenant_networks_reachable=true
162 fi
163
164 if is_service_enabled q-l3; then
165 public_network_id=$(quantum net-list | grep $PUBLIC_NETWORK_NAME | \
166 awk '{print $2}')
167 fi
168
Attila Fazekas2aa35172012-12-05 20:03:40 +0100169 # Timeouts
170 iniset $TEMPEST_CONF compute build_timeout $BUILD_TIMEOUT
171 iniset $TEMPEST_CONF volume build_timeout $BUILD_TIMEOUT
172 iniset $TEMPEST_CONF boto build_timeout $BUILD_TIMEOUT
173 iniset $TEMPEST_CONF compute build_interval $BUILD_INTERVAL
174 iniset $TEMPEST_CONF volume build_interval $BUILD_INTERVAL
175 iniset $TEMPEST_CONF boto build_interval $BUILD_INTERVAL
176 iniset $TEMPEST_CONF boto http_socket_timeout 5
177
178 iniset $TEMPEST_CONF identity use_ssl $IDENTITY_USE_SSL
179 iniset $TEMPEST_CONF identity host $IDENTITY_HOST
180 iniset $TEMPEST_CONF identity port $IDENTITY_PORT
181 iniset $TEMPEST_CONF identity path $IDENTITY_PATH
182
Attila Fazekas65c08462012-12-07 14:20:51 +0100183 iniset $TEMPEST_CONF compute password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100184 iniset $TEMPEST_CONF compute alt_username $ALT_USERNAME
Attila Fazekas65c08462012-12-07 14:20:51 +0100185 iniset $TEMPEST_CONF compute alt_password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100186 iniset $TEMPEST_CONF compute alt_tenant_name $ALT_TENANT_NAME
187 iniset $TEMPEST_CONF compute resize_available False
188 iniset $TEMPEST_CONF compute change_password_available False
189 iniset $TEMPEST_CONF compute compute_log_level ERROR
190 #Skip until #1074039 is fixed
191 iniset $TEMPEST_CONF compute run_ssh False
192 iniset $TEMPEST_CONF compute ssh_user ${DEFAULT_INSTANCE_USER:-$OS_USERNAME}
193 iniset $TEMPEST_CONF compute network_for_ssh private
194 iniset $TEMPEST_CONF compute ip_version_for_ssh 4
195 iniset $TEMPEST_CONF compute ssh_timeout 4
Attila Fazekas65c08462012-12-07 14:20:51 +0100196 iniset $TEMPEST_CONF compute image_ref $image_uuid
197 iniset $TEMPEST_CONF compute image_ref_alt $image_uuid_alt
198 iniset $TEMPEST_CONF compute flavor_ref $flavor_ref
199 iniset $TEMPEST_CONF compute flavor_ref_alt $flavor_ref_alt
Attila Fazekas2aa35172012-12-05 20:03:40 +0100200 iniset $TEMPEST_CONF compute source_dir $NOVA_SOURCE_DIR
201 iniset $TEMPEST_CONF compute live_migration_available ${LIVE_MIGRATION_AVAILABLE:-False}
202 iniset $TEMPEST_CONF compute use_block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
203 # Inherited behavior, might be wrong
204 iniset $TEMPEST_CONF compute bin_dir $NOVA_BIN_DIR
205 # TODO(jaypipes): Create the key file here... right now, no whitebox
206 # tests actually use a key.
207 iniset $TEMPEST_CONF compute path_to_private_key $TEMPEST_DIR/id_rsa
208 iniset $TEMPEST_CONF compute db_uri $BASE_SQL_CONN/nova
209
210 # image
211 iniset $TEMPEST_CONF image host ${IMAGE_HOST:-127.0.0.1}
212 iniset $TEMPEST_CONF image port ${IMAGE_PORT:-9292}
Attila Fazekas65c08462012-12-07 14:20:51 +0100213 iniset $TEMPEST_CONF image password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100214
215 # identity-admin
Attila Fazekas65c08462012-12-07 14:20:51 +0100216 iniset $TEMPEST_CONF "identity-admin" password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100217
218 # compute admin
Attila Fazekas65c08462012-12-07 14:20:51 +0100219 iniset $TEMPEST_CONF "compute-admin" password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100220
Maru Newbya5c774e2012-12-10 10:40:01 +0000221 # network admin
222 iniset $TEMPEST_CONF "network-admin" password "$password"
223
Attila Fazekas2aa35172012-12-05 20:03:40 +0100224 # network
225 iniset $TEMPEST_CONF network api_version 2.0
Maru Newbya5c774e2012-12-10 10:40:01 +0000226 iniset $TEMPEST_CONF network password "$password"
227 iniset $TEMPEST_CONF network tenant_networks_reachable "$tenant_networks_reachable"
228 iniset $TEMPEST_CONF network public_network_id "$public_network_id"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100229
230 #boto
231 iniset $TEMPEST_CONF boto ec2_url "http://$SERVICE_HOST:8773/services/Cloud"
232 iniset $TEMPEST_CONF boto s3_url "http://$SERVICE_HOST:${S3_SERVICE_PORT:-3333}"
233
234 echo "Created tempest configuration file:"
235 cat $TEMPEST_CONF
236
237 # Restore IFS
238 IFS=$ifs
239 #Restore errexit
240 $errexit
Sean Dagued0931212012-10-04 16:06:44 -0400241}
242
243
244# install_tempest() - Collect source and prepare
245function install_tempest() {
246 git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH
Jeremy Stanley9a352da2012-11-28 17:22:39 +0000247
248 # Tempest doesn't satisfy its dependencies on its own, so
249 # install them here instead.
jiajun xud75bc1f2012-12-04 08:51:35 +0800250 pip_install -r $TEMPEST_DIR/tools/pip-requires
Sean Dagued0931212012-10-04 16:06:44 -0400251}
252
Sean Dagued0931212012-10-04 16:06:44 -0400253# Restore xtrace
254$XTRACE