blob: 7d7cf114696a19f23897dd38c170e8c583e247c2 [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Sean Dagued0931212012-10-04 16:06:44 -04003# lib/tempest
Dean Troyer6d04fd72012-12-21 11:03:37 -06004# Install and configure Tempest
Sean Dagued0931212012-10-04 16:06:44 -04005
6# Dependencies:
Adam Spiers6a5aa7c2013-10-24 11:27:02 +01007#
8# - ``functions`` file
9# - ``lib/nova`` service is running
10# - Global vars that are assumed to be defined:
11# - ``DEST``, ``FILES``
12# - ``ADMIN_PASSWORD``
13# - ``DEFAULT_IMAGE_NAME``
14# - ``S3_SERVICE_PORT``
15# - ``SERVICE_HOST``
16# - ``BASE_SQL_CONN`` ``lib/database`` declares
17# - ``PUBLIC_NETWORK_NAME``
18# - ``Q_USE_NAMESPACE``
19# - ``Q_ROUTER_NAME``
Tomoe Sugiharaafbc6312013-11-14 20:02:47 +000020# - ``Q_L3_ENABLED``
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010021# - ``VIRT_DRIVER``
22# - ``LIBVIRT_TYPE``
23# - ``KEYSTONE_SERVICE_PROTOCOL``, ``KEYSTONE_SERVICE_HOST`` from lib/keystone
24#
Attila Fazekas2aa35172012-12-05 20:03:40 +010025# Optional Dependencies:
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010026#
27# - ``ALT_*`` (similar vars exists in keystone_data.sh)
28# - ``LIVE_MIGRATION_AVAILABLE``
29# - ``USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION``
30# - ``DEFAULT_INSTANCE_TYPE``
31# - ``DEFAULT_INSTANCE_USER``
Swapnil Kulkarni09fb7ba2014-10-16 06:30:28 +000032# - ``CINDER_ENABLED_BACKENDS``
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010033#
Sean Dagued0931212012-10-04 16:06:44 -040034# ``stack.sh`` calls the entry points in this order:
35#
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010036# - install_tempest
37# - configure_tempest
38# - init_tempest
Sean Dagued0931212012-10-04 16:06:44 -040039
40# Save trace setting
41XTRACE=$(set +o | grep xtrace)
42set +o xtrace
43
Dean Troyer6d04fd72012-12-21 11:03:37 -060044
Sean Dagued0931212012-10-04 16:06:44 -040045# Defaults
46# --------
47
Sean Dagued0931212012-10-04 16:06:44 -040048# Set up default directories
Sean Dague91b22902014-11-18 07:13:35 -050049GITDIR["tempest-lib"]=$DEST/tempest-lib
Sean Dague5cb19062014-11-01 01:37:45 +010050
Sean Dagued0931212012-10-04 16:06:44 -040051TEMPEST_DIR=$DEST/tempest
john-griffithdc4dc7f2014-01-22 18:09:32 -070052TEMPEST_CONFIG_DIR=${TEMPEST_CONFIG_DIR:-$TEMPEST_DIR/etc}
53TEMPEST_CONFIG=$TEMPEST_CONFIG_DIR/tempest.conf
Matthew Treinish14ccba02013-07-29 16:15:53 -040054TEMPEST_STATE_PATH=${TEMPEST_STATE_PATH:=$DATA_DIR/tempest}
Attila Fazekas2aa35172012-12-05 20:03:40 +010055
Dean Troyer6d04fd72012-12-21 11:03:37 -060056NOVA_SOURCE_DIR=$DEST/nova
57
Attila Fazekasbae02332013-05-09 09:24:49 +020058BUILD_INTERVAL=1
Arx Cruz1bde9b42014-07-18 11:34:33 -030059
60# This is the timeout that tempest will wait for a VM to change state,
61# spawn, delete, etc.
62# The default is set to 196 seconds.
63BUILD_TIMEOUT=${BUILD_TIMEOUT:-196}
Sean Dagued0931212012-10-04 16:06:44 -040064
Joe Gordonc9b245b2015-02-10 14:32:39 -080065# This must be False on stable branches, as master tempest
66# deps do not match stable branch deps. Set this to True to
Dean Troyerdc97cb72015-03-28 08:20:50 -050067# have tempest installed in DevStack by default.
Matthew Treinishcb3cece2015-03-16 10:37:51 -040068INSTALL_TEMPEST=${INSTALL_TEMPEST:-"True"}
Joe Gordonc9b245b2015-02-10 14:32:39 -080069
Attila Fazekas2d4c8da2014-03-19 10:42:01 +010070BOTO_MATERIALS_PATH="$FILES/images/s3-materials/cirros-${CIRROS_VERSION}"
Attila Fazekas58e694e2015-02-04 12:45:50 +010071BOTO_CONF=/etc/boto.cfg
Attila Fazekas1d29d8b2013-01-07 15:51:32 +010072
john-griffithdc4dc7f2014-01-22 18:09:32 -070073# Cinder/Volume variables
74TEMPEST_VOLUME_DRIVER=${TEMPEST_VOLUME_DRIVER:-default}
Eric Harney01456482014-10-14 18:53:53 -040075TEMPEST_DEFAULT_VOLUME_VENDOR="Open Source"
76TEMPEST_VOLUME_VENDOR=${TEMPEST_VOLUME_VENDOR:-$TEMPEST_DEFAULT_VOLUME_VENDOR}
77TEMPEST_DEFAULT_STORAGE_PROTOCOL="iSCSI"
78TEMPEST_STORAGE_PROTOCOL=${TEMPEST_STORAGE_PROTOCOL:-$TEMPEST_DEFAULT_STORAGE_PROTOCOL}
Dean Troyercc6b4432013-04-08 15:38:03 -050079
armando-migliaccio71ef61a2014-02-19 22:19:24 -080080# Neutron/Network variables
Sean Dague53753292014-12-04 19:38:15 -050081IPV6_ENABLED=$(trueorfalse True IPV6_ENABLED)
82IPV6_SUBNET_ATTRIBUTES_ENABLED=$(trueorfalse True IPV6_SUBNET_ATTRIBUTES_ENABLED)
armando-migliaccio71ef61a2014-02-19 22:19:24 -080083
Dean Troyerdc97cb72015-03-28 08:20:50 -050084
Dean Troyercc6b4432013-04-08 15:38:03 -050085# Functions
86# ---------
Sean Dagued0931212012-10-04 16:06:44 -040087
Salvatore33e8ee22014-10-05 01:36:34 +020088# remove_disabled_extension - removes disabled extensions from the list of extensions
89# to test for a given service
90function remove_disabled_extensions {
91 local extensions_list=$1
92 shift
93 local disabled_exts=$*
94 for ext_to_remove in ${disabled_exts//,/ } ; do
95 extensions_list=${extensions_list/$ext_to_remove","}
96 done
97 echo $extensions_list
98}
99
Sean Dagued0931212012-10-04 16:06:44 -0400100# configure_tempest() - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +1100101function configure_tempest {
Joe Gordonc9b245b2015-02-10 14:32:39 -0800102 if [[ "$INSTALL_TEMPEST" == "True" ]]; then
103 setup_develop $TEMPEST_DIR
104 else
105 # install testr since its used to process tempest logs
106 pip_install $(get_from_global_requirements testrepository)
107 fi
Joe Gordond5ac7852015-02-06 19:29:23 -0800108
Attila Fazekas65c08462012-12-07 14:20:51 +0100109 local image_lines
110 local images
111 local num_images
112 local image_uuid
113 local image_uuid_alt
Attila Fazekas65c08462012-12-07 14:20:51 +0100114 local password
115 local line
116 local flavors
Clark Boylan3b80bde2013-11-20 17:51:50 -0800117 local available_flavors
Attila Fazekas65c08462012-12-07 14:20:51 +0100118 local flavors_ref
119 local flavor_lines
Maru Newbya5c774e2012-12-10 10:40:01 +0000120 local public_network_id
Maru Newby31c94ab2012-12-19 03:59:20 +0000121 local public_router_id
Maru Newbya5c774e2012-12-10 10:40:01 +0000122 local tenant_networks_reachable
Attila Fazekas1d29d8b2013-01-07 15:51:32 +0100123 local boto_instance_type="m1.tiny"
Attila Fazekas386ae8c2013-10-21 09:27:18 +0200124 local ssh_connect_method="fixed"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100125
Dean Troyer6d04fd72012-12-21 11:03:37 -0600126 # Save IFS
Attila Fazekas2aa35172012-12-05 20:03:40 +0100127 ifs=$IFS
128
129 # Glance should already contain images to be used in tempest
130 # testing. Here we simply look for images stored in Glance
131 # and set the appropriate variables for use in the tempest config
132 # We ignore ramdisk and kernel images, look for the default image
Attila Fazekas65c08462012-12-07 14:20:51 +0100133 # ``DEFAULT_IMAGE_NAME``. If not found, we set the ``image_uuid`` to the
134 # first image returned and set ``image_uuid_alt`` to the second,
Attila Fazekas2aa35172012-12-05 20:03:40 +0100135 # if there is more than one returned...
136 # ... Also ensure we only take active images, so we don't get snapshots in process
Cody A.W. Somervillec24e23b2012-12-21 02:10:45 -0500137 declare -a images
138
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200139 if is_service_enabled glance; then
140 while read -r IMAGE_NAME IMAGE_UUID; do
141 if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then
142 image_uuid="$IMAGE_UUID"
143 image_uuid_alt="$IMAGE_UUID"
144 fi
145 images+=($IMAGE_UUID)
146 # TODO(stevemar): update this command to use openstackclient's `openstack image list`
147 # when it supports listing by status.
148 done < <(glance image-list --status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }')
Cody A.W. Somervillec24e23b2012-12-21 02:10:45 -0500149
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200150 case "${#images[*]}" in
151 0)
152 echo "Found no valid images to use!"
153 exit 1
154 ;;
155 1)
156 if [ -z "$image_uuid" ]; then
157 image_uuid=${images[0]}
158 image_uuid_alt=${images[0]}
159 fi
160 ;;
161 *)
162 if [ -z "$image_uuid" ]; then
163 image_uuid=${images[0]}
164 image_uuid_alt=${images[1]}
165 fi
166 ;;
167 esac
168 fi
Attila Fazekas2aa35172012-12-05 20:03:40 +0100169
Dean Troyerdc97cb72015-03-28 08:20:50 -0500170 # Create ``tempest.conf`` from ``tempest.conf.sample``
171 # Copy every time because the image UUIDS are going to change
Dean Troyer8421c2b2015-03-16 13:52:19 -0500172 sudo install -d -o $STACK_USER $TEMPEST_CONFIG_DIR
173 install -m 644 $TEMPEST_DIR/etc/tempest.conf.sample $TEMPEST_CONFIG
Attila Fazekas2aa35172012-12-05 20:03:40 +0100174
Attila Fazekas65c08462012-12-07 14:20:51 +0100175 password=${ADMIN_PASSWORD:-secrete}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100176
Matthew Treinish7ced1502015-03-23 15:51:54 -0400177 # Do we want to make a configuration where Tempest has admin on
178 # the cloud. We don't always want to so that we can ensure Tempest
179 # would work on a public cloud.
180 TEMPEST_HAS_ADMIN=$(trueorfalse True TEMPEST_HAS_ADMIN)
Dean Troyerdc97cb72015-03-28 08:20:50 -0500181
182 # See ``lib/keystone`` where these users and tenants are set up
Andrea Frittolid46d9dd2014-03-05 13:38:19 +0000183 ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
184 ADMIN_TENANT_NAME=${ADMIN_TENANT_NAME:-admin}
Andrea Frittoli03523252014-04-08 13:43:56 +0100185 ADMIN_DOMAIN_NAME=${ADMIN_DOMAIN_NAME:-Default}
Andrea Frittolid46d9dd2014-03-05 13:38:19 +0000186 TEMPEST_USERNAME=${TEMPEST_USERNAME:-demo}
187 TEMPEST_TENANT_NAME=${TEMPEST_TENANT_NAME:-demo}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100188 ALT_USERNAME=${ALT_USERNAME:-alt_demo}
189 ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo}
Harshada Mangesh Kakad49126232014-05-23 09:16:52 +0000190 ADMIN_TENANT_ID=$(openstack project list | awk "/ admin / { print \$2 }")
Attila Fazekas2aa35172012-12-05 20:03:40 +0100191
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200192 if is_service_enabled nova; then
Dean Troyerdc97cb72015-03-28 08:20:50 -0500193 # If ``DEFAULT_INSTANCE_TYPE`` is not declared, use the new behavior
194 # Tempest creates its own instance types
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200195 if [[ -z "$DEFAULT_INSTANCE_TYPE" ]]; then
196 available_flavors=$(nova flavor-list)
197 if [[ ! ( $available_flavors =~ 'm1.nano' ) ]]; then
198 if is_arch "ppc64"; then
Dean Troyerdc97cb72015-03-28 08:20:50 -0500199 # Qemu needs at least 128MB of memory to boot on ppc64
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200200 nova flavor-create m1.nano 42 128 0 1
201 else
202 nova flavor-create m1.nano 42 64 0 1
203 fi
Rafael Folcoba0f1d32013-12-06 17:56:24 -0200204 fi
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200205 flavor_ref=42
206 boto_instance_type=m1.nano
207 if [[ ! ( $available_flavors =~ 'm1.micro' ) ]]; then
208 if is_arch "ppc64"; then
209 nova flavor-create m1.micro 84 256 0 1
210 else
211 nova flavor-create m1.micro 84 128 0 1
212 fi
Rafael Folcoba0f1d32013-12-06 17:56:24 -0200213 fi
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200214 flavor_ref_alt=84
215 else
Dean Troyerdc97cb72015-03-28 08:20:50 -0500216 # Check Nova for existing flavors, if ``DEFAULT_INSTANCE_TYPE`` is set use it.
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200217 boto_instance_type=$DEFAULT_INSTANCE_TYPE
218 flavor_lines=`nova flavor-list`
219 IFS=$'\r\n'
220 flavors=""
221 for line in $flavor_lines; do
222 f=$(echo $line | awk "/ $DEFAULT_INSTANCE_TYPE / { print \$2 }")
223 flavors="$flavors $f"
224 done
Attila Fazekas2aa35172012-12-05 20:03:40 +0100225
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200226 for line in $flavor_lines; do
227 flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`"
228 done
Attila Fazekas7bf1dd32013-01-12 17:31:26 +0100229
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200230 IFS=" "
231 flavors=($flavors)
232 num_flavors=${#flavors[*]}
233 echo "Found $num_flavors flavors"
234 if [[ $num_flavors -eq 0 ]]; then
235 echo "Found no valid flavors to use!"
236 exit 1
Adalberto Medeiros63a71a22013-06-06 08:46:04 -0400237 fi
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200238 flavor_ref=${flavors[0]}
239 flavor_ref_alt=$flavor_ref
240
Dean Troyerdc97cb72015-03-28 08:20:50 -0500241 # Ensure ``flavor_ref`` and ``flavor_ref_alt`` have different values.
242 # Some resize instance in tempest tests depends on this.
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200243 for f in ${flavors[@]:1}; do
244 if [[ $f -ne $flavor_ref ]]; then
245 flavor_ref_alt=$f
246 break
247 fi
248 done
249 fi
Attila Fazekas2aa35172012-12-05 20:03:40 +0100250 fi
251
Maru Newbya5c774e2012-12-10 10:40:01 +0000252 if [ "$Q_USE_NAMESPACE" != "False" ]; then
253 tenant_networks_reachable=false
Attila Fazekasf9e77392013-12-03 06:17:16 +0100254 if ! is_service_enabled n-net; then
255 ssh_connect_method="floating"
256 fi
Maru Newbya5c774e2012-12-10 10:40:01 +0000257 else
258 tenant_networks_reachable=true
259 fi
260
Attila Fazekas386ae8c2013-10-21 09:27:18 +0200261 ssh_connect_method=${TEMPEST_SSH_CONNECT_METHOD:-$ssh_connect_method}
262
Tomoe Sugiharaafbc6312013-11-14 20:02:47 +0000263 if [ "$Q_L3_ENABLED" = "True" ]; then
Mark McClainb05c8762013-07-06 23:29:39 -0400264 public_network_id=$(neutron net-list | grep $PUBLIC_NETWORK_NAME | \
Maru Newbya5c774e2012-12-10 10:40:01 +0000265 awk '{print $2}')
Maru Newby31c94ab2012-12-19 03:59:20 +0000266 if [ "$Q_USE_NAMESPACE" == "False" ]; then
Dean Troyerdc97cb72015-03-28 08:20:50 -0500267 # If namespaces are disabled, DevStack will create a single
Maru Newby31c94ab2012-12-19 03:59:20 +0000268 # public router that tempest should be configured to use.
Mark McClainb05c8762013-07-06 23:29:39 -0400269 public_router_id=$(neutron router-list | awk "/ $Q_ROUTER_NAME / \
Sean Dague101b4242013-10-22 08:47:11 -0400270 { print \$2 }")
Maru Newby31c94ab2012-12-19 03:59:20 +0000271 fi
Maru Newbya5c774e2012-12-10 10:40:01 +0000272 fi
273
Masayuki Igawa5a252d92014-11-21 21:55:09 +0900274 iniset $TEMPEST_CONFIG DEFAULT use_syslog $SYSLOG
Dean Troyerdc97cb72015-03-28 08:20:50 -0500275
Matthew Treinish859cc682013-07-26 15:22:44 -0400276 # Oslo
Joe Gordon23d6d502015-03-06 15:24:22 -0800277 iniset $TEMPEST_CONFIG oslo_concurrency lock_path $TEMPEST_STATE_PATH
Matthew Treinish14ccba02013-07-29 16:15:53 -0400278 mkdir -p $TEMPEST_STATE_PATH
john-griffithdc4dc7f2014-01-22 18:09:32 -0700279 iniset $TEMPEST_CONFIG DEFAULT use_stderr False
280 iniset $TEMPEST_CONFIG DEFAULT log_file tempest.log
281 iniset $TEMPEST_CONFIG DEFAULT debug True
Matthew Treinish859cc682013-07-26 15:22:44 -0400282
Attila Fazekas2aa35172012-12-05 20:03:40 +0100283 # Timeouts
john-griffithdc4dc7f2014-01-22 18:09:32 -0700284 iniset $TEMPEST_CONFIG compute build_timeout $BUILD_TIMEOUT
285 iniset $TEMPEST_CONFIG volume build_timeout $BUILD_TIMEOUT
286 iniset $TEMPEST_CONFIG boto build_timeout $BUILD_TIMEOUT
john-griffithdc4dc7f2014-01-22 18:09:32 -0700287 iniset $TEMPEST_CONFIG boto http_socket_timeout 5
Attila Fazekas2aa35172012-12-05 20:03:40 +0100288
Attila Fazekas97d3d202013-01-19 19:20:49 +0100289 # Identity
john-griffithdc4dc7f2014-01-22 18:09:32 -0700290 iniset $TEMPEST_CONFIG identity uri "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:5000/v2.0/"
Steve Martinellib74e01c2014-12-18 01:35:35 -0500291 iniset $TEMPEST_CONFIG identity uri_v3 "$KEYSTONE_SERVICE_URI_V3"
Andrea Frittolid46d9dd2014-03-05 13:38:19 +0000292 iniset $TEMPEST_CONFIG identity username $TEMPEST_USERNAME
john-griffithdc4dc7f2014-01-22 18:09:32 -0700293 iniset $TEMPEST_CONFIG identity password "$password"
Andrea Frittolid46d9dd2014-03-05 13:38:19 +0000294 iniset $TEMPEST_CONFIG identity tenant_name $TEMPEST_TENANT_NAME
john-griffithdc4dc7f2014-01-22 18:09:32 -0700295 iniset $TEMPEST_CONFIG identity alt_username $ALT_USERNAME
296 iniset $TEMPEST_CONFIG identity alt_password "$password"
297 iniset $TEMPEST_CONFIG identity alt_tenant_name $ALT_TENANT_NAME
Matthew Treinish7ced1502015-03-23 15:51:54 -0400298 if [[ "$TEMPEST_HAS_ADMIN" == "True" ]]; then
299 iniset $TEMPEST_CONFIG identity admin_username $ADMIN_USERNAME
300 iniset $TEMPEST_CONFIG identity admin_password "$password"
301 iniset $TEMPEST_CONFIG identity admin_tenant_name $ADMIN_TENANT_NAME
302 iniset $TEMPEST_CONFIG identity admin_tenant_id $ADMIN_TENANT_ID
303 iniset $TEMPEST_CONFIG identity admin_domain_name $ADMIN_DOMAIN_NAME
304 fi
Andrea Frittoli07f1d0e2014-03-06 23:23:01 +0000305 iniset $TEMPEST_CONFIG identity auth_version ${TEMPEST_AUTH_VERSION:-v2}
Rob Crittendene1d013f2015-02-10 14:15:35 -0500306 if is_ssl_enabled_service "key" || is_service_enabled tls-proxy; then
307 iniset $TEMPEST_CONFIG identity ca_certificates_file $SSL_BUNDLE_FILE
308 fi
Attila Fazekas2aa35172012-12-05 20:03:40 +0100309
Sean Daguec3771452013-06-13 14:23:37 -0400310 # Image
Dean Troyerdc97cb72015-03-28 08:20:50 -0500311 # We want to be able to override this variable in the gate to avoid
312 # doing an external HTTP fetch for this test.
Sean Daguec3771452013-06-13 14:23:37 -0400313 if [[ ! -z "$TEMPEST_HTTP_IMAGE" ]]; then
john-griffithdc4dc7f2014-01-22 18:09:32 -0700314 iniset $TEMPEST_CONFIG image http_image $TEMPEST_HTTP_IMAGE
Sean Daguec3771452013-06-13 14:23:37 -0400315 fi
316
Andrea Frittoli122a16f2014-08-14 08:18:40 +0100317 # Auth
Matthew Treinish7ced1502015-03-23 15:51:54 -0400318 TEMPEST_ALLOW_TENANT_ISOLATION=${TEMPEST_ALLOW_TENANT_ISOLATION:-$TEMPEST_HAS_ADMIN}
Andrea Frittoli122a16f2014-08-14 08:18:40 +0100319 iniset $TEMPEST_CONFIG auth allow_tenant_isolation ${TEMPEST_ALLOW_TENANT_ISOLATION:-True}
Andrea Frittoli (andreaf)72f026b2015-03-25 17:24:24 -0400320 iniset $TEMPEST_CONFIG auth tempest_roles "Member"
Andrea Frittoli122a16f2014-08-14 08:18:40 +0100321
Attila Fazekas97d3d202013-01-19 19:20:49 +0100322 # Compute
john-griffithdc4dc7f2014-01-22 18:09:32 -0700323 iniset $TEMPEST_CONFIG compute ssh_user ${DEFAULT_INSTANCE_USER:-cirros} # DEPRECATED
324 iniset $TEMPEST_CONFIG compute network_for_ssh $PRIVATE_NETWORK_NAME
325 iniset $TEMPEST_CONFIG compute ip_version_for_ssh 4
326 iniset $TEMPEST_CONFIG compute ssh_timeout $BUILD_TIMEOUT
327 iniset $TEMPEST_CONFIG compute image_ref $image_uuid
328 iniset $TEMPEST_CONFIG compute image_ssh_user ${DEFAULT_INSTANCE_USER:-cirros}
329 iniset $TEMPEST_CONFIG compute image_ref_alt $image_uuid_alt
Kirill Shileev608f8842014-10-03 22:48:58 +0400330 iniset $TEMPEST_CONFIG compute image_alt_ssh_user ${ALT_INSTANCE_USER:-cirros}
john-griffithdc4dc7f2014-01-22 18:09:32 -0700331 iniset $TEMPEST_CONFIG compute flavor_ref $flavor_ref
332 iniset $TEMPEST_CONFIG compute flavor_ref_alt $flavor_ref_alt
john-griffithdc4dc7f2014-01-22 18:09:32 -0700333 iniset $TEMPEST_CONFIG compute ssh_connect_method $ssh_connect_method
Adam Gandelman84ee55b2015-03-30 14:25:27 -0700334 iniset $TEMPEST_CONFIG compute fixed_network_name $PRIVATE_NETWORK_NAME
Attila Fazekas97d3d202013-01-19 19:20:49 +0100335
Sean Daguede19bf92014-03-20 16:54:58 -0400336 # Compute Features
Dean Troyerdc97cb72015-03-28 08:20:50 -0500337 # Run ``verify_tempest_config -ur`` to retrieve enabled extensions on API endpoints
Salvatore33e8ee22014-10-05 01:36:34 +0200338 # NOTE(mtreinish): This must be done after auth settings are added to the tempest config
339 local tmp_cfg_file=$(mktemp)
Joe Gordon1368b982015-02-04 15:28:18 -0800340 cd $TEMPEST_DIR
Pavlo Shchelokovskyy199c6042015-03-18 10:48:47 +0000341 tox -revenv -- verify-tempest-config -uro $tmp_cfg_file
Salvatore33e8ee22014-10-05 01:36:34 +0200342
343 local compute_api_extensions=${COMPUTE_API_EXTENSIONS:-"all"}
344 if [[ ! -z "$DISABLE_COMPUTE_API_EXTENSIONS" ]]; then
345 # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
346 compute_api_extensions=${COMPUTE_API_EXTENSIONS:-$(iniget $tmp_cfg_file compute-feature-enabled api_extensions | tr -d " ")}
347 # Remove disabled extensions
348 compute_api_extensions=$(remove_disabled_extensions $compute_api_extensions $DISABLE_COMPUTE_API_EXTENSIONS)
349 fi
350
Sean Daguede19bf92014-03-20 16:54:58 -0400351 iniset $TEMPEST_CONFIG compute-feature-enabled resize True
Matthew Treinish270f93e2014-03-20 21:18:42 +0000352 iniset $TEMPEST_CONFIG compute-feature-enabled live_migration ${LIVE_MIGRATION_AVAILABLE:-False}
353 iniset $TEMPEST_CONFIG compute-feature-enabled change_password False
354 iniset $TEMPEST_CONFIG compute-feature-enabled block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
Salvatore33e8ee22014-10-05 01:36:34 +0200355 iniset $TEMPEST_CONFIG compute-feature-enabled api_extensions $compute_api_extensions
Matt Riedemann58065f22015-03-14 06:13:26 -0700356 # TODO(mriedem): Remove the preserve_ports flag when Juno is end of life.
357 iniset $TEMPEST_CONFIG compute-feature-enabled preserve_ports True
Sean Daguede19bf92014-03-20 16:54:58 -0400358
armando-migliaccio71ef61a2014-02-19 22:19:24 -0800359 # Network
john-griffithdc4dc7f2014-01-22 18:09:32 -0700360 iniset $TEMPEST_CONFIG network api_version 2.0
361 iniset $TEMPEST_CONFIG network tenant_networks_reachable "$tenant_networks_reachable"
362 iniset $TEMPEST_CONFIG network public_network_id "$public_network_id"
363 iniset $TEMPEST_CONFIG network public_router_id "$public_router_id"
364 iniset $TEMPEST_CONFIG network default_network "$FIXED_RANGE"
Matthew Treinishccf60f72014-03-03 22:48:31 -0500365 iniset $TEMPEST_CONFIG network-feature-enabled ipv6 "$IPV6_ENABLED"
Sean M. Collinsbb2908b2014-05-15 10:24:31 -0400366 iniset $TEMPEST_CONFIG network-feature-enabled ipv6_subnet_attributes "$IPV6_SUBNET_ATTRIBUTES_ENABLED"
Salvatore33e8ee22014-10-05 01:36:34 +0200367
368 local network_api_extensions=${NETWORK_API_EXTENSIONS:-"all"}
369 if [[ ! -z "$DISABLE_NETWORK_API_EXTENSIONS" ]]; then
370 # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
371 network_api_extensions=${NETWORK_API_EXTENSIONS:-$(iniget $tmp_cfg_file network-feature-enabled api_extensions | tr -d " ")}
372 # Remove disabled extensions
373 network_api_extensions=$(remove_disabled_extensions $network_api_extensions $DISABLE_NETWORK_API_EXTENSIONS)
374 fi
375 iniset $TEMPEST_CONFIG network-feature-enabled api_extensions $network_api_extensions
Attila Fazekas2aa35172012-12-05 20:03:40 +0100376
Giulio Fidente97e1bd02013-06-04 05:33:52 +0200377 # boto
Andrey Pavlov0ea8b722015-02-06 22:37:53 +0300378 iniset $TEMPEST_CONFIG boto ec2_url "$EC2_SERVICE_PROTOCOL://$SERVICE_HOST:8773/"
john-griffithdc4dc7f2014-01-22 18:09:32 -0700379 iniset $TEMPEST_CONFIG boto s3_url "http://$SERVICE_HOST:${S3_SERVICE_PORT:-3333}"
380 iniset $TEMPEST_CONFIG boto s3_materials_path "$BOTO_MATERIALS_PATH"
Adalberto Medeiros53971532014-07-10 16:55:49 -0300381 iniset $TEMPEST_CONFIG boto ari_manifest cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-initrd.manifest.xml
382 iniset $TEMPEST_CONFIG boto ami_manifest cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-blank.img.manifest.xml
383 iniset $TEMPEST_CONFIG boto aki_manifest cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-vmlinuz.manifest.xml
john-griffithdc4dc7f2014-01-22 18:09:32 -0700384 iniset $TEMPEST_CONFIG boto instance_type "$boto_instance_type"
385 iniset $TEMPEST_CONFIG boto http_socket_timeout 30
386 iniset $TEMPEST_CONFIG boto ssh_user ${DEFAULT_INSTANCE_USER:-cirros}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100387
Sean Dague669c4fc2014-04-03 11:28:01 -0400388 # Orchestration Tests
389 if is_service_enabled heat; then
390 if [[ ! -z "$HEAT_CFN_IMAGE_URL" ]]; then
Alessandro Pilottif3e75bf2014-12-15 20:02:08 +0200391 iniset $TEMPEST_CONFIG orchestration image_ref $(basename "${HEAT_CFN_IMAGE_URL%.*}")
Sean Dague669c4fc2014-04-03 11:28:01 -0400392 fi
Attila Fazekas51557a52014-06-13 16:09:37 +0200393 # build a specialized heat flavor
Sean Dague669c4fc2014-04-03 11:28:01 -0400394 available_flavors=$(nova flavor-list)
395 if [[ ! ( $available_flavors =~ 'm1.heat' ) ]]; then
Attila Fazekas51557a52014-06-13 16:09:37 +0200396 nova flavor-create m1.heat 451 512 0 1
Sean Dague669c4fc2014-04-03 11:28:01 -0400397 fi
398 iniset $TEMPEST_CONFIG orchestration instance_type "m1.heat"
399 iniset $TEMPEST_CONFIG orchestration build_timeout 900
Matthew Treinish886cbb22015-03-18 22:03:01 -0400400 iniset $TEMPEST_CONFIG orchestration stack_owner_role "_member_"
Steve Bakerd5cccad2013-07-19 10:34:24 +1200401 fi
402
William Marshall24d866e2013-07-02 12:26:31 -0500403 # Scenario
Matthew Treinishd2cb2342015-04-02 11:08:24 -0400404 SCENARIO_IMAGE_DIR=${SCENARIO_IMAGE_DIR:-$FILES/images/cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-uec}
405 iniset $TEMPEST_CONFIG scenario img_dir $SCENARIO_IMAGE_DIR
Adalberto Medeiros53971532014-07-10 16:55:49 -0300406 iniset $TEMPEST_CONFIG scenario ami_img_file "cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-blank.img"
407 iniset $TEMPEST_CONFIG scenario ari_img_file "cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-initrd"
408 iniset $TEMPEST_CONFIG scenario aki_img_file "cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-vmlinuz"
Matthew Treinishd2cb2342015-04-02 11:08:24 -0400409 iniset $TEMPEST_CONFIG scenario img_file "cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-disk.img"
William Marshall24d866e2013-07-02 12:26:31 -0500410
Joe Gordonbb8c6d42013-08-26 17:00:05 -0400411 # Large Ops Number
john-griffithdc4dc7f2014-01-22 18:09:32 -0700412 iniset $TEMPEST_CONFIG scenario large_ops_number ${TEMPEST_LARGE_OPS_NUMBER:-0}
Joe Gordonbb8c6d42013-08-26 17:00:05 -0400413
Vadim Rovachev2541d612014-05-29 18:48:10 +0400414 # Telemetry
Dean Troyerdc97cb72015-03-28 08:20:50 -0500415 # Ceilometer API optimization happened in Juno that allows to run more tests in tempest.
Vadim Rovachev2541d612014-05-29 18:48:10 +0400416 # Once Tempest retires support for icehouse this flag can be removed.
417 iniset $TEMPEST_CONFIG telemetry too_slow_to_test "False"
418
Dean Troyerdc97cb72015-03-28 08:20:50 -0500419 # Object Store
Salvatore33e8ee22014-10-05 01:36:34 +0200420 local object_storage_api_extensions=${OBJECT_STORAGE_API_EXTENSIONS:-"all"}
421 if [[ ! -z "$DISABLE_OBJECT_STORAGE_API_EXTENSIONS" ]]; then
422 # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
423 object_storage_api_extensions=${OBJECT_STORAGE_API_EXTENSIONS:-$(iniget $tmp_cfg_file object-storage-feature-enabled discoverable_apis | tr -d " ")}
424 # Remove disabled extensions
425 object_storage_api_extensions=$(remove_disabled_extensions $object_storage_api_extensions $DISABLE_STORAGE_API_EXTENSIONS)
426 fi
427 iniset $TEMPEST_CONFIG object-storage-feature-enabled discoverable_apis $object_storage_api_extensions
Salvatore Orlando3046bc62014-08-21 12:11:10 -0700428
Giulio Fidente97e1bd02013-06-04 05:33:52 +0200429 # Volume
Salvatore33e8ee22014-10-05 01:36:34 +0200430 local volume_api_extensions=${VOLUME_API_EXTENSIONS:-"all"}
431 if [[ ! -z "$DISABLE_VOLUME_API_EXTENSIONS" ]]; then
432 # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
433 volume_api_extensions=${VOLUME_API_EXTENSIONS:-$(iniget $tmp_cfg_file volume-feature-enabled api_extensions | tr -d " ")}
434 # Remove disabled extensions
435 volume_api_extensions=$(remove_disabled_extensions $volume_api_extensions $DISABLE_VOLUME_API_EXTENSIONS)
436 fi
437 iniset $TEMPEST_CONFIG volume-feature-enabled api_extensions $volume_api_extensions
438
Giulio Fidente3d60f4d2014-02-20 16:43:49 +0100439 if ! is_service_enabled c-bak; then
440 iniset $TEMPEST_CONFIG volume-feature-enabled backup False
Giulio Fidente3632ab12013-09-10 02:51:26 +0200441 fi
Swapnil Kulkarni09fb7ba2014-10-16 06:30:28 +0000442
Dean Troyerdc97cb72015-03-28 08:20:50 -0500443 # Using ``CINDER_ENABLED_BACKENDS``
Swapnil Kulkarni09fb7ba2014-10-16 06:30:28 +0000444 if [[ -n "$CINDER_ENABLED_BACKENDS" ]] && [[ $CINDER_ENABLED_BACKENDS =~ .*,.* ]]; then
Matthew Treinishdb1c3842014-02-04 20:58:00 +0000445 iniset $TEMPEST_CONFIG volume-feature-enabled multi_backend "True"
Swapnil Kulkarni09fb7ba2014-10-16 06:30:28 +0000446 local i=1
447 local be
448 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
449 local be_name=${be##*:}
450 iniset $TEMPEST_CONFIG volume "backend${i}_name" "$be_name"
451 i=$(( i + 1 ))
452 done
john-griffithdc4dc7f2014-01-22 18:09:32 -0700453 fi
454
Eric Harney01456482014-10-14 18:53:53 -0400455 if [ $TEMPEST_VOLUME_DRIVER != "default" -o \
Patrick East1c0628f2014-10-22 16:22:47 -0700456 "$TEMPEST_VOLUME_VENDOR" != "$TEMPEST_DEFAULT_VOLUME_VENDOR" ]; then
Ed Balduf2f23d752014-07-29 14:42:27 -0600457 iniset $TEMPEST_CONFIG volume vendor_name "$TEMPEST_VOLUME_VENDOR"
Eric Harney01456482014-10-14 18:53:53 -0400458 fi
459 if [ $TEMPEST_VOLUME_DRIVER != "default" -o \
JordanP82a7d932014-12-04 14:09:16 +0100460 "$TEMPEST_STORAGE_PROTOCOL" != "$TEMPEST_DEFAULT_STORAGE_PROTOCOL" ]; then
461 iniset $TEMPEST_CONFIG volume storage_protocol "$TEMPEST_STORAGE_PROTOCOL"
Giulio Fidente97e1bd02013-06-04 05:33:52 +0200462 fi
463
Julie Pichonfea70f82013-07-29 11:22:08 +0100464 # Dashboard
john-griffithdc4dc7f2014-01-22 18:09:32 -0700465 iniset $TEMPEST_CONFIG dashboard dashboard_url "http://$SERVICE_HOST/"
466 iniset $TEMPEST_CONFIG dashboard login_url "http://$SERVICE_HOST/auth/login/"
Julie Pichonfea70f82013-07-29 11:22:08 +0100467
Dean Troyerdc97cb72015-03-28 08:20:50 -0500468 # CLI
john-griffithdc4dc7f2014-01-22 18:09:32 -0700469 iniset $TEMPEST_CONFIG cli cli_dir $NOVA_BIN_DIR
Ian Wienand7fa19022013-06-25 14:11:48 +1000470
Adam Gandelman43bd6672014-04-03 11:13:13 -0700471 # Baremetal
472 if [ "$VIRT_DRIVER" = "ironic" ] ; then
473 iniset $TEMPEST_CONFIG baremetal driver_enabled True
Adam Gandelmanfdfe7a02014-07-24 10:06:18 -0400474 iniset $TEMPEST_CONFIG compute-feature-enabled change_password False
475 iniset $TEMPEST_CONFIG compute-feature-enabled console_output False
476 iniset $TEMPEST_CONFIG compute-feature-enabled interface_attach False
477 iniset $TEMPEST_CONFIG compute-feature-enabled live_migration False
478 iniset $TEMPEST_CONFIG compute-feature-enabled pause False
479 iniset $TEMPEST_CONFIG compute-feature-enabled rescue False
480 iniset $TEMPEST_CONFIG compute-feature-enabled resize False
481 iniset $TEMPEST_CONFIG compute-feature-enabled shelve False
482 iniset $TEMPEST_CONFIG compute-feature-enabled snapshot False
David Shrewsburycf21b712014-08-13 07:03:58 -0400483 iniset $TEMPEST_CONFIG compute-feature-enabled suspend False
Adam Gandelman43bd6672014-04-03 11:13:13 -0700484 fi
485
Nels Nelson7b47c472015-01-05 16:36:42 -0600486 # Libvirt-LXC
487 if [ "$VIRT_DRIVER" = "libvirt" ] && [ "$LIBVIRT_TYPE" = "lxc" ]; then
488 iniset $TEMPEST_CONFIG compute-feature-enabled rescue False
489 iniset $TEMPEST_CONFIG compute-feature-enabled resize False
490 iniset $TEMPEST_CONFIG compute-feature-enabled suspend False
491 fi
492
Dean Troyerdc97cb72015-03-28 08:20:50 -0500493 # ``service_available``
Dean Troyer4237f592014-01-29 16:22:11 -0600494 for service in ${TEMPEST_SERVICES//,/ }; do
Matthew Treinishb56d81d2013-07-23 17:25:39 -0400495 if is_service_enabled $service ; then
john-griffithdc4dc7f2014-01-22 18:09:32 -0700496 iniset $TEMPEST_CONFIG service_available $service "True"
Matthew Treinishb56d81d2013-07-23 17:25:39 -0400497 else
john-griffithdc4dc7f2014-01-22 18:09:32 -0700498 iniset $TEMPEST_CONFIG service_available $service "False"
Matthew Treinishb56d81d2013-07-23 17:25:39 -0400499 fi
500 done
501
Rob Crittendene1d013f2015-02-10 14:15:35 -0500502 if is_ssl_enabled_service "key" || is_service_enabled tls-proxy; then
Dean Troyerdc97cb72015-03-28 08:20:50 -0500503 # Use the ``BOTO_CONFIG`` environment variable to point to this file
Rob Crittenden90c20202014-11-17 01:16:22 -0500504 iniset $BOTO_CONF Boto ca_certificates_file $SSL_BUNDLE_FILE
505 sudo chown $STACK_USER $BOTO_CONF
506 fi
507
Attila Fazekas2aa35172012-12-05 20:03:40 +0100508 # Restore IFS
509 IFS=$ifs
Sean Dagued0931212012-10-04 16:06:44 -0400510}
511
Dean Troyer42a59c22014-03-03 14:31:29 -0600512# create_tempest_accounts() - Set up common required tempest accounts
513
514# Project User Roles
515# ------------------------------------------------------------------
516# alt_demo alt_demo Member
517
Dean Troyer42a59c22014-03-03 14:31:29 -0600518function create_tempest_accounts {
519 if is_service_enabled tempest; then
520 # Tempest has some tests that validate various authorization checks
521 # between two regular users in separate tenants
Bartosz Górski0abde392014-02-28 14:15:19 +0100522 get_or_create_project alt_demo
Jamie Lennox18f39bf2015-01-28 13:38:32 +1000523 get_or_create_user alt_demo "$ADMIN_PASSWORD" "alt_demo@example.com"
Jamie Lennox9b215db2015-02-10 18:19:57 +1100524 get_or_add_user_project_role Member alt_demo alt_demo
Dean Troyer42a59c22014-03-03 14:31:29 -0600525 fi
526}
527
Dean Troyerdc97cb72015-03-28 08:20:50 -0500528# install_tempest_lib() - Collect source, prepare, and install ``tempest-lib``
Matthew Treinish34723862014-09-08 14:01:21 -0400529function install_tempest_lib {
Sean Dague91b22902014-11-18 07:13:35 -0500530 if use_library_from_git "tempest-lib"; then
531 git_clone_by_name "tempest-lib"
Sean Dague86b65dd2014-11-20 17:23:04 -0500532 setup_dev_lib "tempest-lib"
Dean Troyerdc97cb72015-03-28 08:20:50 -0500533 # NOTE(mtreinish) For testing ``tempest-lib`` from git with Tempest we need to
534 # put the git version of ``tempest-lib`` in the Tempest job's tox venv
Matthew Treinish83e166b2015-02-18 19:01:20 -0500535 export PIP_VIRTUAL_ENV=${PROJECT_VENV["tempest"]}
536 setup_dev_lib "tempest-lib"
537 unset PIP_VIRTUAL_ENV
Sean Dague5cb19062014-11-01 01:37:45 +0100538 fi
Matthew Treinish34723862014-09-08 14:01:21 -0400539}
540
Sean Dagued0931212012-10-04 16:06:44 -0400541# install_tempest() - Collect source and prepare
Ian Wienandaee18c72014-02-21 15:35:08 +1100542function install_tempest {
Sean Dagued0931212012-10-04 16:06:44 -0400543 git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH
Clark Boylan33dc8692014-08-19 22:37:10 -0700544 pip_install tox
Matthew Treinish83e166b2015-02-18 19:01:20 -0500545 pushd $TEMPEST_DIR
546 tox --notest -efull
547 PROJECT_VENV["tempest"]=${TEMPEST_DIR}/.tox/full
548 install_tempest_lib
549 popd
Sean Dagued0931212012-10-04 16:06:44 -0400550}
551
Dean Troyerdc97cb72015-03-28 08:20:50 -0500552# init_tempest() - Initialize EC2 images
Ian Wienandaee18c72014-02-21 15:35:08 +1100553function init_tempest {
Adalberto Medeiros53971532014-07-10 16:55:49 -0300554 local base_image_name=cirros-${CIRROS_VERSION}-${CIRROS_ARCH}
555 # /opt/stack/devstack/files/images/cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-uec
Attila Fazekas3c529222013-01-21 06:50:33 +0100556 local image_dir="$FILES/images/${base_image_name}-uec"
Attila Fazekas1d29d8b2013-01-07 15:51:32 +0100557 local kernel="$image_dir/${base_image_name}-vmlinuz"
558 local ramdisk="$image_dir/${base_image_name}-initrd"
559 local disk_image="$image_dir/${base_image_name}-blank.img"
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200560 if is_service_enabled nova; then
Dean Troyerdc97cb72015-03-28 08:20:50 -0500561 # If the CirrOS uec downloaded and the system is UEC capable
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200562 if [ -f "$kernel" -a -f "$ramdisk" -a -f "$disk_image" -a "$VIRT_DRIVER" != "openvz" \
563 -a \( "$LIBVIRT_TYPE" != "lxc" -o "$VIRT_DRIVER" != "libvirt" \) ]; then
564 echo "Prepare aki/ari/ami Images"
565 mkdir -p $BOTO_MATERIALS_PATH
566 ( #new namespace
567 # tenant:demo ; user: demo
568 source $TOP_DIR/accrc/demo/demo
569 euca-bundle-image -r ${CIRROS_ARCH} -i "$kernel" --kernel true -d "$BOTO_MATERIALS_PATH"
570 euca-bundle-image -r ${CIRROS_ARCH} -i "$ramdisk" --ramdisk true -d "$BOTO_MATERIALS_PATH"
571 euca-bundle-image -r ${CIRROS_ARCH} -i "$disk_image" -d "$BOTO_MATERIALS_PATH"
572 ) 2>&1 </dev/null | cat
573 else
574 echo "Boto materials are not prepared"
575 fi
Attila Fazekas1d29d8b2013-01-07 15:51:32 +0100576 fi
577}
578
Sean Dagued0931212012-10-04 16:06:44 -0400579# Restore xtrace
580$XTRACE
Sean Dague584d90e2013-03-29 14:34:53 -0400581
Adam Spiers6a5aa7c2013-10-24 11:27:02 +0100582# Tell emacs to use shell-script-mode
583## Local variables:
584## mode: shell-script
585## End: