blob: 8018166777e14face7c13ff8f54082df7e0d917e [file] [log] [blame]
Sean Dagued0931212012-10-04 16:06:44 -04001# lib/tempest
Dean Troyer6d04fd72012-12-21 11:03:37 -06002# Install and configure Tempest
Sean Dagued0931212012-10-04 16:06:44 -04003
4# Dependencies:
5# ``functions`` file
Attila Fazekas2aa35172012-12-05 20:03:40 +01006# ``lib/nova`` service is runing
Sean Dagued0931212012-10-04 16:06:44 -04007# <list other global vars that are assumed to be defined>
Attila Fazekas3c529222013-01-21 06:50:33 +01008# - ``DEST``, ``FILES``
Attila Fazekas65c08462012-12-07 14:20:51 +01009# - ``ADMIN_PASSWORD``
10# - ``DEFAULT_IMAGE_NAME``
11# - ``S3_SERVICE_PORT``
12# - ``SERVICE_HOST``
13# - ``BASE_SQL_CONN`` ``lib/database`` declares
Maru Newby31c94ab2012-12-19 03:59:20 +000014# - ``PUBLIC_NETWORK_NAME``
15# - ``Q_USE_NAMESPACE``
16# - ``Q_ROUTER_NAME``
Attila Fazekas1d29d8b2013-01-07 15:51:32 +010017# - ``VIRT_DRIVER``
18# - ``LIBVIRT_TYPE``
Attila Fazekas97d3d202013-01-19 19:20:49 +010019# - ``KEYSTONE_SERVICE_PROTOCOL``, ``KEYSTONE_SERVICE_HOST`` from lib/keystone
Attila Fazekas2aa35172012-12-05 20:03:40 +010020# Optional Dependencies:
Attila Fazekas2aa35172012-12-05 20:03:40 +010021# ALT_* (similar vars exists in keystone_data.sh)
Attila Fazekas65c08462012-12-07 14:20:51 +010022# ``LIVE_MIGRATION_AVAILABLE``
23# ``USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION``
24# ``DEFAULT_INSTANCE_TYPE``
25# ``DEFAULT_INSTANCE_USER``
Giulio Fidente97e1bd02013-06-04 05:33:52 +020026# ``CINDER_MULTI_LVM_BACKEND``
Sean Dagued0931212012-10-04 16:06:44 -040027# ``stack.sh`` calls the entry points in this order:
28#
Attila Fazekas2aa35172012-12-05 20:03:40 +010029# install_tempest
30# configure_tempest
Attila Fazekas1d29d8b2013-01-07 15:51:32 +010031# init_tempest
Sean Dagued0931212012-10-04 16:06:44 -040032
33# Save trace setting
34XTRACE=$(set +o | grep xtrace)
35set +o xtrace
36
Dean Troyer6d04fd72012-12-21 11:03:37 -060037
Sean Dagued0931212012-10-04 16:06:44 -040038# Defaults
39# --------
40
Sean Dagued0931212012-10-04 16:06:44 -040041# Set up default directories
42TEMPEST_DIR=$DEST/tempest
Attila Fazekas2aa35172012-12-05 20:03:40 +010043TEMPEST_CONF_DIR=$TEMPEST_DIR/etc
44TEMPEST_CONF=$TEMPEST_CONF_DIR/tempest.conf
45
Dean Troyer6d04fd72012-12-21 11:03:37 -060046NOVA_SOURCE_DIR=$DEST/nova
47
Attila Fazekasbae02332013-05-09 09:24:49 +020048BUILD_INTERVAL=1
Attila Fazekas2aa35172012-12-05 20:03:40 +010049BUILD_TIMEOUT=400
Sean Dagued0931212012-10-04 16:06:44 -040050
Dean Troyer6d04fd72012-12-21 11:03:37 -060051
Scott Mosercde655a2013-02-20 12:33:39 -050052BOTO_MATERIALS_PATH="$FILES/images/s3-materials/cirros-0.3.1"
Attila Fazekas1d29d8b2013-01-07 15:51:32 +010053
Dean Troyercc6b4432013-04-08 15:38:03 -050054
55# Functions
56# ---------
Sean Dagued0931212012-10-04 16:06:44 -040057
Sean Dagued0931212012-10-04 16:06:44 -040058# configure_tempest() - Set config files, create data dirs, etc
59function configure_tempest() {
Matthew Treinish95fb0d42013-01-28 16:24:14 -050060 setup_develop $TEMPEST_DIR
Attila Fazekas65c08462012-12-07 14:20:51 +010061 local image_lines
62 local images
63 local num_images
64 local image_uuid
65 local image_uuid_alt
Attila Fazekas2aa35172012-12-05 20:03:40 +010066 local errexit
Attila Fazekas65c08462012-12-07 14:20:51 +010067 local password
68 local line
69 local flavors
70 local flavors_ref
71 local flavor_lines
Maru Newbya5c774e2012-12-10 10:40:01 +000072 local public_network_id
Maru Newby31c94ab2012-12-19 03:59:20 +000073 local public_router_id
Maru Newbya5c774e2012-12-10 10:40:01 +000074 local tenant_networks_reachable
Attila Fazekas1d29d8b2013-01-07 15:51:32 +010075 local boto_instance_type="m1.tiny"
Attila Fazekas2aa35172012-12-05 20:03:40 +010076
Dean Troyer6d04fd72012-12-21 11:03:37 -060077 # TODO(afazekas):
Sean Dagued0931212012-10-04 16:06:44 -040078 # sudo python setup.py deploy
Attila Fazekas2aa35172012-12-05 20:03:40 +010079
80 # This function exits on an error so that errors don't compound and you see
81 # only the first error that occured.
82 errexit=$(set +o | grep errexit)
83 set -o errexit
84
Dean Troyer6d04fd72012-12-21 11:03:37 -060085 # Save IFS
Attila Fazekas2aa35172012-12-05 20:03:40 +010086 ifs=$IFS
87
88 # Glance should already contain images to be used in tempest
89 # testing. Here we simply look for images stored in Glance
90 # and set the appropriate variables for use in the tempest config
91 # We ignore ramdisk and kernel images, look for the default image
Attila Fazekas65c08462012-12-07 14:20:51 +010092 # ``DEFAULT_IMAGE_NAME``. If not found, we set the ``image_uuid`` to the
93 # first image returned and set ``image_uuid_alt`` to the second,
Attila Fazekas2aa35172012-12-05 20:03:40 +010094 # if there is more than one returned...
95 # ... Also ensure we only take active images, so we don't get snapshots in process
Cody A.W. Somervillec24e23b2012-12-21 02:10:45 -050096 declare -a images
97
98 while read -r IMAGE_NAME IMAGE_UUID; do
99 if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then
100 image_uuid="$IMAGE_UUID"
101 image_uuid_alt="$IMAGE_UUID"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100102 fi
Cody A.W. Somervillec24e23b2012-12-21 02:10:45 -0500103 images+=($IMAGE_UUID)
104 done < <(glance image-list --status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }')
105
106 case "${#images[*]}" in
107 0)
108 echo "Found no valid images to use!"
109 exit 1
110 ;;
111 1)
112 if [ -z "$image_uuid" ]; then
113 image_uuid=${images[0]}
114 image_uuid_alt=${images[0]}
115 fi
116 ;;
117 *)
118 if [ -z "$image_uuid" ]; then
119 image_uuid=${images[0]}
120 image_uuid_alt=${images[1]}
121 fi
122 ;;
123 esac
Attila Fazekas2aa35172012-12-05 20:03:40 +0100124
125 # Create tempest.conf from tempest.conf.sample
126 # copy every time, because the image UUIDS are going to change
127 cp $TEMPEST_CONF.sample $TEMPEST_CONF
128
Attila Fazekas65c08462012-12-07 14:20:51 +0100129 password=${ADMIN_PASSWORD:-secrete}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100130
131 # See files/keystone_data.sh where alt_demo user
132 # and tenant are set up...
133 ALT_USERNAME=${ALT_USERNAME:-alt_demo}
134 ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo}
135
Attila Fazekas7bf1dd32013-01-12 17:31:26 +0100136 # If the ``DEFAULT_INSTANCE_TYPE`` not declared, use the new behavior
137 # Tempest creates instane types for himself
138 if [[ -z "$DEFAULT_INSTANCE_TYPE" ]]; then
Attila Fazekas02c0bcc2013-01-14 19:10:17 +0100139 nova flavor-create m1.nano 42 64 0 1
Attila Fazekas7bf1dd32013-01-12 17:31:26 +0100140 flavor_ref=42
Attila Fazekas1d29d8b2013-01-07 15:51:32 +0100141 boto_instance_type=m1.nano
Attila Fazekas02c0bcc2013-01-14 19:10:17 +0100142 nova flavor-create m1.micro 84 128 0 1
Attila Fazekas7bf1dd32013-01-12 17:31:26 +0100143 flavor_ref_alt=84
144 else
145 # Check Nova for existing flavors and, if set, look for the
146 # ``DEFAULT_INSTANCE_TYPE`` and use that.
Attila Fazekas1d29d8b2013-01-07 15:51:32 +0100147 boto_instance_type=$DEFAULT_INSTANCE_TYPE
Attila Fazekas7bf1dd32013-01-12 17:31:26 +0100148 flavor_lines=`nova flavor-list`
149 IFS=$'\r\n'
150 flavors=""
Dean Troyerceaa38b2012-12-12 17:09:57 -0600151 for line in $flavor_lines; do
152 f=$(echo $line | awk "/ $DEFAULT_INSTANCE_TYPE / { print \$2 }")
153 flavors="$flavors $f"
154 done
Attila Fazekas2aa35172012-12-05 20:03:40 +0100155
Attila Fazekas7bf1dd32013-01-12 17:31:26 +0100156 for line in $flavor_lines; do
157 flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`"
158 done
159
160 IFS=" "
161 flavors=($flavors)
162 num_flavors=${#flavors[*]}
163 echo "Found $num_flavors flavors"
164 if [[ $num_flavors -eq 0 ]]; then
165 echo "Found no valid flavors to use!"
166 exit 1
167 fi
168 flavor_ref=${flavors[0]}
169 flavor_ref_alt=$flavor_ref
170 if [[ $num_flavors -gt 1 ]]; then
171 flavor_ref_alt=${flavors[1]}
172 fi
Attila Fazekas2aa35172012-12-05 20:03:40 +0100173 fi
174
Maru Newbya5c774e2012-12-10 10:40:01 +0000175 if [ "$Q_USE_NAMESPACE" != "False" ]; then
176 tenant_networks_reachable=false
177 else
178 tenant_networks_reachable=true
179 fi
180
181 if is_service_enabled q-l3; then
182 public_network_id=$(quantum net-list | grep $PUBLIC_NETWORK_NAME | \
183 awk '{print $2}')
Maru Newby31c94ab2012-12-19 03:59:20 +0000184 if [ "$Q_USE_NAMESPACE" == "False" ]; then
185 # If namespaces are disabled, devstack will create a single
186 # public router that tempest should be configured to use.
187 public_router_id=$(quantum router-list | awk "/ $Q_ROUTER_NAME / \
188 { print \$2 }")
189 fi
Maru Newbya5c774e2012-12-10 10:40:01 +0000190 fi
191
Attila Fazekas2aa35172012-12-05 20:03:40 +0100192 # Timeouts
193 iniset $TEMPEST_CONF compute build_timeout $BUILD_TIMEOUT
194 iniset $TEMPEST_CONF volume build_timeout $BUILD_TIMEOUT
195 iniset $TEMPEST_CONF boto build_timeout $BUILD_TIMEOUT
196 iniset $TEMPEST_CONF compute build_interval $BUILD_INTERVAL
197 iniset $TEMPEST_CONF volume build_interval $BUILD_INTERVAL
198 iniset $TEMPEST_CONF boto build_interval $BUILD_INTERVAL
199 iniset $TEMPEST_CONF boto http_socket_timeout 5
200
Attila Fazekas97d3d202013-01-19 19:20:49 +0100201 # Identity
202 iniset $TEMPEST_CONF identity uri "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:5000/v2.0/"
203 iniset $TEMPEST_CONF identity password "$password"
204 iniset $TEMPEST_CONF identity alt_username $ALT_USERNAME
205 iniset $TEMPEST_CONF identity alt_password "$password"
206 iniset $TEMPEST_CONF identity alt_tenant_name $ALT_TENANT_NAME
207 iniset $TEMPEST_CONF identity admin_password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100208
Attila Fazekas97d3d202013-01-19 19:20:49 +0100209 # Compute
Attila Fazekas2aa35172012-12-05 20:03:40 +0100210 iniset $TEMPEST_CONF compute change_password_available False
Nachi Ueno06fac372012-12-26 14:09:43 -0800211 # Note(nati) current tempest don't create network for each tenant
212 # so reuse same tenant for now
213 if is_service_enabled quantum; then
214 TEMPEST_ALLOW_TENANT_ISOLATION=${TEMPEST_ALLOW_TENANT_ISOLATION:-False}
215 fi
216 iniset $TEMPEST_CONF compute allow_tenant_isolation ${TEMPEST_ALLOW_TENANT_ISOLATION:-True}
Attila Fazekas97d3d202013-01-19 19:20:49 +0100217 iniset $TEMPEST_CONF compute ssh_user ${DEFAULT_INSTANCE_USER:-cirros} # DEPRECATED
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900218 iniset $TEMPEST_CONF compute network_for_ssh $PRIVATE_NETWORK_NAME
Attila Fazekas2aa35172012-12-05 20:03:40 +0100219 iniset $TEMPEST_CONF compute ip_version_for_ssh 4
Attila Fazekas1d29d8b2013-01-07 15:51:32 +0100220 iniset $TEMPEST_CONF compute ssh_timeout $BUILD_TIMEOUT
Attila Fazekas65c08462012-12-07 14:20:51 +0100221 iniset $TEMPEST_CONF compute image_ref $image_uuid
Attila Fazekas97d3d202013-01-19 19:20:49 +0100222 iniset $TEMPEST_CONF compute image_ssh_user ${DEFAULT_INSTANCE_USER:-cirros}
Attila Fazekas65c08462012-12-07 14:20:51 +0100223 iniset $TEMPEST_CONF compute image_ref_alt $image_uuid_alt
Attila Fazekas97d3d202013-01-19 19:20:49 +0100224 iniset $TEMPEST_CONF compute image_alt_ssh_user ${DEFAULT_INSTANCE_USER:-cirros}
Attila Fazekas65c08462012-12-07 14:20:51 +0100225 iniset $TEMPEST_CONF compute flavor_ref $flavor_ref
226 iniset $TEMPEST_CONF compute flavor_ref_alt $flavor_ref_alt
Attila Fazekas2aa35172012-12-05 20:03:40 +0100227 iniset $TEMPEST_CONF compute live_migration_available ${LIVE_MIGRATION_AVAILABLE:-False}
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900228 iniset $TEMPEST_CONF compute use_block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
Attila Fazekas97d3d202013-01-19 19:20:49 +0100229
230 # Whitebox
231 iniset $TEMPEST_CONF whitebox source_dir $NOVA_SOURCE_DIR
232 iniset $TEMPEST_CONF whitebox bin_dir $NOVA_BIN_DIR
Attila Fazekas2aa35172012-12-05 20:03:40 +0100233 # TODO(jaypipes): Create the key file here... right now, no whitebox
234 # tests actually use a key.
Attila Fazekas97d3d202013-01-19 19:20:49 +0100235 iniset $TEMPEST_CONF whitebox path_to_private_key $TEMPEST_DIR/id_rsa
236 iniset $TEMPEST_CONF whitebox db_uri $BASE_SQL_CONN/nova
237
Giulio Fidente97e1bd02013-06-04 05:33:52 +0200238 # Compute admin
Attila Fazekas97d3d202013-01-19 19:20:49 +0100239 iniset $TEMPEST_CONF "compute-admin" password "$password" # DEPRECATED
Attila Fazekas2aa35172012-12-05 20:03:40 +0100240
Giulio Fidente97e1bd02013-06-04 05:33:52 +0200241 # Network
Sean Dague4a20f9a2013-03-01 07:23:38 -0500242 if is_service_enabled quantum; then
243 iniset $TEMPEST_CONF network quantum_available "True"
244 fi
Attila Fazekas2aa35172012-12-05 20:03:40 +0100245 iniset $TEMPEST_CONF network api_version 2.0
Maru Newbya5c774e2012-12-10 10:40:01 +0000246 iniset $TEMPEST_CONF network tenant_networks_reachable "$tenant_networks_reachable"
247 iniset $TEMPEST_CONF network public_network_id "$public_network_id"
Maru Newby31c94ab2012-12-19 03:59:20 +0000248 iniset $TEMPEST_CONF network public_router_id "$public_router_id"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100249
Giulio Fidente97e1bd02013-06-04 05:33:52 +0200250 # boto
Attila Fazekas2aa35172012-12-05 20:03:40 +0100251 iniset $TEMPEST_CONF boto ec2_url "http://$SERVICE_HOST:8773/services/Cloud"
252 iniset $TEMPEST_CONF boto s3_url "http://$SERVICE_HOST:${S3_SERVICE_PORT:-3333}"
Attila Fazekas1d29d8b2013-01-07 15:51:32 +0100253 iniset $TEMPEST_CONF boto s3_materials_path "$BOTO_MATERIALS_PATH"
254 iniset $TEMPEST_CONF boto instance_type "$boto_instance_type"
255 iniset $TEMPEST_CONF boto http_socket_timeout 30
Attila Fazekas97d3d202013-01-19 19:20:49 +0100256 iniset $TEMPEST_CONF boto ssh_user ${DEFAULT_INSTANCE_USER:-cirros}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100257
Giulio Fidente97e1bd02013-06-04 05:33:52 +0200258 # Orchestration
Steve Baker26824b02013-06-04 13:15:04 +1200259 if is_service_enabled heat; then
260 iniset $TEMPEST_CONF orchestration heat_available "True"
261 fi
262
Giulio Fidente97e1bd02013-06-04 05:33:52 +0200263 # Volume
264 CINDER_MULTI_LVM_BACKEND=$(trueorfalse False $CINDER_MULTI_LVM_BACKEND)
265 if [ $CINDER_MULTI_LVM_BACKEND == "True "]; then
266 iniset $TEMPEST_CONF volume multi_backend_enabled "True"
267 iniset $TEMPEST_CONF volume backend1_name "LVM_iSCSI"
268 iniset $TEMPEST_CONF volume backend2_name "LVM_iSCSI_2"
269 fi
270
Attila Fazekas2aa35172012-12-05 20:03:40 +0100271 echo "Created tempest configuration file:"
272 cat $TEMPEST_CONF
273
274 # Restore IFS
275 IFS=$ifs
276 #Restore errexit
277 $errexit
Sean Dagued0931212012-10-04 16:06:44 -0400278}
279
Sean Dagued0931212012-10-04 16:06:44 -0400280# install_tempest() - Collect source and prepare
281function install_tempest() {
282 git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH
Sean Dagued0931212012-10-04 16:06:44 -0400283}
284
Attila Fazekas1d29d8b2013-01-07 15:51:32 +0100285# init_tempest() - Initialize ec2 images
286function init_tempest() {
Scott Mosercde655a2013-02-20 12:33:39 -0500287 local base_image_name=cirros-0.3.1-x86_64
288 # /opt/stack/devstack/files/images/cirros-0.3.1-x86_64-uec
Attila Fazekas3c529222013-01-21 06:50:33 +0100289 local image_dir="$FILES/images/${base_image_name}-uec"
Attila Fazekas1d29d8b2013-01-07 15:51:32 +0100290 local kernel="$image_dir/${base_image_name}-vmlinuz"
291 local ramdisk="$image_dir/${base_image_name}-initrd"
292 local disk_image="$image_dir/${base_image_name}-blank.img"
293 # if the cirros uec downloaded and the system is uec capable
294 if [ -f "$kernel" -a -f "$ramdisk" -a -f "$disk_image" -a "$VIRT_DRIVER" != "openvz" \
295 -a \( "$LIBVIRT_TYPE" != "lxc" -o "$VIRT_DRIVER" != "libvirt" \) ]; then
296 echo "Prepare aki/ari/ami Images"
297 ( #new namespace
298 # tenant:demo ; user: demo
Chris Yeohb0b98b72013-01-23 21:14:49 +1030299 source $TOP_DIR/accrc/demo/demo
Attila Fazekas1d29d8b2013-01-07 15:51:32 +0100300 euca-bundle-image -i "$kernel" --kernel true -d "$BOTO_MATERIALS_PATH"
301 euca-bundle-image -i "$ramdisk" --ramdisk true -d "$BOTO_MATERIALS_PATH"
302 euca-bundle-image -i "$disk_image" -d "$BOTO_MATERIALS_PATH"
303 ) 2>&1 </dev/null | cat
304 else
305 echo "Boto materials are not prepared"
306 fi
307}
308
Sean Dagued0931212012-10-04 16:06:44 -0400309# Restore xtrace
310$XTRACE
Sean Dague584d90e2013-03-29 14:34:53 -0400311
312# Local variables:
313# mode: shell-script
314# End: