blob: c28af8604b59ecf020b8280bdc0c811abb01559d [file] [log] [blame]
Sean Dagued0931212012-10-04 16:06:44 -04001# lib/tempest
2
3# Dependencies:
4# ``functions`` file
Attila Fazekas2aa35172012-12-05 20:03:40 +01005# ``lib/nova`` service is runing
Sean Dagued0931212012-10-04 16:06:44 -04006# <list other global vars that are assumed to be defined>
Attila Fazekas65c08462012-12-07 14:20:51 +01007# - ``DEST``
8# - ``ADMIN_PASSWORD``
9# - ``DEFAULT_IMAGE_NAME``
10# - ``S3_SERVICE_PORT``
11# - ``SERVICE_HOST``
12# - ``BASE_SQL_CONN`` ``lib/database`` declares
Attila Fazekas2aa35172012-12-05 20:03:40 +010013# Optional Dependencies:
Attila Fazekas65c08462012-12-07 14:20:51 +010014# IDENTITY_USE_SSL, IDENTITY_HOST, IDENTITY_PORT, IDENTITY_PATH
Attila Fazekas2aa35172012-12-05 20:03:40 +010015# ALT_* (similar vars exists in keystone_data.sh)
Attila Fazekas65c08462012-12-07 14:20:51 +010016# ``OS_USERNAME``
17# ``IMAGE_PORT``, ``IMAGE_HOST``
18# ``LIVE_MIGRATION_AVAILABLE``
19# ``USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION``
20# ``DEFAULT_INSTANCE_TYPE``
21# ``DEFAULT_INSTANCE_USER``
Sean Dagued0931212012-10-04 16:06:44 -040022# ``stack.sh`` calls the entry points in this order:
23#
Attila Fazekas2aa35172012-12-05 20:03:40 +010024# install_tempest
25# configure_tempest
26# init_tempest
27## start_tempest
28## stop_tempest
29## cleanup_tempest
Sean Dagued0931212012-10-04 16:06:44 -040030
31# Save trace setting
32XTRACE=$(set +o | grep xtrace)
33set +o xtrace
34
Sean Dagued0931212012-10-04 16:06:44 -040035# Defaults
36# --------
37
38# <define global variables here that belong to this project>
39
40# Set up default directories
Attila Fazekas2aa35172012-12-05 20:03:40 +010041NOVA_SOURCE_DIR=$DEST/nova
Sean Dagued0931212012-10-04 16:06:44 -040042TEMPEST_DIR=$DEST/tempest
Attila Fazekas2aa35172012-12-05 20:03:40 +010043TEMPEST_CONF_DIR=$TEMPEST_DIR/etc
44TEMPEST_CONF=$TEMPEST_CONF_DIR/tempest.conf
45
46BUILD_INTERVAL=3
47BUILD_TIMEOUT=400
Sean Dagued0931212012-10-04 16:06:44 -040048
49# Entry Points
50# ------------
51
52
53# configure_tempest() - Set config files, create data dirs, etc
54function configure_tempest() {
Attila Fazekas65c08462012-12-07 14:20:51 +010055 local image_lines
56 local images
57 local num_images
58 local image_uuid
59 local image_uuid_alt
Attila Fazekas2aa35172012-12-05 20:03:40 +010060 local errexit
Attila Fazekas65c08462012-12-07 14:20:51 +010061 local password
62 local line
63 local flavors
64 local flavors_ref
65 local flavor_lines
Maru Newbya5c774e2012-12-10 10:40:01 +000066 local public_network_id
67 local tenant_networks_reachable
Attila Fazekas2aa35172012-12-05 20:03:40 +010068
69 #TODO(afazekas):
Sean Dagued0931212012-10-04 16:06:44 -040070 # sudo python setup.py deploy
Attila Fazekas2aa35172012-12-05 20:03:40 +010071
72 # This function exits on an error so that errors don't compound and you see
73 # only the first error that occured.
74 errexit=$(set +o | grep errexit)
75 set -o errexit
76
77 #Save IFS
78 ifs=$IFS
79
80 # Glance should already contain images to be used in tempest
81 # testing. Here we simply look for images stored in Glance
82 # and set the appropriate variables for use in the tempest config
83 # We ignore ramdisk and kernel images, look for the default image
Attila Fazekas65c08462012-12-07 14:20:51 +010084 # ``DEFAULT_IMAGE_NAME``. If not found, we set the ``image_uuid`` to the
85 # first image returned and set ``image_uuid_alt`` to the second,
Attila Fazekas2aa35172012-12-05 20:03:40 +010086 # if there is more than one returned...
87 # ... Also ensure we only take active images, so we don't get snapshots in process
Cody A.W. Somervillec24e23b2012-12-21 02:10:45 -050088 declare -a images
89
90 while read -r IMAGE_NAME IMAGE_UUID; do
91 if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then
92 image_uuid="$IMAGE_UUID"
93 image_uuid_alt="$IMAGE_UUID"
Attila Fazekas2aa35172012-12-05 20:03:40 +010094 fi
Cody A.W. Somervillec24e23b2012-12-21 02:10:45 -050095 images+=($IMAGE_UUID)
96 done < <(glance image-list --status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }')
97
98 case "${#images[*]}" in
99 0)
100 echo "Found no valid images to use!"
101 exit 1
102 ;;
103 1)
104 if [ -z "$image_uuid" ]; then
105 image_uuid=${images[0]}
106 image_uuid_alt=${images[0]}
107 fi
108 ;;
109 *)
110 if [ -z "$image_uuid" ]; then
111 image_uuid=${images[0]}
112 image_uuid_alt=${images[1]}
113 fi
114 ;;
115 esac
Attila Fazekas2aa35172012-12-05 20:03:40 +0100116
117 # Create tempest.conf from tempest.conf.sample
118 # copy every time, because the image UUIDS are going to change
119 cp $TEMPEST_CONF.sample $TEMPEST_CONF
120
121 IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
122 IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
123 IDENTITY_PORT=${IDENTITY_PORT:-5000}
124 # TODO(jaypipes): This is dumb and needs to be removed
125 # from the Tempest configuration file entirely...
126 IDENTITY_PATH=${IDENTITY_PATH:-tokens}
127
Attila Fazekas65c08462012-12-07 14:20:51 +0100128 password=${ADMIN_PASSWORD:-secrete}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100129
130 # See files/keystone_data.sh where alt_demo user
131 # and tenant are set up...
132 ALT_USERNAME=${ALT_USERNAME:-alt_demo}
133 ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo}
134
135 # Check Nova for existing flavors and, if set, look for the
Attila Fazekas65c08462012-12-07 14:20:51 +0100136 # ``DEFAULT_INSTANCE_TYPE`` and use that. Otherwise, just use the first flavor.
137 flavor_lines=`nova flavor-list`
138 IFS=$'\r\n'
139 flavors=""
140 for line in $flavor_lines; do
Attila Fazekas2aa35172012-12-05 20:03:40 +0100141 if [ -z $DEFAULT_INSTANCE_TYPE ]; then
Attila Fazekas65c08462012-12-07 14:20:51 +0100142 flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100143 else
Attila Fazekas65c08462012-12-07 14:20:51 +0100144 flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | grep "$DEFAULT_INSTANCE_TYPE" | cut -d' ' -f2`"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100145 fi
146 done
147
148 IFS=" "
Attila Fazekas65c08462012-12-07 14:20:51 +0100149 flavors=($flavors)
150 num_flavors=${#flavors[*]}
151 echo "Found $num_flavors flavors"
152 if [[ $num_flavors -eq 0 ]]; then
Attila Fazekas2aa35172012-12-05 20:03:40 +0100153 echo "Found no valid flavors to use!"
154 exit 1
155 fi
Attila Fazekas65c08462012-12-07 14:20:51 +0100156 flavor_ref=${flavors[0]}
157 flavor_ref_alt=$flavor_ref
158 if [[ $num_flavors -gt 1 ]]; then
159 flavor_ref_alt=${flavors[1]}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100160 fi
161
Maru Newbya5c774e2012-12-10 10:40:01 +0000162 if [ "$Q_USE_NAMESPACE" != "False" ]; then
163 tenant_networks_reachable=false
164 else
165 tenant_networks_reachable=true
166 fi
167
168 if is_service_enabled q-l3; then
169 public_network_id=$(quantum net-list | grep $PUBLIC_NETWORK_NAME | \
170 awk '{print $2}')
171 fi
172
Attila Fazekas2aa35172012-12-05 20:03:40 +0100173 # Timeouts
174 iniset $TEMPEST_CONF compute build_timeout $BUILD_TIMEOUT
175 iniset $TEMPEST_CONF volume build_timeout $BUILD_TIMEOUT
176 iniset $TEMPEST_CONF boto build_timeout $BUILD_TIMEOUT
177 iniset $TEMPEST_CONF compute build_interval $BUILD_INTERVAL
178 iniset $TEMPEST_CONF volume build_interval $BUILD_INTERVAL
179 iniset $TEMPEST_CONF boto build_interval $BUILD_INTERVAL
180 iniset $TEMPEST_CONF boto http_socket_timeout 5
181
182 iniset $TEMPEST_CONF identity use_ssl $IDENTITY_USE_SSL
183 iniset $TEMPEST_CONF identity host $IDENTITY_HOST
184 iniset $TEMPEST_CONF identity port $IDENTITY_PORT
185 iniset $TEMPEST_CONF identity path $IDENTITY_PATH
186
Attila Fazekas65c08462012-12-07 14:20:51 +0100187 iniset $TEMPEST_CONF compute password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100188 iniset $TEMPEST_CONF compute alt_username $ALT_USERNAME
Attila Fazekas65c08462012-12-07 14:20:51 +0100189 iniset $TEMPEST_CONF compute alt_password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100190 iniset $TEMPEST_CONF compute alt_tenant_name $ALT_TENANT_NAME
191 iniset $TEMPEST_CONF compute resize_available False
192 iniset $TEMPEST_CONF compute change_password_available False
193 iniset $TEMPEST_CONF compute compute_log_level ERROR
194 #Skip until #1074039 is fixed
195 iniset $TEMPEST_CONF compute run_ssh False
196 iniset $TEMPEST_CONF compute ssh_user ${DEFAULT_INSTANCE_USER:-$OS_USERNAME}
197 iniset $TEMPEST_CONF compute network_for_ssh private
198 iniset $TEMPEST_CONF compute ip_version_for_ssh 4
199 iniset $TEMPEST_CONF compute ssh_timeout 4
Attila Fazekas65c08462012-12-07 14:20:51 +0100200 iniset $TEMPEST_CONF compute image_ref $image_uuid
201 iniset $TEMPEST_CONF compute image_ref_alt $image_uuid_alt
202 iniset $TEMPEST_CONF compute flavor_ref $flavor_ref
203 iniset $TEMPEST_CONF compute flavor_ref_alt $flavor_ref_alt
Attila Fazekas2aa35172012-12-05 20:03:40 +0100204 iniset $TEMPEST_CONF compute source_dir $NOVA_SOURCE_DIR
205 iniset $TEMPEST_CONF compute live_migration_available ${LIVE_MIGRATION_AVAILABLE:-False}
206 iniset $TEMPEST_CONF compute use_block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
207 # Inherited behavior, might be wrong
208 iniset $TEMPEST_CONF compute bin_dir $NOVA_BIN_DIR
209 # TODO(jaypipes): Create the key file here... right now, no whitebox
210 # tests actually use a key.
211 iniset $TEMPEST_CONF compute path_to_private_key $TEMPEST_DIR/id_rsa
212 iniset $TEMPEST_CONF compute db_uri $BASE_SQL_CONN/nova
213
214 # image
215 iniset $TEMPEST_CONF image host ${IMAGE_HOST:-127.0.0.1}
216 iniset $TEMPEST_CONF image port ${IMAGE_PORT:-9292}
Attila Fazekas65c08462012-12-07 14:20:51 +0100217 iniset $TEMPEST_CONF image password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100218
219 # identity-admin
Attila Fazekas65c08462012-12-07 14:20:51 +0100220 iniset $TEMPEST_CONF "identity-admin" password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100221
222 # compute admin
Attila Fazekas65c08462012-12-07 14:20:51 +0100223 iniset $TEMPEST_CONF "compute-admin" password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100224
Maru Newbya5c774e2012-12-10 10:40:01 +0000225 # network admin
226 iniset $TEMPEST_CONF "network-admin" password "$password"
227
Attila Fazekas2aa35172012-12-05 20:03:40 +0100228 # network
229 iniset $TEMPEST_CONF network api_version 2.0
Maru Newbya5c774e2012-12-10 10:40:01 +0000230 iniset $TEMPEST_CONF network password "$password"
231 iniset $TEMPEST_CONF network tenant_networks_reachable "$tenant_networks_reachable"
232 iniset $TEMPEST_CONF network public_network_id "$public_network_id"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100233
234 #boto
235 iniset $TEMPEST_CONF boto ec2_url "http://$SERVICE_HOST:8773/services/Cloud"
236 iniset $TEMPEST_CONF boto s3_url "http://$SERVICE_HOST:${S3_SERVICE_PORT:-3333}"
237
238 echo "Created tempest configuration file:"
239 cat $TEMPEST_CONF
240
241 # Restore IFS
242 IFS=$ifs
243 #Restore errexit
244 $errexit
Sean Dagued0931212012-10-04 16:06:44 -0400245}
246
247
248# install_tempest() - Collect source and prepare
249function install_tempest() {
250 git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH
Jeremy Stanley9a352da2012-11-28 17:22:39 +0000251
252 # Tempest doesn't satisfy its dependencies on its own, so
253 # install them here instead.
jiajun xud75bc1f2012-12-04 08:51:35 +0800254 pip_install -r $TEMPEST_DIR/tools/pip-requires
Sean Dagued0931212012-10-04 16:06:44 -0400255}
256
Sean Dagued0931212012-10-04 16:06:44 -0400257# Restore xtrace
258$XTRACE