blob: 24c8271132691b7b97513c3066b6342edd1d5945 [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``
Matthew Treinishbefe0922017-02-16 15:45:11 -050014# - ``DEFAULT_IMAGE_FILE_NAME``
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010015# - ``S3_SERVICE_PORT``
16# - ``SERVICE_HOST``
17# - ``BASE_SQL_CONN`` ``lib/database`` declares
18# - ``PUBLIC_NETWORK_NAME``
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010019# - ``VIRT_DRIVER``
20# - ``LIBVIRT_TYPE``
Dr. Jens Harbotteb0ac1d2024-07-08 18:02:25 +020021# - ``KEYSTONE_SERVICE_URI_V3`` from lib/keystone
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010022#
Attila Fazekas2aa35172012-12-05 20:03:40 +010023# Optional Dependencies:
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010024#
Einst Crazyf54f60a2015-10-30 23:00:57 +080025# - ``ALT_*``
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010026# - ``LIVE_MIGRATION_AVAILABLE``
27# - ``USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION``
28# - ``DEFAULT_INSTANCE_TYPE``
29# - ``DEFAULT_INSTANCE_USER``
Weronika Sikorad7d87b02019-09-18 13:45:53 +000030# - ``DEFAULT_INSTANCE_ALT_USER``
Swapnil Kulkarni09fb7ba2014-10-16 06:30:28 +000031# - ``CINDER_ENABLED_BACKENDS``
Lukas Piwowarski8c25a852023-10-05 08:11:05 +000032# - ``CINDER_BACKUP_DRIVER``
Matt Riedemann89ee5852015-07-09 13:25:04 -070033# - ``NOVA_ALLOW_DUPLICATE_NETWORKS``
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010034#
Sean Dagued0931212012-10-04 16:06:44 -040035# ``stack.sh`` calls the entry points in this order:
36#
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010037# - install_tempest
38# - configure_tempest
Sean Dagued0931212012-10-04 16:06:44 -040039
40# Save trace setting
Ian Wienand523f4882015-10-13 11:03:03 +110041_XTRACE_TEMPEST=$(set +o | grep xtrace)
Sean Dagued0931212012-10-04 16:06:44 -040042set +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
49TEMPEST_DIR=$DEST/tempest
john-griffithdc4dc7f2014-01-22 18:09:32 -070050TEMPEST_CONFIG_DIR=${TEMPEST_CONFIG_DIR:-$TEMPEST_DIR/etc}
51TEMPEST_CONFIG=$TEMPEST_CONFIG_DIR/tempest.conf
Matthew Treinish14ccba02013-07-29 16:15:53 -040052TEMPEST_STATE_PATH=${TEMPEST_STATE_PATH:=$DATA_DIR/tempest}
Attila Fazekas2aa35172012-12-05 20:03:40 +010053
Arx Cruz1bde9b42014-07-18 11:34:33 -030054# This is the timeout that tempest will wait for a VM to change state,
55# spawn, delete, etc.
56# The default is set to 196 seconds.
57BUILD_TIMEOUT=${BUILD_TIMEOUT:-196}
Sean Dagued0931212012-10-04 16:06:44 -040058
Joe Gordonc9b245b2015-02-10 14:32:39 -080059# This must be False on stable branches, as master tempest
60# deps do not match stable branch deps. Set this to True to
Dean Troyerdc97cb72015-03-28 08:20:50 -050061# have tempest installed in DevStack by default.
Matthew Treinishcb3cece2015-03-16 10:37:51 -040062INSTALL_TEMPEST=${INSTALL_TEMPEST:-"True"}
Joe Gordonc9b245b2015-02-10 14:32:39 -080063
Matthew Treinish440464c2016-05-04 11:55:12 -040064# This variable is passed directly to pip install inside the common tox venv
65# that is created
66TEMPEST_PLUGINS=${TEMPEST_PLUGINS:-0}
67
john-griffithdc4dc7f2014-01-22 18:09:32 -070068# Cinder/Volume variables
69TEMPEST_VOLUME_DRIVER=${TEMPEST_VOLUME_DRIVER:-default}
Eric Harney01456482014-10-14 18:53:53 -040070TEMPEST_DEFAULT_VOLUME_VENDOR="Open Source"
71TEMPEST_VOLUME_VENDOR=${TEMPEST_VOLUME_VENDOR:-$TEMPEST_DEFAULT_VOLUME_VENDOR}
72TEMPEST_DEFAULT_STORAGE_PROTOCOL="iSCSI"
73TEMPEST_STORAGE_PROTOCOL=${TEMPEST_STORAGE_PROTOCOL:-$TEMPEST_DEFAULT_STORAGE_PROTOCOL}
Dean Troyercc6b4432013-04-08 15:38:03 -050074
Brian Rosmaita111a38b2022-05-13 20:53:26 -040075# Glance/Image variables
76# When Glance image import is enabled, image creation is asynchronous and images
77# may not yet be active when tempest looks for them. In that case, we poll
78# Glance every TEMPEST_GLANCE_IMPORT_POLL_INTERVAL seconds for the number of
79# times specified by TEMPEST_GLANCE_IMPORT_POLL_LIMIT. If you are importing
80# multiple images, set TEMPEST_GLANCE_IMAGE_COUNT so the poller does not quit
81# too early (though it will not exceed the polling limit).
82TEMPEST_GLANCE_IMPORT_POLL_INTERVAL=${TEMPEST_GLANCE_IMPORT_POLL_INTERVAL:-1}
83TEMPEST_GLANCE_IMPORT_POLL_LIMIT=${TEMPEST_GLANCE_IMPORT_POLL_LIMIT:-12}
84TEMPEST_GLANCE_IMAGE_COUNT=${TEMPEST_GLANCE_IMAGE_COUNT:-1}
85
armando-migliaccio71ef61a2014-02-19 22:19:24 -080086# Neutron/Network variables
Sean Dague53753292014-12-04 19:38:15 -050087IPV6_ENABLED=$(trueorfalse True IPV6_ENABLED)
88IPV6_SUBNET_ATTRIBUTES_ENABLED=$(trueorfalse True IPV6_SUBNET_ATTRIBUTES_ENABLED)
armando-migliaccio71ef61a2014-02-19 22:19:24 -080089
Matthew Treinishdf8f43b2015-08-09 20:30:39 -040090# Do we want to make a configuration where Tempest has admin on
91# the cloud. We don't always want to so that we can ensure Tempest
92# would work on a public cloud.
93TEMPEST_HAS_ADMIN=$(trueorfalse True TEMPEST_HAS_ADMIN)
94
95# Credential provider configuration option variables
96TEMPEST_ALLOW_TENANT_ISOLATION=${TEMPEST_ALLOW_TENANT_ISOLATION:-$TEMPEST_HAS_ADMIN}
Matthew Treinish403fbb12015-08-24 21:17:37 -040097TEMPEST_USE_TEST_ACCOUNTS=$(trueorfalse False TEMPEST_USE_TEST_ACCOUNTS)
Matthew Treinishdf8f43b2015-08-09 20:30:39 -040098
99# The number of workers tempest is expected to be run with. This is used for
100# generating a accounts.yaml for running with test-accounts. This is also the
101# same variable that devstack-gate uses to specify the number of workers that
102# it will run tempest with
103TEMPEST_CONCURRENCY=${TEMPEST_CONCURRENCY:-$(nproc)}
104
Sean Mooney6df53712024-07-12 20:08:58 +0100105TEMPEST_FLAVOR_RAM=${TEMPEST_FLAVOR_RAM:-192}
106TEMPEST_FLAVOR_ALT_RAM=${TEMPEST_FLAVOR_ALT_RAM:-256}
107
Dan Smith84ce1982024-07-31 19:04:08 +0000108OSTESTIMAGES_REPO=${OSTESTIMAGES_REPO:-${GIT_BASE}/openstack/os-test-images.git}
109OSTESTIMAGES_BRANCH=${OSTESTIMAGES_BRANCH:-$BRANCHLESS_TARGET_BRANCH}
110OSTESTIMAGES_DIR=${DEST}/os-test-images
111
Dean Troyercc6b4432013-04-08 15:38:03 -0500112# Functions
113# ---------
Sean Dagued0931212012-10-04 16:06:44 -0400114
Salvatore33e8ee22014-10-05 01:36:34 +0200115# remove_disabled_extension - removes disabled extensions from the list of extensions
116# to test for a given service
117function remove_disabled_extensions {
118 local extensions_list=$1
119 shift
120 local disabled_exts=$*
fumihiko kakuma8606c982015-04-13 09:55:06 +0900121 remove_disabled_services "$extensions_list" "$disabled_exts"
Salvatore33e8ee22014-10-05 01:36:34 +0200122}
123
Matt Riedemann23d33a82018-11-21 12:10:32 -0500124# image_size_in_gib - converts an image size from bytes to GiB, rounded up
125# Takes an image ID parameter as input
126function image_size_in_gib {
127 local size
Julia Kreger5c9affd2021-03-12 11:19:52 -0800128 size=$(openstack --os-cloud devstack-admin image show $1 -c size -f value)
Lucas Alvares Gomes40f75792019-11-26 15:20:03 +0000129 echo $size | python3 -c "import math; print(int(math.ceil(float(int(input()) / 1024.0 ** 3))))"
Matt Riedemann23d33a82018-11-21 12:10:32 -0500130}
131
Ghanshyam Mann3bdc8f62021-02-09 12:56:34 -0600132function set_tempest_venv_constraints {
133 local tmp_c
134 tmp_c=$1
135 if [[ $TEMPEST_VENV_UPPER_CONSTRAINTS == "master" ]]; then
Dr. Jens Harbott2ef4a4c2022-01-03 15:13:44 +0100136 (cd $REQUIREMENTS_DIR &&
137 git show master:upper-constraints.txt 2>/dev/null ||
138 git show origin/master:upper-constraints.txt) > $tmp_c
Ghanshyam Mann7fe99812023-01-26 22:28:07 -0600139 # NOTE(gmann): we need to set the below env var pointing to master
140 # constraints even that is what default in tox.ini. Otherwise it can
141 # create the issue for grenade run where old and new devstack can have
142 # different tempest (old and master) to install. For detail problem,
143 # refer to the https://bugs.launchpad.net/devstack/+bug/2003993
144 export UPPER_CONSTRAINTS_FILE=https://releases.openstack.org/constraints/upper/master
145 export TOX_CONSTRAINTS_FILE=https://releases.openstack.org/constraints/upper/master
Ghanshyam Mann3bdc8f62021-02-09 12:56:34 -0600146 else
147 echo "Using $TEMPEST_VENV_UPPER_CONSTRAINTS constraints in Tempest virtual env."
148 cat $TEMPEST_VENV_UPPER_CONSTRAINTS > $tmp_c
149 # NOTE: setting both tox env var and once Tempest start using new var
150 # TOX_CONSTRAINTS_FILE then we can remove the old one.
151 export UPPER_CONSTRAINTS_FILE=$TEMPEST_VENV_UPPER_CONSTRAINTS
152 export TOX_CONSTRAINTS_FILE=$TEMPEST_VENV_UPPER_CONSTRAINTS
153 fi
154}
155
Brian Rosmaita111a38b2022-05-13 20:53:26 -0400156# Makes a call to glance to get a list of active images, ignoring
157# ramdisk and kernel images. Takes 3 arguments, an array and two
158# variables. The array will contain the list of active image UUIDs;
159# if an image with ``DEFAULT_IMAGE_NAME`` is found, its UUID will be
Ghanshyam Manne32715b2023-06-22 21:10:31 -0500160# set as the value img_id ($2) parameters.
Brian Rosmaita111a38b2022-05-13 20:53:26 -0400161function get_active_images {
162 declare -n img_array=$1
163 declare -n img_id=$2
Brian Rosmaita111a38b2022-05-13 20:53:26 -0400164
165 # start with a fresh array in case we are called multiple times
166 img_array=()
167
168 while read -r IMAGE_NAME IMAGE_UUID; do
169 if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then
170 img_id="$IMAGE_UUID"
Brian Rosmaita111a38b2022-05-13 20:53:26 -0400171 fi
172 img_array+=($IMAGE_UUID)
173 done < <(openstack --os-cloud devstack-admin image list --property status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }')
174}
175
176function poll_glance_images {
177 declare -n image_array=$1
178 declare -n image_id=$2
Brian Rosmaita111a38b2022-05-13 20:53:26 -0400179 local -i poll_count
180
181 poll_count=$TEMPEST_GLANCE_IMPORT_POLL_LIMIT
182 while (( poll_count-- > 0 )) ; do
183 sleep $TEMPEST_GLANCE_IMPORT_POLL_INTERVAL
Ghanshyam Manne32715b2023-06-22 21:10:31 -0500184 get_active_images image_array image_id
Brian Rosmaita111a38b2022-05-13 20:53:26 -0400185 if (( ${#image_array[*]} >= $TEMPEST_GLANCE_IMAGE_COUNT )) ; then
186 return
187 fi
188 done
189 local msg
190 msg="Polling limit of $TEMPEST_GLANCE_IMPORT_POLL_LIMIT exceeded; "
191 msg+="poll interval was $TEMPEST_GLANCE_IMPORT_POLL_INTERVAL sec"
192 warn $LINENO "$msg"
193}
194
Sean Dagued0931212012-10-04 16:06:44 -0400195# configure_tempest() - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +1100196function configure_tempest {
Joe Gordonc9b245b2015-02-10 14:32:39 -0800197 if [[ "$INSTALL_TEMPEST" == "True" ]]; then
198 setup_develop $TEMPEST_DIR
199 else
200 # install testr since its used to process tempest logs
Sean Dague60996b12015-04-08 09:06:49 -0400201 pip_install_gr testrepository
Joe Gordonc9b245b2015-02-10 14:32:39 -0800202 fi
Joe Gordond5ac7852015-02-06 19:29:23 -0800203
Attila Fazekas65c08462012-12-07 14:20:51 +0100204 local image_lines
205 local images
206 local num_images
207 local image_uuid
208 local image_uuid_alt
Attila Fazekas65c08462012-12-07 14:20:51 +0100209 local password
210 local line
211 local flavors
Clark Boylan3b80bde2013-11-20 17:51:50 -0800212 local available_flavors
Attila Fazekas65c08462012-12-07 14:20:51 +0100213 local flavors_ref
214 local flavor_lines
Szymon Datko28c49812019-08-22 15:39:53 +0200215 local flavor_ref_size
216 local flavor_ref_alt_size
Maru Newbya5c774e2012-12-10 10:40:01 +0000217 local public_network_id
Maru Newby31c94ab2012-12-19 03:59:20 +0000218 local public_router_id
Sean Dague5544c4a2016-01-25 08:27:06 -0500219 local ssh_connect_method="floating"
Matt Riedemann23d33a82018-11-21 12:10:32 -0500220 local disk
Attila Fazekas2aa35172012-12-05 20:03:40 +0100221
Dean Troyer6d04fd72012-12-21 11:03:37 -0600222 # Save IFS
Attila Fazekas2aa35172012-12-05 20:03:40 +0100223 ifs=$IFS
224
225 # Glance should already contain images to be used in tempest
226 # testing. Here we simply look for images stored in Glance
227 # and set the appropriate variables for use in the tempest config
228 # We ignore ramdisk and kernel images, look for the default image
Attila Fazekas65c08462012-12-07 14:20:51 +0100229 # ``DEFAULT_IMAGE_NAME``. If not found, we set the ``image_uuid`` to the
230 # first image returned and set ``image_uuid_alt`` to the second,
Attila Fazekas2aa35172012-12-05 20:03:40 +0100231 # if there is more than one returned...
232 # ... Also ensure we only take active images, so we don't get snapshots in process
Cody A.W. Somervillec24e23b2012-12-21 02:10:45 -0500233 declare -a images
234
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200235 if is_service_enabled glance; then
Ghanshyam Manne32715b2023-06-22 21:10:31 -0500236 get_active_images images image_uuid
Brian Rosmaita111a38b2022-05-13 20:53:26 -0400237
238 if (( ${#images[*]} < $TEMPEST_GLANCE_IMAGE_COUNT )); then
239 # Glance image import is asynchronous and may be configured
240 # to do image conversion. If image import is being used,
241 # it's possible that this code is being executed before the
242 # import has completed and there may be no active images yet.
243 if [[ "$GLANCE_USE_IMPORT_WORKFLOW" == "True" ]]; then
Ghanshyam Manne32715b2023-06-22 21:10:31 -0500244 poll_glance_images images image_uuid
Brian Rosmaita111a38b2022-05-13 20:53:26 -0400245 if (( ${#images[*]} < $TEMPEST_GLANCE_IMAGE_COUNT )); then
246 echo "Only found ${#images[*]} image(s), was looking for $TEMPEST_GLANCE_IMAGE_COUNT"
247 exit 1
248 fi
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200249 fi
Brian Rosmaita111a38b2022-05-13 20:53:26 -0400250 fi
Cody A.W. Somervillec24e23b2012-12-21 02:10:45 -0500251
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200252 case "${#images[*]}" in
253 0)
254 echo "Found no valid images to use!"
255 exit 1
256 ;;
257 1)
258 if [ -z "$image_uuid" ]; then
259 image_uuid=${images[0]}
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200260 fi
Brian Haleye261bd82023-07-19 16:04:12 -0400261 image_uuid_alt=$image_uuid
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200262 ;;
263 *)
264 if [ -z "$image_uuid" ]; then
265 image_uuid=${images[0]}
Ghanshyam Manne32715b2023-06-22 21:10:31 -0500266 if [ -z "$image_uuid_alt" ]; then
267 image_uuid_alt=${images[1]}
268 fi
269 elif [ -z "$image_uuid_alt" ]; then
yatinkarel931b45d2023-07-19 12:15:52 +0530270 for image in ${images[@]}; do
Ghanshyam Manne32715b2023-06-22 21:10:31 -0500271 if [[ "$image" != "$image_uuid" ]]; then
272 image_uuid_alt=$image
yatinkarel931b45d2023-07-19 12:15:52 +0530273 break
Ghanshyam Manne32715b2023-06-22 21:10:31 -0500274 fi
275 done
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200276 fi
277 ;;
278 esac
279 fi
Attila Fazekas2aa35172012-12-05 20:03:40 +0100280
Matthew Treinish93c10572015-07-31 10:38:50 -0400281 # (Re)create ``tempest.conf``
282 # Create every time because the image UUIDS are going to change
Dean Troyer8421c2b2015-03-16 13:52:19 -0500283 sudo install -d -o $STACK_USER $TEMPEST_CONFIG_DIR
Matthew Treinish93c10572015-07-31 10:38:50 -0400284 rm -f $TEMPEST_CONFIG
Attila Fazekas2aa35172012-12-05 20:03:40 +0100285
Balagopal7ed812c2016-03-01 04:43:31 +0000286 local password=${ADMIN_PASSWORD:-secret}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100287
Dean Troyerdc97cb72015-03-28 08:20:50 -0500288 # See ``lib/keystone`` where these users and tenants are set up
Sean Dague0f765352016-02-18 06:53:08 -0500289 local admin_username=${ADMIN_USERNAME:-admin}
Sean Dague76392b52016-04-04 09:07:08 -0400290 local admin_project_name=${ADMIN_TENANT_NAME:-admin}
Sean Dague0f765352016-02-18 06:53:08 -0500291 local admin_domain_name=${ADMIN_DOMAIN_NAME:-Default}
Sean Dague0f765352016-02-18 06:53:08 -0500292 local alt_username=${ALT_USERNAME:-alt_demo}
Sean Dague76392b52016-04-04 09:07:08 -0400293 local alt_project_name=${ALT_TENANT_NAME:-alt_demo}
294 local admin_project_id
Julia Kreger5c9affd2021-03-12 11:19:52 -0800295 admin_project_id=$(openstack --os-cloud devstack-admin project list | awk "/ admin / { print \$2 }")
Attila Fazekas2aa35172012-12-05 20:03:40 +0100296
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200297 if is_service_enabled nova; then
Dean Troyerdc97cb72015-03-28 08:20:50 -0500298 # If ``DEFAULT_INSTANCE_TYPE`` is not declared, use the new behavior
299 # Tempest creates its own instance types
Julia Kreger5c9affd2021-03-12 11:19:52 -0800300 available_flavors=$(openstack --os-cloud devstack-admin flavor list)
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200301 if [[ -z "$DEFAULT_INSTANCE_TYPE" ]]; then
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200302 if [[ ! ( $available_flavors =~ 'm1.nano' ) ]]; then
Matt Riedemann23d33a82018-11-21 12:10:32 -0500303 # Determine the flavor disk size based on the image size.
304 disk=$(image_size_in_gib $image_uuid)
Sean Mooney6df53712024-07-12 20:08:58 +0100305 ram=${TEMPEST_FLAVOR_RAM}
306 openstack --os-cloud devstack-admin flavor create --id 42 --ram ${ram} --disk $disk --vcpus 1 --property hw_rng:allowed=True m1.nano
Rafael Folcoba0f1d32013-12-06 17:56:24 -0200307 fi
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200308 flavor_ref=42
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200309 if [[ ! ( $available_flavors =~ 'm1.micro' ) ]]; then
Matt Riedemann23d33a82018-11-21 12:10:32 -0500310 # Determine the alt flavor disk size based on the alt image size.
311 disk=$(image_size_in_gib $image_uuid_alt)
Sean Mooney6df53712024-07-12 20:08:58 +0100312 ram=${TEMPEST_FLAVOR_ALT_RAM}
313 openstack --os-cloud devstack-admin flavor create --id 84 --ram ${ram} --disk $disk --vcpus 1 --property hw_rng:allowed=True m1.micro
Rafael Folcoba0f1d32013-12-06 17:56:24 -0200314 fi
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200315 flavor_ref_alt=84
316 else
Dean Troyerdc97cb72015-03-28 08:20:50 -0500317 # Check Nova for existing flavors, if ``DEFAULT_INSTANCE_TYPE`` is set use it.
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200318 IFS=$'\r\n'
319 flavors=""
Rafael Folco0b4c83a2015-11-26 10:08:36 -0600320 for line in $available_flavors; do
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200321 f=$(echo $line | awk "/ $DEFAULT_INSTANCE_TYPE / { print \$2 }")
322 flavors="$flavors $f"
323 done
Attila Fazekas2aa35172012-12-05 20:03:40 +0100324
Rafael Folco0b4c83a2015-11-26 10:08:36 -0600325 for line in $available_flavors; do
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200326 flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`"
327 done
Attila Fazekas7bf1dd32013-01-12 17:31:26 +0100328
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200329 IFS=" "
330 flavors=($flavors)
331 num_flavors=${#flavors[*]}
332 echo "Found $num_flavors flavors"
333 if [[ $num_flavors -eq 0 ]]; then
334 echo "Found no valid flavors to use!"
335 exit 1
Adalberto Medeiros63a71a22013-06-06 08:46:04 -0400336 fi
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200337 flavor_ref=${flavors[0]}
338 flavor_ref_alt=$flavor_ref
Julia Kreger5c9affd2021-03-12 11:19:52 -0800339 flavor_ref_size=$(openstack --os-cloud devstack-admin flavor show --format value --column disk "${flavor_ref}")
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200340
Dean Troyerdc97cb72015-03-28 08:20:50 -0500341 # Ensure ``flavor_ref`` and ``flavor_ref_alt`` have different values.
342 # Some resize instance in tempest tests depends on this.
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200343 for f in ${flavors[@]:1}; do
John L. Villalovos3345a6d2017-03-13 13:47:34 -0700344 if [[ "$f" != "$flavor_ref" ]]; then
Szymon Datko28c49812019-08-22 15:39:53 +0200345 #
346 # NOTE(sdatko): Resize is only possible when target flavor
347 # is not smaller than the original one. For
348 # Tempest tests, in case there was a bigger
349 # flavor selected as default, e.g. m1.small,
350 # we need to perform additional check.
351 #
Julia Kreger5c9affd2021-03-12 11:19:52 -0800352 flavor_ref_alt_size=$(openstack --os-cloud devstack-admin flavor show --format value --column disk "${f}")
Szymon Datko28c49812019-08-22 15:39:53 +0200353 if [[ "${flavor_ref_alt_size}" -lt "${flavor_ref_size}" ]]; then
354 continue
355 fi
356
Attila Fazekasc411fcf2014-08-19 16:48:14 +0200357 flavor_ref_alt=$f
358 break
359 fi
360 done
361 fi
Attila Fazekas2aa35172012-12-05 20:03:40 +0100362 fi
363
Dan Smith84ce1982024-07-31 19:04:08 +0000364 if is_service_enabled glance; then
365 git_clone $OSTESTIMAGES_REPO $OSTESTIMAGES_DIR $OSTESTIMAGES_BRANCH
366 pushd $OSTESTIMAGES_DIR
367 tox -egenerate
368 popd
369 iniset $TEMPEST_CONFIG image images_manifest_file ${OSTESTIMAGES_DIR}/images/manifest.yaml
370 local image_conversion
371 image_conversion=$(iniget $GLANCE_IMAGE_IMPORT_CONF image_conversion output_format)
372 if [[ "$image_conversion" ]]; then
373 iniset $TEMPEST_CONFIG image-feature-enabled image_conversion True
374 fi
375 fi
376
Dan Smitha2ec7fd2016-08-10 11:14:00 -0700377 iniset $TEMPEST_CONFIG network project_network_cidr $FIXED_RANGE
378
Attila Fazekas386ae8c2013-10-21 09:27:18 +0200379 ssh_connect_method=${TEMPEST_SSH_CONNECT_METHOD:-$ssh_connect_method}
380
Armando Migliaccio53f59d82016-05-17 15:12:24 -0700381 # the public network (for floating ip access) is only available
382 # if the extension is enabled.
Eric Berglund8e142402016-11-29 17:33:28 -0600383 # If NEUTRON_CREATE_INITIAL_NETWORKS is not true, there is no network created
384 # and the public_network_id should not be set.
385 if [[ "$NEUTRON_CREATE_INITIAL_NETWORKS" == "True" ]] && is_networking_extension_supported 'external-net'; then
Julia Kreger5c9affd2021-03-12 11:19:52 -0800386 public_network_id=$(openstack --os-cloud devstack-admin network show -f value -c id $PUBLIC_NETWORK_NAME)
Attila Fazekas0d4c9c92018-09-10 15:52:46 -0600387 # make sure shared network presence does not confuses the tempest tests
Slawek Kaplonski14a0c092022-01-28 09:44:40 +0100388 openstack --os-cloud devstack-admin --os-region "$REGION_NAME" network create --share shared
389 openstack --os-cloud devstack-admin --os-region "$REGION_NAME" subnet create --description shared-subnet --subnet-range ${TEMPEST_SHARED_POOL:-192.168.233.0/24} --network shared shared-subnet
Maru Newbya5c774e2012-12-10 10:40:01 +0000390 fi
391
Masayuki Igawa5a252d92014-11-21 21:55:09 +0900392 iniset $TEMPEST_CONFIG DEFAULT use_syslog $SYSLOG
Dean Troyerdc97cb72015-03-28 08:20:50 -0500393
Matthew Treinish859cc682013-07-26 15:22:44 -0400394 # Oslo
Joe Gordon23d6d502015-03-06 15:24:22 -0800395 iniset $TEMPEST_CONFIG oslo_concurrency lock_path $TEMPEST_STATE_PATH
Matthew Treinish14ccba02013-07-29 16:15:53 -0400396 mkdir -p $TEMPEST_STATE_PATH
john-griffithdc4dc7f2014-01-22 18:09:32 -0700397 iniset $TEMPEST_CONFIG DEFAULT use_stderr False
398 iniset $TEMPEST_CONFIG DEFAULT log_file tempest.log
399 iniset $TEMPEST_CONFIG DEFAULT debug True
Matthew Treinish859cc682013-07-26 15:22:44 -0400400
Attila Fazekas2aa35172012-12-05 20:03:40 +0100401 # Timeouts
john-griffithdc4dc7f2014-01-22 18:09:32 -0700402 iniset $TEMPEST_CONFIG compute build_timeout $BUILD_TIMEOUT
403 iniset $TEMPEST_CONFIG volume build_timeout $BUILD_TIMEOUT
Attila Fazekas2aa35172012-12-05 20:03:40 +0100404
Attila Fazekas97d3d202013-01-19 19:20:49 +0100405 # Identity
Steve Martinellib74e01c2014-12-18 01:35:35 -0500406 iniset $TEMPEST_CONFIG identity uri_v3 "$KEYSTONE_SERVICE_URI_V3"
Rodrigo Duarteb51a8862016-09-26 15:22:35 -0300407 iniset $TEMPEST_CONFIG identity user_lockout_failure_attempts $KEYSTONE_LOCKOUT_FAILURE_ATTEMPTS
408 iniset $TEMPEST_CONFIG identity user_lockout_duration $KEYSTONE_LOCKOUT_DURATION
409 iniset $TEMPEST_CONFIG identity user_unique_last_password_count $KEYSTONE_UNIQUE_LAST_PASSWORD_COUNT
Matthew Treinish7ced1502015-03-23 15:51:54 -0400410 if [[ "$TEMPEST_HAS_ADMIN" == "True" ]]; then
Sean Dague0f765352016-02-18 06:53:08 -0500411 iniset $TEMPEST_CONFIG auth admin_username $admin_username
Matthew Treinishfbe0a622015-12-10 19:36:50 -0500412 iniset $TEMPEST_CONFIG auth admin_password "$password"
Castulo J. Martinez2d9959c2016-11-01 13:34:20 -0700413 iniset $TEMPEST_CONFIG auth admin_project_name $admin_project_name
Sean Dague0f765352016-02-18 06:53:08 -0500414 iniset $TEMPEST_CONFIG auth admin_domain_name $admin_domain_name
Matthew Treinish7ced1502015-03-23 15:51:54 -0400415 fi
Ken'ichi Ohmichidc6e5502017-03-03 16:55:50 -0800416 iniset $TEMPEST_CONFIG identity auth_version ${TEMPEST_AUTH_VERSION:-v3}
Sean Daguef3b2f4c2017-04-13 10:11:48 -0400417 if is_service_enabled tls-proxy; then
Rob Crittendene1d013f2015-02-10 14:15:35 -0500418 iniset $TEMPEST_CONFIG identity ca_certificates_file $SSL_BUNDLE_FILE
419 fi
Attila Fazekas2aa35172012-12-05 20:03:40 +0100420
Rodrigo Duarte0578e422016-03-16 12:15:07 -0300421 # Identity Features
Rodrigo Duarteb51a8862016-09-26 15:22:35 -0300422 if [[ "$KEYSTONE_SECURITY_COMPLIANCE_ENABLED" = True ]]; then
423 iniset $TEMPEST_CONFIG identity-feature-enabled security_compliance True
424 fi
Rodrigo Duarte0578e422016-03-16 12:15:07 -0300425
Leticia Wanderley1d141da2017-08-04 00:42:59 -0300426 # When LDAP is enabled domain specific drivers are also enabled and the users
427 # and groups identity tests must adapt to this scenario
428 if is_service_enabled ldap; then
429 iniset $TEMPEST_CONFIG identity-feature-enabled domain_specific_drivers True
430 fi
431
Felipe Monteiro1ab9a2d2018-03-16 02:02:12 +0000432 # TODO(felipemonteiro): Remove this once Tempest no longer supports Pike
433 # as this is supported in Queens and beyond.
434 iniset $TEMPEST_CONFIG identity-feature-enabled project_tags True
435
Colleen Murphy931f82d2018-02-18 14:11:10 +0100436 # In Queens and later, application credentials are enabled by default
437 # so remove this once Tempest no longer supports Pike.
438 iniset $TEMPEST_CONFIG identity-feature-enabled application_credentials True
439
Colleen Murphyf8aa74b2019-12-27 09:30:57 -0800440 # In Train and later, access rules for application credentials are enabled
441 # by default so remove this once Tempest no longer supports Stein.
442 iniset $TEMPEST_CONFIG identity-feature-enabled access_rules True
443
Sean Daguec3771452013-06-13 14:23:37 -0400444 # Image
Dean Troyerdc97cb72015-03-28 08:20:50 -0500445 # We want to be able to override this variable in the gate to avoid
446 # doing an external HTTP fetch for this test.
Sean Daguec3771452013-06-13 14:23:37 -0400447 if [[ ! -z "$TEMPEST_HTTP_IMAGE" ]]; then
john-griffithdc4dc7f2014-01-22 18:09:32 -0700448 iniset $TEMPEST_CONFIG image http_image $TEMPEST_HTTP_IMAGE
Sean Daguec3771452013-06-13 14:23:37 -0400449 fi
Ghanshyam Mann32d5b1e2020-07-22 20:52:48 -0500450 iniset $TEMPEST_CONFIG image-feature-enabled import_image $GLANCE_USE_IMPORT_WORKFLOW
Dan Smithed164282021-01-18 09:57:00 -0800451 iniset $TEMPEST_CONFIG image-feature-enabled os_glance_reserved True
Dan Smith802259a2021-01-12 22:55:57 +0000452 if is_service_enabled g-api-r; then
Dan Smith61b4fbf2021-03-09 08:05:37 -0800453 iniset $TEMPEST_CONFIG image alternate_image_endpoint image_remote
Dan Smith802259a2021-01-12 22:55:57 +0000454 fi
455
Attila Fazekas97d3d202013-01-19 19:20:49 +0100456 # Compute
john-griffithdc4dc7f2014-01-22 18:09:32 -0700457 iniset $TEMPEST_CONFIG compute image_ref $image_uuid
john-griffithdc4dc7f2014-01-22 18:09:32 -0700458 iniset $TEMPEST_CONFIG compute image_ref_alt $image_uuid_alt
john-griffithdc4dc7f2014-01-22 18:09:32 -0700459 iniset $TEMPEST_CONFIG compute flavor_ref $flavor_ref
460 iniset $TEMPEST_CONFIG compute flavor_ref_alt $flavor_ref_alt
Sean Dague563a7e72015-12-15 17:16:19 -0500461 iniset $TEMPEST_CONFIG validation connect_method $ssh_connect_method
Stephen Finucane4b8cba72019-05-21 14:17:11 +0100462 if ! is_service_enabled neutron; then
melanie wittf5b550e2015-04-10 22:20:07 +0000463 iniset $TEMPEST_CONFIG compute fixed_network_name $PRIVATE_NETWORK_NAME
464 fi
Attila Fazekas97d3d202013-01-19 19:20:49 +0100465
Sean Dague8349aff2015-09-01 12:45:28 -0400466 # Set the service catalog entry for Tempest to run on. Typically
467 # used to try different compute API version targets. The tempest
468 # default if 'compute', which is typically valid, so only set this
469 # if you want to change it.
470 if [[ -n "$TEMPEST_COMPUTE_TYPE" ]]; then
471 iniset $TEMPEST_CONFIG compute catalog_type $TEMPEST_COMPUTE_TYPE
472 fi
473
Sean Daguede19bf92014-03-20 16:54:58 -0400474 # Compute Features
ghanshyam642b07b2015-11-19 10:01:14 +0900475 # Set the microversion range for compute tests.
476 # This is used to run the Nova microversions tests.
477 # Setting [None, latest] range of microversion which allow Tempest to run all microversions tests.
478 # NOTE- To avoid microversion tests failure on stable branch, we need to change "tempest_compute_max_microversion"
479 # for stable branch on each release which should be changed from "latest" to max supported version of that release.
480 local tempest_compute_min_microversion=${TEMPEST_COMPUTE_MIN_MICROVERSION:-None}
481 local tempest_compute_max_microversion=${TEMPEST_COMPUTE_MAX_MICROVERSION:-"latest"}
482 # Reset microversions to None where v2.0 is running which does not support microversion.
483 # Both "None" means no microversion testing.
484 if [[ "$TEMPEST_COMPUTE_TYPE" == "compute_legacy" ]]; then
485 tempest_compute_min_microversion=None
486 tempest_compute_max_microversion=None
487 fi
488 if [ "$tempest_compute_min_microversion" == "None" ]; then
Jordan Pittierf5a50a02016-05-10 14:56:12 +0200489 inicomment $TEMPEST_CONFIG compute min_microversion
ghanshyam642b07b2015-11-19 10:01:14 +0900490 else
Jordan Pittierf5a50a02016-05-10 14:56:12 +0200491 iniset $TEMPEST_CONFIG compute min_microversion $tempest_compute_min_microversion
ghanshyam642b07b2015-11-19 10:01:14 +0900492 fi
493 if [ "$tempest_compute_max_microversion" == "None" ]; then
Jordan Pittierf5a50a02016-05-10 14:56:12 +0200494 inicomment $TEMPEST_CONFIG compute max_microversion
ghanshyam642b07b2015-11-19 10:01:14 +0900495 else
Jordan Pittierf5a50a02016-05-10 14:56:12 +0200496 iniset $TEMPEST_CONFIG compute max_microversion $tempest_compute_max_microversion
ghanshyam642b07b2015-11-19 10:01:14 +0900497 fi
498
Matt Riedemann6d3670a2016-07-03 19:40:25 -0400499 iniset $TEMPEST_CONFIG compute-feature-enabled personality ${ENABLE_FILE_INJECTION:-False}
Sean Daguede19bf92014-03-20 16:54:58 -0400500 iniset $TEMPEST_CONFIG compute-feature-enabled resize True
Matthew Treinish270f93e2014-03-20 21:18:42 +0000501 iniset $TEMPEST_CONFIG compute-feature-enabled live_migration ${LIVE_MIGRATION_AVAILABLE:-False}
502 iniset $TEMPEST_CONFIG compute-feature-enabled change_password False
503 iniset $TEMPEST_CONFIG compute-feature-enabled block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
Pawel Koniszewski8a92b7f2016-10-05 16:14:19 +0200504 iniset $TEMPEST_CONFIG compute-feature-enabled live_migrate_back_and_forth ${LIVE_MIGRATE_BACK_AND_FORTH:-False}
Matt Riedemanne57a3322015-06-20 14:48:00 -0700505 iniset $TEMPEST_CONFIG compute-feature-enabled attach_encrypted_volume ${ATTACH_ENCRYPTED_VOLUME_AVAILABLE:-True}
Artom Lifshitz47058612018-05-23 10:08:56 -0400506
Pavan Kesava Rao71bd10e2021-07-19 13:33:42 -0400507 # Starting Wallaby, nova sanitizes instance hostnames having freeform characters with dashes
508 iniset $TEMPEST_CONFIG compute-feature-enabled hostname_fqdn_sanitization True
509
Artom Lifshitz47058612018-05-23 10:08:56 -0400510 if [[ -n "$NOVA_FILTERS" ]]; then
511 iniset $TEMPEST_CONFIG compute-feature-enabled scheduler_enabled_filters ${NOVA_FILTERS}
512 fi
513
Matt Riedemannffe691e2016-01-12 17:58:44 -0800514 if [[ $ENABLE_VOLUME_MULTIATTACH == "True" ]]; then
515 iniset $TEMPEST_CONFIG compute-feature-enabled volume_multiattach True
516 fi
517
melanie witt6645cf72017-12-13 23:59:09 +0000518 if is_service_enabled n-novnc; then
Michelle Mandel10db2b82016-07-20 11:39:42 -0400519 iniset $TEMPEST_CONFIG compute-feature-enabled vnc_console True
520 fi
521
Marian Horbanea21eb42015-08-18 06:57:18 -0400522 # Network
Jordan Pittierf5a50a02016-05-10 14:56:12 +0200523 iniset $TEMPEST_CONFIG network project_networks_reachable false
john-griffithdc4dc7f2014-01-22 18:09:32 -0700524 iniset $TEMPEST_CONFIG network public_network_id "$public_network_id"
525 iniset $TEMPEST_CONFIG network public_router_id "$public_router_id"
526 iniset $TEMPEST_CONFIG network default_network "$FIXED_RANGE"
Matthew Treinishccf60f72014-03-03 22:48:31 -0500527 iniset $TEMPEST_CONFIG network-feature-enabled ipv6 "$IPV6_ENABLED"
Sean M. Collinsbb2908b2014-05-15 10:24:31 -0400528 iniset $TEMPEST_CONFIG network-feature-enabled ipv6_subnet_attributes "$IPV6_SUBNET_ATTRIBUTES_ENABLED"
Matt Riedemannc9c9d312016-09-15 20:33:22 -0400529 iniset $TEMPEST_CONFIG network-feature-enabled port_security $NEUTRON_PORT_SECURITY
Salvatore33e8ee22014-10-05 01:36:34 +0200530
Slawek Kaplonski24b65ad2021-06-22 15:31:46 +0200531 iniset $TEMPEST_CONFIG enforce_scope neutron "$NEUTRON_ENFORCE_SCOPE"
532
William Marshall24d866e2013-07-02 12:26:31 -0500533 # Scenario
Stephen Finucane970891a2021-03-02 16:45:39 +0000534 SCENARIO_IMAGE_DIR=${SCENARIO_IMAGE_DIR:-$FILES}
535 SCENARIO_IMAGE_FILE=$DEFAULT_IMAGE_FILE_NAME
Martin Kopeca2943892023-04-25 21:50:31 +0200536 SCENARIO_IMAGE_TYPE=${SCENARIO_IMAGE_TYPE:-cirros}
Martin Kopec729546a2020-03-12 10:03:38 +0000537 iniset $TEMPEST_CONFIG scenario img_file $SCENARIO_IMAGE_DIR/$SCENARIO_IMAGE_FILE
William Marshall24d866e2013-07-02 12:26:31 -0500538
Martin Kopeca2943892023-04-25 21:50:31 +0200539 # since version 0.6.0 cirros uses dhcpcd dhcp client by default, however, cirros, prior to the
540 # version 0.6.0, used udhcpc (the only available client at that time) which is also tempest's default
541 if [[ "$SCENARIO_IMAGE_TYPE" == "cirros" ]]; then
542 # the image is a cirros image
543 # use dhcpcd client when version greater or equal 0.6.0
544 if [[ $(echo $CIRROS_VERSION | tr -d '.') -ge 060 ]]; then
545 iniset $TEMPEST_CONFIG scenario dhcp_client dhcpcd
546 fi
547 fi
548
Michael Turek7938d832016-04-12 14:55:21 -0400549 # If using provider networking, use the physical network for validation rather than private
550 TEMPEST_SSH_NETWORK_NAME=$PRIVATE_NETWORK_NAME
551 if is_provider_network; then
552 TEMPEST_SSH_NETWORK_NAME=$PHYSICAL_NETWORK
553 fi
lanoux994db612015-08-03 13:48:12 +0000554 # Validation
Andrea Frittolief1e88e2017-04-20 23:37:32 +0100555 iniset $TEMPEST_CONFIG validation run_validation ${TEMPEST_RUN_VALIDATION:-True}
Matthew Treinishfbe0a622015-12-10 19:36:50 -0500556 iniset $TEMPEST_CONFIG validation ip_version_for_ssh 4
557 iniset $TEMPEST_CONFIG validation ssh_timeout $BUILD_TIMEOUT
Weronika Sikorad7d87b02019-09-18 13:45:53 +0000558 iniset $TEMPEST_CONFIG validation image_ssh_user ${DEFAULT_INSTANCE_USER:=cirros}
559 iniset $TEMPEST_CONFIG validation image_alt_ssh_user ${DEFAULT_INSTANCE_ALT_USER:-$DEFAULT_INSTANCE_USER}
Michael Turek7938d832016-04-12 14:55:21 -0400560 iniset $TEMPEST_CONFIG validation network_for_ssh $TEMPEST_SSH_NETWORK_NAME
lanoux994db612015-08-03 13:48:12 +0000561
Giulio Fidente97e1bd02013-06-04 05:33:52 +0200562 # Volume
Patrick East3eb7c972017-01-13 11:44:54 -0800563 # Only turn on TEMPEST_VOLUME_MANAGE_SNAPSHOT by default for "lvm" backends
564 if [[ "$CINDER_ENABLED_BACKENDS" == *"lvm"* ]]; then
565 TEMPEST_VOLUME_MANAGE_SNAPSHOT=${TEMPEST_VOLUME_MANAGE_SNAPSHOT:-True}
566 fi
567 iniset $TEMPEST_CONFIG volume-feature-enabled manage_snapshot $(trueorfalse False TEMPEST_VOLUME_MANAGE_SNAPSHOT)
jeremy.zhangd5919d02017-03-08 15:27:37 +0800568 # Only turn on TEMPEST_VOLUME_MANAGE_VOLUME by default for "lvm" backends
569 if [[ "$CINDER_ENABLED_BACKENDS" == *"lvm"* ]]; then
570 TEMPEST_VOLUME_MANAGE_VOLUME=${TEMPEST_VOLUME_MANAGE_VOLUME:-True}
571 fi
572 iniset $TEMPEST_CONFIG volume-feature-enabled manage_volume $(trueorfalse False TEMPEST_VOLUME_MANAGE_VOLUME)
Matt Riedemann17cdecc2017-07-05 20:25:02 -0400573 # Only turn on TEMPEST_EXTEND_ATTACHED_VOLUME by default for "lvm" backends
574 # in Cinder and the libvirt driver in Nova.
575 if [[ "$CINDER_ENABLED_BACKENDS" == *"lvm"* ]] && [ "$VIRT_DRIVER" = "libvirt" ]; then
576 TEMPEST_EXTEND_ATTACHED_VOLUME=${TEMPEST_EXTEND_ATTACHED_VOLUME:-True}
577 fi
578 iniset $TEMPEST_CONFIG volume-feature-enabled extend_attached_volume $(trueorfalse False TEMPEST_EXTEND_ATTACHED_VOLUME)
Luigi Toscano8fd45de2020-05-12 12:00:20 +0200579 # Only turn on TEMPEST_VOLUME_REVERT_TO_SNAPSHOT by default for "lvm" backends
580 if [[ "$CINDER_ENABLED_BACKENDS" == *"lvm"* ]]; then
581 TEMPEST_VOLUME_REVERT_TO_SNAPSHOT=${TEMPEST_VOLUME_REVERT_TO_SNAPSHOT:-True}
582 fi
583 iniset $TEMPEST_CONFIG volume-feature-enabled volume_revert $(trueorfalse False TEMPEST_VOLUME_REVERT_TO_SNAPSHOT)
Lukas Piwowarski8c25a852023-10-05 08:11:05 +0000584 if [[ "$CINDER_BACKUP_DRIVER" == *"swift"* ]]; then
585 iniset $TEMPEST_CONFIG volume backup_driver swift
586 fi
Alex Meade0c0c09a2016-05-13 10:57:29 -0400587 local tempest_volume_min_microversion=${TEMPEST_VOLUME_MIN_MICROVERSION:-None}
588 local tempest_volume_max_microversion=${TEMPEST_VOLUME_MAX_MICROVERSION:-"latest"}
589 if [ "$tempest_volume_min_microversion" == "None" ]; then
590 inicomment $TEMPEST_CONFIG volume min_microversion
591 else
592 iniset $TEMPEST_CONFIG volume min_microversion $tempest_volume_min_microversion
593 fi
594
595 if [ "$tempest_volume_max_microversion" == "None" ]; then
596 inicomment $TEMPEST_CONFIG volume max_microversion
597 else
598 iniset $TEMPEST_CONFIG volume max_microversion $tempest_volume_max_microversion
599 fi
David Kranzd1d66672015-06-11 13:09:37 -0400600
Giulio Fidente3d60f4d2014-02-20 16:43:49 +0100601 if ! is_service_enabled c-bak; then
602 iniset $TEMPEST_CONFIG volume-feature-enabled backup False
Giulio Fidente3632ab12013-09-10 02:51:26 +0200603 fi
Swapnil Kulkarni09fb7ba2014-10-16 06:30:28 +0000604
Dean Troyerdc97cb72015-03-28 08:20:50 -0500605 # Using ``CINDER_ENABLED_BACKENDS``
bkopilov3ac1ea82016-06-06 16:00:48 +0300606 # Cinder uses a comma separated list with "type:backend_name":
607 # CINDER_ENABLED_BACKENDS = ceph:cephBE1,lvm:lvmBE2,foo:my_foo
Swapnil Kulkarni09fb7ba2014-10-16 06:30:28 +0000608 if [[ -n "$CINDER_ENABLED_BACKENDS" ]] && [[ $CINDER_ENABLED_BACKENDS =~ .*,.* ]]; then
bkopilov3ac1ea82016-06-06 16:00:48 +0300609 # We have at least 2 backends
Matthew Treinishdb1c3842014-02-04 20:58:00 +0000610 iniset $TEMPEST_CONFIG volume-feature-enabled multi_backend "True"
bkopilov3ac1ea82016-06-06 16:00:48 +0300611 local add_comma_seperator=0
612 local backends_list=''
Swapnil Kulkarni09fb7ba2014-10-16 06:30:28 +0000613 local be
bkopilov3ac1ea82016-06-06 16:00:48 +0300614 # Tempest uses a comma separated list of backend_names:
615 # backend_names = BACKEND_1,BACKEND_2
Swapnil Kulkarni09fb7ba2014-10-16 06:30:28 +0000616 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
bkopilov3ac1ea82016-06-06 16:00:48 +0300617 if [ "$add_comma_seperator" -eq "1" ]; then
618 backends_list+=,${be##*:}
619 else
620 # first element in the list
621 backends_list+=${be##*:}
622 add_comma_seperator=1
623 fi
Swapnil Kulkarni09fb7ba2014-10-16 06:30:28 +0000624 done
bkopilov3ac1ea82016-06-06 16:00:48 +0300625 iniset $TEMPEST_CONFIG volume "backend_names" "$backends_list"
john-griffithdc4dc7f2014-01-22 18:09:32 -0700626 fi
627
Eric Harney01456482014-10-14 18:53:53 -0400628 if [ $TEMPEST_VOLUME_DRIVER != "default" -o \
Patrick East1c0628f2014-10-22 16:22:47 -0700629 "$TEMPEST_VOLUME_VENDOR" != "$TEMPEST_DEFAULT_VOLUME_VENDOR" ]; then
Ed Balduf2f23d752014-07-29 14:42:27 -0600630 iniset $TEMPEST_CONFIG volume vendor_name "$TEMPEST_VOLUME_VENDOR"
Eric Harney01456482014-10-14 18:53:53 -0400631 fi
632 if [ $TEMPEST_VOLUME_DRIVER != "default" -o \
JordanP82a7d932014-12-04 14:09:16 +0100633 "$TEMPEST_STORAGE_PROTOCOL" != "$TEMPEST_DEFAULT_STORAGE_PROTOCOL" ]; then
634 iniset $TEMPEST_CONFIG volume storage_protocol "$TEMPEST_STORAGE_PROTOCOL"
Giulio Fidente97e1bd02013-06-04 05:33:52 +0200635 fi
636
Rajat Dhasmana1898a682023-03-14 05:35:33 +0000637 if [[ $ENABLE_VOLUME_MULTIATTACH == "True" ]]; then
638 iniset $TEMPEST_CONFIG volume volume_type_multiattach $VOLUME_TYPE_MULTIATTACH
639 fi
640
Ghanshyam Mannfc207052019-06-05 08:24:45 +0000641 # Placement Features
642 # Set the microversion range for placement.
643 # Setting [None, latest] range of microversion which allow Tempest to run all microversions tests.
644 # NOTE- To avoid microversion tests failure on stable branch, we need to change "tempest_placement_max_microversion"
645 # for stable branch on each release which should be changed from "latest" to max supported version of that release.
646 local tempest_placement_min_microversion=${TEMPEST_PLACEMENT_MIN_MICROVERSION:-None}
647 local tempest_placement_max_microversion=${TEMPEST_PLACEMENT_MAX_MICROVERSION:-"latest"}
648 if [ "$tempest_placement_min_microversion" == "None" ]; then
649 inicomment $TEMPEST_CONFIG placement min_microversion
650 else
651 iniset $TEMPEST_CONFIG placement min_microversion $tempest_placement_min_microversion
652 fi
653 if [ "$tempest_placement_max_microversion" == "None" ]; then
654 inicomment $TEMPEST_CONFIG placement max_microversion
655 else
656 iniset $TEMPEST_CONFIG placement max_microversion $tempest_placement_max_microversion
657 fi
658
Adam Gandelman43bd6672014-04-03 11:13:13 -0700659 # Baremetal
660 if [ "$VIRT_DRIVER" = "ironic" ] ; then
Adam Gandelmanfdfe7a02014-07-24 10:06:18 -0400661 iniset $TEMPEST_CONFIG compute-feature-enabled change_password False
662 iniset $TEMPEST_CONFIG compute-feature-enabled console_output False
663 iniset $TEMPEST_CONFIG compute-feature-enabled interface_attach False
664 iniset $TEMPEST_CONFIG compute-feature-enabled live_migration False
665 iniset $TEMPEST_CONFIG compute-feature-enabled pause False
666 iniset $TEMPEST_CONFIG compute-feature-enabled rescue False
667 iniset $TEMPEST_CONFIG compute-feature-enabled resize False
668 iniset $TEMPEST_CONFIG compute-feature-enabled shelve False
669 iniset $TEMPEST_CONFIG compute-feature-enabled snapshot False
David Shrewsburycf21b712014-08-13 07:03:58 -0400670 iniset $TEMPEST_CONFIG compute-feature-enabled suspend False
Adam Gandelman43bd6672014-04-03 11:13:13 -0700671 fi
672
Matt Riedemann92575ba2016-09-21 16:15:31 -0400673 # Libvirt
674 if [ "$VIRT_DRIVER" = "libvirt" ]; then
675 # Libvirt-LXC
676 if [ "$LIBVIRT_TYPE" = "lxc" ]; then
677 iniset $TEMPEST_CONFIG compute-feature-enabled rescue False
678 iniset $TEMPEST_CONFIG compute-feature-enabled resize False
679 iniset $TEMPEST_CONFIG compute-feature-enabled shelve False
680 iniset $TEMPEST_CONFIG compute-feature-enabled snapshot False
681 iniset $TEMPEST_CONFIG compute-feature-enabled suspend False
Stephen Finucane4b8cba72019-05-21 14:17:11 +0100682 else
Alexandre Arents4a1186a2020-09-17 12:50:53 +0000683 iniset $TEMPEST_CONFIG compute-feature-enabled shelve_migrate True
Lee Yarwood4361ef12019-12-11 17:53:44 +0000684 iniset $TEMPEST_CONFIG compute-feature-enabled stable_rescue True
Matt Riedemanne9a9fbe2017-01-30 22:22:43 -0500685 iniset $TEMPEST_CONFIG compute-feature-enabled swap_volume True
Matt Riedemann92575ba2016-09-21 16:15:31 -0400686 fi
Nels Nelson7b47c472015-01-05 16:36:42 -0600687 fi
688
Dean Troyerdc97cb72015-03-28 08:20:50 -0500689 # ``service_available``
Sean Dague346edcc2015-08-26 09:38:37 -0400690 #
ghanshyamf0dd9992018-11-26 07:38:54 +0000691 # this tempest service list needs to be the services that
692 # tempest own, otherwise we can have an erroneous set of
Sean Dague346edcc2015-08-26 09:38:37 -0400693 # defaults (something defaulting true in Tempest, but not listed here).
ghanshyamf0dd9992018-11-26 07:38:54 +0000694 # services tested by tempest plugins needs to be set on service devstack
695 # plugin side as devstack cannot keep track of all the tempest plugins
696 # services. Refer Bug#1743688 for more details.
697 # 'horizon' is also kept here as no devtack plugin for horizon.
Sean Dague0f765352016-02-18 06:53:08 -0500698 local service
ghanshyamf0dd9992018-11-26 07:38:54 +0000699 local tempest_services="key,glance,nova,neutron,cinder,swift,horizon"
Sean Dague0f765352016-02-18 06:53:08 -0500700 for service in ${tempest_services//,/ }; do
Matthew Treinishb56d81d2013-07-23 17:25:39 -0400701 if is_service_enabled $service ; then
john-griffithdc4dc7f2014-01-22 18:09:32 -0700702 iniset $TEMPEST_CONFIG service_available $service "True"
Matthew Treinishb56d81d2013-07-23 17:25:39 -0400703 else
john-griffithdc4dc7f2014-01-22 18:09:32 -0700704 iniset $TEMPEST_CONFIG service_available $service "False"
Matthew Treinishb56d81d2013-07-23 17:25:39 -0400705 fi
706 done
707
Grzegorz Grasza5f5002a2021-10-26 10:50:37 +0200708 # ``enforce_scope``
709 # If services enable the enforce_scope for their policy
710 # we need to enable the same on Tempest side so that
711 # test can be run with scoped token.
Grzegorz Grasza86155632021-10-18 16:52:06 +0200712 if [[ "$KEYSTONE_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
Grzegorz Grasza5f5002a2021-10-26 10:50:37 +0200713 iniset $TEMPEST_CONFIG enforce_scope keystone true
Grzegorz Grasza5f5002a2021-10-26 10:50:37 +0200714 fi
Ghanshyam Mann9dc2b882021-03-05 09:32:19 -0600715
Ghanshyam Mann857f4992022-10-19 20:15:42 -0500716 if [[ "$NOVA_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
717 iniset $TEMPEST_CONFIG enforce_scope nova true
718 fi
719
Ghanshyam Mann16c2b382022-11-30 14:24:07 -0600720 if [[ "$PLACEMENT_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
721 iniset $TEMPEST_CONFIG enforce_scope placement true
722 fi
723
Grzegorz Grasza86155632021-10-18 16:52:06 +0200724 if [[ "$GLANCE_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
725 iniset $TEMPEST_CONFIG enforce_scope glance true
726 fi
727
728 if [[ "$CINDER_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
729 iniset $TEMPEST_CONFIG enforce_scope cinder true
730 fi
Ghanshyam Mannbd0d0fd2021-03-06 17:23:39 -0600731
Matt Riedemanncf94edc2015-10-28 09:50:01 -0700732 if [ "$VIRT_DRIVER" = "libvirt" ] && [ "$LIBVIRT_TYPE" = "lxc" ]; then
733 # libvirt-lxc does not support boot from volume or attaching volumes
734 # so basically anything with cinder is out of the question.
735 iniset $TEMPEST_CONFIG service_available cinder "False"
736 fi
737
Matthew Treinishe8f3f7a2016-04-11 12:52:39 -0400738 # Run tempest configuration utilities. This must be done last during configuration to
739 # ensure as complete a config as possible already exists
740
741 # NOTE(mtreinish): Respect constraints on tempest verify-config venv
742 local tmp_cfg_file
743 tmp_cfg_file=$(mktemp)
744 cd $TEMPEST_DIR
Claudiu Belu34c16792017-06-12 09:32:21 -0700745
Rodolfo Alonso Hernandez8579f582019-11-04 11:37:54 +0000746 local tmp_u_c_m
747 tmp_u_c_m=$(mktemp -t tempest_u_c_m.XXXXXXXXXX)
Ghanshyam Mann3bdc8f62021-02-09 12:56:34 -0600748 set_tempest_venv_constraints $tmp_u_c_m
June Yib9b6d6b2022-07-02 13:07:43 +0900749 if [[ "$OFFLINE" != "True" ]]; then
750 tox -revenv-tempest --notest
751 fi
Rodolfo Alonso Hernandez8579f582019-11-04 11:37:54 +0000752 tox -evenv-tempest -- pip install -c $tmp_u_c_m -r requirements.txt
753 rm -f $tmp_u_c_m
Matthew Treinishe8f3f7a2016-04-11 12:52:39 -0400754
755 # Auth:
Matthew Treinishe8f3f7a2016-04-11 12:52:39 -0400756 if [[ $TEMPEST_USE_TEST_ACCOUNTS == "True" ]]; then
757 if [[ $TEMPEST_HAS_ADMIN == "True" ]]; then
Soniya Vyas7634c782019-12-26 16:59:56 +0530758 tox -evenv-tempest -- tempest account-generator -c $TEMPEST_CONFIG --os-username $admin_username --os-password "$password" --os-project-name $admin_project_name -r $TEMPEST_CONCURRENCY --with-admin etc/accounts.yaml
Matthew Treinishe8f3f7a2016-04-11 12:52:39 -0400759 else
Soniya Vyas7634c782019-12-26 16:59:56 +0530760 tox -evenv-tempest -- tempest account-generator -c $TEMPEST_CONFIG --os-username $admin_username --os-password "$password" --os-project-name $admin_project_name -r $TEMPEST_CONCURRENCY etc/accounts.yaml
Matthew Treinishe8f3f7a2016-04-11 12:52:39 -0400761 fi
762 iniset $TEMPEST_CONFIG auth use_dynamic_credentials False
763 iniset $TEMPEST_CONFIG auth test_accounts_file "etc/accounts.yaml"
764 elif [[ $TEMPEST_HAS_ADMIN == "False" ]]; then
765 iniset $TEMPEST_CONFIG auth use_dynamic_credentials ${TEMPEST_ALLOW_TENANT_ISOLATION:-False}
766
767 else
768 iniset $TEMPEST_CONFIG auth use_dynamic_credentials ${TEMPEST_ALLOW_TENANT_ISOLATION:-True}
769 fi
770
771 # API Extensions
772 # Run ``verify_tempest_config -ur`` to retrieve enabled extensions on API endpoints
773 # NOTE(mtreinish): This must be done after auth settings are added to the tempest config
774 tox -evenv -- tempest verify-config -uro $tmp_cfg_file
Sean Dague7b229352016-08-09 13:29:11 -0400775
Matthew Treinishe8f3f7a2016-04-11 12:52:39 -0400776 # Neutron API Extensions
Sean Dague894ccc92016-08-08 16:19:05 -0400777
778 # disable metering if we didn't enable the service
Slawek Kaplonskia52041c2022-11-18 11:39:56 +0100779 if ! is_service_enabled q-metering neutron-metering; then
Sean Dague894ccc92016-08-08 16:19:05 -0400780 DISABLE_NETWORK_API_EXTENSIONS+=", metering"
781 fi
782
Dima Kuznetsov787412c2017-08-28 09:09:38 +0300783 # disable l3_agent_scheduler if we didn't enable L3 agent
Slawek Kaplonskia52041c2022-11-18 11:39:56 +0100784 if ! is_service_enabled q-l3 neutron-l3; then
Dima Kuznetsov787412c2017-08-28 09:09:38 +0300785 DISABLE_NETWORK_API_EXTENSIONS+=", l3_agent_scheduler"
786 fi
787
Matthew Treinishe8f3f7a2016-04-11 12:52:39 -0400788 local network_api_extensions=${NETWORK_API_EXTENSIONS:-"all"}
789 if [[ ! -z "$DISABLE_NETWORK_API_EXTENSIONS" ]]; then
790 # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
791 network_api_extensions=${NETWORK_API_EXTENSIONS:-$(iniget $tmp_cfg_file network-feature-enabled api_extensions | tr -d " ")}
792 # Remove disabled extensions
793 network_api_extensions=$(remove_disabled_extensions $network_api_extensions $DISABLE_NETWORK_API_EXTENSIONS)
794 fi
Ghanshyam Mann52c28862019-06-20 07:42:31 +0000795 if [[ -n "$ADDITIONAL_NETWORK_API_EXTENSIONS" ]] && [[ "$network_api_extensions" != "all" ]]; then
796 network_api_extensions+=",$ADDITIONAL_NETWORK_API_EXTENSIONS"
797 fi
Matthew Treinishe8f3f7a2016-04-11 12:52:39 -0400798 iniset $TEMPEST_CONFIG network-feature-enabled api_extensions $network_api_extensions
799 # Swift API Extensions
800 local object_storage_api_extensions=${OBJECT_STORAGE_API_EXTENSIONS:-"all"}
801 if [[ ! -z "$DISABLE_OBJECT_STORAGE_API_EXTENSIONS" ]]; then
802 # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
803 object_storage_api_extensions=${OBJECT_STORAGE_API_EXTENSIONS:-$(iniget $tmp_cfg_file object-storage-feature-enabled discoverable_apis | tr -d " ")}
804 # Remove disabled extensions
805 object_storage_api_extensions=$(remove_disabled_extensions $object_storage_api_extensions $DISABLE_STORAGE_API_EXTENSIONS)
806 fi
807 iniset $TEMPEST_CONFIG object-storage-feature-enabled discoverable_apis $object_storage_api_extensions
808 # Cinder API Extensions
809 local volume_api_extensions=${VOLUME_API_EXTENSIONS:-"all"}
810 if [[ ! -z "$DISABLE_VOLUME_API_EXTENSIONS" ]]; then
811 # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
812 volume_api_extensions=${VOLUME_API_EXTENSIONS:-$(iniget $tmp_cfg_file volume-feature-enabled api_extensions | tr -d " ")}
813 # Remove disabled extensions
814 volume_api_extensions=$(remove_disabled_extensions $volume_api_extensions $DISABLE_VOLUME_API_EXTENSIONS)
815 fi
816 iniset $TEMPEST_CONFIG volume-feature-enabled api_extensions $volume_api_extensions
817
Attila Fazekas2aa35172012-12-05 20:03:40 +0100818 # Restore IFS
819 IFS=$ifs
Sean Dagued0931212012-10-04 16:06:44 -0400820}
821
Sean Dagued0931212012-10-04 16:06:44 -0400822# install_tempest() - Collect source and prepare
Ian Wienandaee18c72014-02-21 15:35:08 +1100823function install_tempest {
Sean Dagued0931212012-10-04 16:06:44 -0400824 git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH
Ghanshyam Mann9a1be772022-12-08 20:24:46 -0600825 # NOTE(gmann): Pinning tox<4.0.0 for stable/zed and lower. Tox 4.0.0
826 # released after zed was released and has some incompatible changes
827 # and it is ok not to fix the issues caused by tox 4.0.0 in stable
828 # beanches jobs. We can continue testing the stable/zed and lower
829 # branches with tox<4.0.0
830 pip_install 'tox!=2.8.0,<4.0.0'
Matthew Treinish83e166b2015-02-18 19:01:20 -0500831 pushd $TEMPEST_DIR
Ghanshyame1c04062020-01-29 15:39:17 -0600832 # NOTE(gmann): checkout the TEMPEST_BRANCH in case TEMPEST_BRANCH
833 # is tag name not master. git_clone would not checkout tag because
834 # TEMPEST_DIR already exist until RECLONE is true.
835 git checkout $TEMPEST_BRANCH
836
Ghanshyam Mann3bdc8f62021-02-09 12:56:34 -0600837 local tmp_u_c_m
838 tmp_u_c_m=$(mktemp -t tempest_u_c_m.XXXXXXXXXX)
839 set_tempest_venv_constraints $tmp_u_c_m
840
Sean Dague583c5202017-03-21 11:15:05 -0400841 tox -r --notest -efull
Matthew Treinish1e31e682016-02-09 23:50:54 -0500842 # NOTE(mtreinish) Respect constraints in the tempest full venv, things that
843 # are using a tox job other than full will not be respecting constraints but
844 # running pip install -U on tempest requirements
Ghanshyam Mann3bdc8f62021-02-09 12:56:34 -0600845 $TEMPEST_DIR/.tox/tempest/bin/pip install -c $tmp_u_c_m -r requirements.txt
Matthew Treinish440464c2016-05-04 11:55:12 -0400846 PROJECT_VENV["tempest"]=${TEMPEST_DIR}/.tox/tempest
Ghanshyam Mann3bdc8f62021-02-09 12:56:34 -0600847 rm -f $tmp_u_c_m
Matthew Treinish7e603d12016-06-01 18:16:14 -0400848 popd
849}
850
851# install_tempest_plugins() - Install any specified plugins into the tempest venv
852function install_tempest_plugins {
853 pushd $TEMPEST_DIR
Matthew Treinish440464c2016-05-04 11:55:12 -0400854 if [[ $TEMPEST_PLUGINS != 0 ]] ; then
Rodolfo Alonso Hernandez8579f582019-11-04 11:37:54 +0000855 local tmp_u_c_m
856 tmp_u_c_m=$(mktemp -t tempest_u_c_m.XXXXXXXXXX)
Ghanshyam Mann3bdc8f62021-02-09 12:56:34 -0600857 set_tempest_venv_constraints $tmp_u_c_m
Rodolfo Alonso Hernandez8579f582019-11-04 11:37:54 +0000858 tox -evenv-tempest -- pip install -c $tmp_u_c_m $TEMPEST_PLUGINS
859 rm -f $tmp_u_c_m
Matthew Treinishb6558672016-05-20 17:30:17 -0400860 echo "Checking installed Tempest plugins:"
861 tox -evenv-tempest -- tempest list-plugins
Matthew Treinishb31640a2016-05-02 16:33:29 -0400862 fi
Matthew Treinish83e166b2015-02-18 19:01:20 -0500863 popd
Sean Dagued0931212012-10-04 16:06:44 -0400864}
865
Sean Dagued0931212012-10-04 16:06:44 -0400866# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100867$_XTRACE_TEMPEST
Sean Dague584d90e2013-03-29 14:34:53 -0400868
Adam Spiers6a5aa7c2013-10-24 11:27:02 +0100869# Tell emacs to use shell-script-mode
870## Local variables:
871## mode: shell-script
872## End: