blob: 906ca6ab8f1d1c7ee442c97ef1c76923b2d193ee [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 Fazekas65c08462012-12-07 14:20:51 +01008# - ``DEST``
9# - ``ADMIN_PASSWORD``
10# - ``DEFAULT_IMAGE_NAME``
11# - ``S3_SERVICE_PORT``
12# - ``SERVICE_HOST``
13# - ``BASE_SQL_CONN`` ``lib/database`` declares
Attila Fazekas2aa35172012-12-05 20:03:40 +010014# Optional Dependencies:
Attila Fazekas65c08462012-12-07 14:20:51 +010015# IDENTITY_USE_SSL, IDENTITY_HOST, IDENTITY_PORT, IDENTITY_PATH
Attila Fazekas2aa35172012-12-05 20:03:40 +010016# ALT_* (similar vars exists in keystone_data.sh)
Attila Fazekas65c08462012-12-07 14:20:51 +010017# ``OS_USERNAME``
18# ``IMAGE_PORT``, ``IMAGE_HOST``
19# ``LIVE_MIGRATION_AVAILABLE``
20# ``USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION``
21# ``DEFAULT_INSTANCE_TYPE``
22# ``DEFAULT_INSTANCE_USER``
Sean Dagued0931212012-10-04 16:06:44 -040023# ``stack.sh`` calls the entry points in this order:
24#
Attila Fazekas2aa35172012-12-05 20:03:40 +010025# install_tempest
26# configure_tempest
Sean Dagued0931212012-10-04 16:06:44 -040027
28# Save trace setting
29XTRACE=$(set +o | grep xtrace)
30set +o xtrace
31
Dean Troyer6d04fd72012-12-21 11:03:37 -060032
Sean Dagued0931212012-10-04 16:06:44 -040033# Defaults
34# --------
35
Sean Dagued0931212012-10-04 16:06:44 -040036# Set up default directories
37TEMPEST_DIR=$DEST/tempest
Attila Fazekas2aa35172012-12-05 20:03:40 +010038TEMPEST_CONF_DIR=$TEMPEST_DIR/etc
39TEMPEST_CONF=$TEMPEST_CONF_DIR/tempest.conf
40
Dean Troyer6d04fd72012-12-21 11:03:37 -060041NOVA_SOURCE_DIR=$DEST/nova
42
Attila Fazekas2aa35172012-12-05 20:03:40 +010043BUILD_INTERVAL=3
44BUILD_TIMEOUT=400
Sean Dagued0931212012-10-04 16:06:44 -040045
Dean Troyer6d04fd72012-12-21 11:03:37 -060046
Sean Dagued0931212012-10-04 16:06:44 -040047# Entry Points
48# ------------
49
Sean Dagued0931212012-10-04 16:06:44 -040050# configure_tempest() - Set config files, create data dirs, etc
51function configure_tempest() {
Attila Fazekas65c08462012-12-07 14:20:51 +010052 local image_lines
53 local images
54 local num_images
55 local image_uuid
56 local image_uuid_alt
Attila Fazekas2aa35172012-12-05 20:03:40 +010057 local errexit
Attila Fazekas65c08462012-12-07 14:20:51 +010058 local password
59 local line
60 local flavors
61 local flavors_ref
62 local flavor_lines
Maru Newbya5c774e2012-12-10 10:40:01 +000063 local public_network_id
64 local tenant_networks_reachable
Attila Fazekas2aa35172012-12-05 20:03:40 +010065
Dean Troyer6d04fd72012-12-21 11:03:37 -060066 # TODO(afazekas):
Sean Dagued0931212012-10-04 16:06:44 -040067 # sudo python setup.py deploy
Attila Fazekas2aa35172012-12-05 20:03:40 +010068
69 # This function exits on an error so that errors don't compound and you see
70 # only the first error that occured.
71 errexit=$(set +o | grep errexit)
72 set -o errexit
73
Dean Troyer6d04fd72012-12-21 11:03:37 -060074 # Save IFS
Attila Fazekas2aa35172012-12-05 20:03:40 +010075 ifs=$IFS
76
77 # Glance should already contain images to be used in tempest
78 # testing. Here we simply look for images stored in Glance
79 # and set the appropriate variables for use in the tempest config
80 # We ignore ramdisk and kernel images, look for the default image
Attila Fazekas65c08462012-12-07 14:20:51 +010081 # ``DEFAULT_IMAGE_NAME``. If not found, we set the ``image_uuid`` to the
82 # first image returned and set ``image_uuid_alt`` to the second,
Attila Fazekas2aa35172012-12-05 20:03:40 +010083 # if there is more than one returned...
84 # ... Also ensure we only take active images, so we don't get snapshots in process
Cody A.W. Somervillec24e23b2012-12-21 02:10:45 -050085 declare -a images
86
87 while read -r IMAGE_NAME IMAGE_UUID; do
88 if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then
89 image_uuid="$IMAGE_UUID"
90 image_uuid_alt="$IMAGE_UUID"
Attila Fazekas2aa35172012-12-05 20:03:40 +010091 fi
Cody A.W. Somervillec24e23b2012-12-21 02:10:45 -050092 images+=($IMAGE_UUID)
93 done < <(glance image-list --status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }')
94
95 case "${#images[*]}" in
96 0)
97 echo "Found no valid images to use!"
98 exit 1
99 ;;
100 1)
101 if [ -z "$image_uuid" ]; then
102 image_uuid=${images[0]}
103 image_uuid_alt=${images[0]}
104 fi
105 ;;
106 *)
107 if [ -z "$image_uuid" ]; then
108 image_uuid=${images[0]}
109 image_uuid_alt=${images[1]}
110 fi
111 ;;
112 esac
Attila Fazekas2aa35172012-12-05 20:03:40 +0100113
114 # Create tempest.conf from tempest.conf.sample
115 # copy every time, because the image UUIDS are going to change
116 cp $TEMPEST_CONF.sample $TEMPEST_CONF
117
118 IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
119 IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
120 IDENTITY_PORT=${IDENTITY_PORT:-5000}
121 # TODO(jaypipes): This is dumb and needs to be removed
122 # from the Tempest configuration file entirely...
123 IDENTITY_PATH=${IDENTITY_PATH:-tokens}
124
Attila Fazekas65c08462012-12-07 14:20:51 +0100125 password=${ADMIN_PASSWORD:-secrete}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100126
127 # See files/keystone_data.sh where alt_demo user
128 # and tenant are set up...
129 ALT_USERNAME=${ALT_USERNAME:-alt_demo}
130 ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo}
131
Attila Fazekas7bf1dd32013-01-12 17:31:26 +0100132 # If the ``DEFAULT_INSTANCE_TYPE`` not declared, use the new behavior
133 # Tempest creates instane types for himself
134 if [[ -z "$DEFAULT_INSTANCE_TYPE" ]]; then
135 nova flavor-create m1.pico 42 32 0 1
136 flavor_ref=42
137 nova flavor-create m1.nano 84 64 0 1
138 flavor_ref_alt=84
139 else
140 # Check Nova for existing flavors and, if set, look for the
141 # ``DEFAULT_INSTANCE_TYPE`` and use that.
142 flavor_lines=`nova flavor-list`
143 IFS=$'\r\n'
144 flavors=""
Dean Troyerceaa38b2012-12-12 17:09:57 -0600145 for line in $flavor_lines; do
146 f=$(echo $line | awk "/ $DEFAULT_INSTANCE_TYPE / { print \$2 }")
147 flavors="$flavors $f"
148 done
Attila Fazekas2aa35172012-12-05 20:03:40 +0100149
Attila Fazekas7bf1dd32013-01-12 17:31:26 +0100150 for line in $flavor_lines; do
151 flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`"
152 done
153
154 IFS=" "
155 flavors=($flavors)
156 num_flavors=${#flavors[*]}
157 echo "Found $num_flavors flavors"
158 if [[ $num_flavors -eq 0 ]]; then
159 echo "Found no valid flavors to use!"
160 exit 1
161 fi
162 flavor_ref=${flavors[0]}
163 flavor_ref_alt=$flavor_ref
164 if [[ $num_flavors -gt 1 ]]; then
165 flavor_ref_alt=${flavors[1]}
166 fi
Attila Fazekas2aa35172012-12-05 20:03:40 +0100167 fi
168
Maru Newbya5c774e2012-12-10 10:40:01 +0000169 if [ "$Q_USE_NAMESPACE" != "False" ]; then
170 tenant_networks_reachable=false
171 else
172 tenant_networks_reachable=true
173 fi
174
175 if is_service_enabled q-l3; then
176 public_network_id=$(quantum net-list | grep $PUBLIC_NETWORK_NAME | \
177 awk '{print $2}')
178 fi
179
Attila Fazekas2aa35172012-12-05 20:03:40 +0100180 # Timeouts
181 iniset $TEMPEST_CONF compute build_timeout $BUILD_TIMEOUT
182 iniset $TEMPEST_CONF volume build_timeout $BUILD_TIMEOUT
183 iniset $TEMPEST_CONF boto build_timeout $BUILD_TIMEOUT
184 iniset $TEMPEST_CONF compute build_interval $BUILD_INTERVAL
185 iniset $TEMPEST_CONF volume build_interval $BUILD_INTERVAL
186 iniset $TEMPEST_CONF boto build_interval $BUILD_INTERVAL
187 iniset $TEMPEST_CONF boto http_socket_timeout 5
188
189 iniset $TEMPEST_CONF identity use_ssl $IDENTITY_USE_SSL
190 iniset $TEMPEST_CONF identity host $IDENTITY_HOST
191 iniset $TEMPEST_CONF identity port $IDENTITY_PORT
192 iniset $TEMPEST_CONF identity path $IDENTITY_PATH
193
Attila Fazekas65c08462012-12-07 14:20:51 +0100194 iniset $TEMPEST_CONF compute password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100195 iniset $TEMPEST_CONF compute alt_username $ALT_USERNAME
Attila Fazekas65c08462012-12-07 14:20:51 +0100196 iniset $TEMPEST_CONF compute alt_password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100197 iniset $TEMPEST_CONF compute alt_tenant_name $ALT_TENANT_NAME
198 iniset $TEMPEST_CONF compute resize_available False
199 iniset $TEMPEST_CONF compute change_password_available False
200 iniset $TEMPEST_CONF compute compute_log_level ERROR
Nachi Ueno06fac372012-12-26 14:09:43 -0800201 # Note(nati) current tempest don't create network for each tenant
202 # so reuse same tenant for now
203 if is_service_enabled quantum; then
204 TEMPEST_ALLOW_TENANT_ISOLATION=${TEMPEST_ALLOW_TENANT_ISOLATION:-False}
205 fi
206 iniset $TEMPEST_CONF compute allow_tenant_isolation ${TEMPEST_ALLOW_TENANT_ISOLATION:-True}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100207 #Skip until #1074039 is fixed
208 iniset $TEMPEST_CONF compute run_ssh False
209 iniset $TEMPEST_CONF compute ssh_user ${DEFAULT_INSTANCE_USER:-$OS_USERNAME}
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900210 iniset $TEMPEST_CONF compute network_for_ssh $PRIVATE_NETWORK_NAME
Attila Fazekas2aa35172012-12-05 20:03:40 +0100211 iniset $TEMPEST_CONF compute ip_version_for_ssh 4
212 iniset $TEMPEST_CONF compute ssh_timeout 4
Attila Fazekas65c08462012-12-07 14:20:51 +0100213 iniset $TEMPEST_CONF compute image_ref $image_uuid
214 iniset $TEMPEST_CONF compute image_ref_alt $image_uuid_alt
215 iniset $TEMPEST_CONF compute flavor_ref $flavor_ref
216 iniset $TEMPEST_CONF compute flavor_ref_alt $flavor_ref_alt
Attila Fazekas2aa35172012-12-05 20:03:40 +0100217 iniset $TEMPEST_CONF compute source_dir $NOVA_SOURCE_DIR
218 iniset $TEMPEST_CONF compute live_migration_available ${LIVE_MIGRATION_AVAILABLE:-False}
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900219 iniset $TEMPEST_CONF compute use_block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100220 # Inherited behavior, might be wrong
221 iniset $TEMPEST_CONF compute bin_dir $NOVA_BIN_DIR
222 # TODO(jaypipes): Create the key file here... right now, no whitebox
223 # tests actually use a key.
224 iniset $TEMPEST_CONF compute path_to_private_key $TEMPEST_DIR/id_rsa
225 iniset $TEMPEST_CONF compute db_uri $BASE_SQL_CONN/nova
226
227 # image
228 iniset $TEMPEST_CONF image host ${IMAGE_HOST:-127.0.0.1}
229 iniset $TEMPEST_CONF image port ${IMAGE_PORT:-9292}
Attila Fazekas65c08462012-12-07 14:20:51 +0100230 iniset $TEMPEST_CONF image password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100231
232 # identity-admin
Attila Fazekas65c08462012-12-07 14:20:51 +0100233 iniset $TEMPEST_CONF "identity-admin" password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100234
235 # compute admin
Attila Fazekas65c08462012-12-07 14:20:51 +0100236 iniset $TEMPEST_CONF "compute-admin" password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100237
Maru Newbya5c774e2012-12-10 10:40:01 +0000238 # network admin
239 iniset $TEMPEST_CONF "network-admin" password "$password"
240
Attila Fazekas2aa35172012-12-05 20:03:40 +0100241 # network
242 iniset $TEMPEST_CONF network api_version 2.0
Maru Newbya5c774e2012-12-10 10:40:01 +0000243 iniset $TEMPEST_CONF network password "$password"
244 iniset $TEMPEST_CONF network tenant_networks_reachable "$tenant_networks_reachable"
245 iniset $TEMPEST_CONF network public_network_id "$public_network_id"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100246
247 #boto
248 iniset $TEMPEST_CONF boto ec2_url "http://$SERVICE_HOST:8773/services/Cloud"
249 iniset $TEMPEST_CONF boto s3_url "http://$SERVICE_HOST:${S3_SERVICE_PORT:-3333}"
250
251 echo "Created tempest configuration file:"
252 cat $TEMPEST_CONF
253
254 # Restore IFS
255 IFS=$ifs
256 #Restore errexit
257 $errexit
Sean Dagued0931212012-10-04 16:06:44 -0400258}
259
Sean Dagued0931212012-10-04 16:06:44 -0400260# install_tempest() - Collect source and prepare
261function install_tempest() {
262 git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH
Jeremy Stanley9a352da2012-11-28 17:22:39 +0000263
264 # Tempest doesn't satisfy its dependencies on its own, so
265 # install them here instead.
jiajun xud75bc1f2012-12-04 08:51:35 +0800266 pip_install -r $TEMPEST_DIR/tools/pip-requires
Sean Dagued0931212012-10-04 16:06:44 -0400267}
268
Sean Dagued0931212012-10-04 16:06:44 -0400269# Restore xtrace
270$XTRACE