blob: 7fa15df068cacf6baf52de211d0f4e86aba742d7 [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
Attila Fazekas2aa35172012-12-05 20:03:40 +010066
67 #TODO(afazekas):
Sean Dagued0931212012-10-04 16:06:44 -040068 # sudo python setup.py deploy
Attila Fazekas2aa35172012-12-05 20:03:40 +010069
70 # This function exits on an error so that errors don't compound and you see
71 # only the first error that occured.
72 errexit=$(set +o | grep errexit)
73 set -o errexit
74
75 #Save IFS
76 ifs=$IFS
77
78 # Glance should already contain images to be used in tempest
79 # testing. Here we simply look for images stored in Glance
80 # and set the appropriate variables for use in the tempest config
81 # We ignore ramdisk and kernel images, look for the default image
Attila Fazekas65c08462012-12-07 14:20:51 +010082 # ``DEFAULT_IMAGE_NAME``. If not found, we set the ``image_uuid`` to the
83 # first image returned and set ``image_uuid_alt`` to the second,
Attila Fazekas2aa35172012-12-05 20:03:40 +010084 # if there is more than one returned...
85 # ... Also ensure we only take active images, so we don't get snapshots in process
Attila Fazekas65c08462012-12-07 14:20:51 +010086 image_lines=`glance image-list`
Attila Fazekas2aa35172012-12-05 20:03:40 +010087 IFS=$'\n\r'
Attila Fazekas65c08462012-12-07 14:20:51 +010088 images=""
89 for line in $image_lines; do
Attila Fazekas2aa35172012-12-05 20:03:40 +010090 if [ -z $DEFAULT_IMAGE_NAME ]; then
Attila Fazekas65c08462012-12-07 14:20:51 +010091 images="$images `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | cut -d' ' -f2`"
Attila Fazekas2aa35172012-12-05 20:03:40 +010092 else
Attila Fazekas65c08462012-12-07 14:20:51 +010093 images="$images `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | grep "$DEFAULT_IMAGE_NAME" | cut -d' ' -f2`"
Attila Fazekas2aa35172012-12-05 20:03:40 +010094 fi
95 done
96 # Create array of image UUIDs...
97 IFS=" "
Attila Fazekas65c08462012-12-07 14:20:51 +010098 images=($images)
99 num_images=${#images[*]}
100 echo "Found $num_images images"
101 if [[ $num_images -eq 0 ]]; then
Attila Fazekas2aa35172012-12-05 20:03:40 +0100102 echo "Found no valid images to use!"
103 exit 1
104 fi
Attila Fazekas65c08462012-12-07 14:20:51 +0100105 image_uuid=${images[0]}
106 image_uuid_alt=$image_uuid
107 if [[ $num_images -gt 1 ]]; then
108 image_uuid_alt=${images[1]}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100109 fi
110
111 # Create tempest.conf from tempest.conf.sample
112 # copy every time, because the image UUIDS are going to change
113 cp $TEMPEST_CONF.sample $TEMPEST_CONF
114
115 IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
116 IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
117 IDENTITY_PORT=${IDENTITY_PORT:-5000}
118 # TODO(jaypipes): This is dumb and needs to be removed
119 # from the Tempest configuration file entirely...
120 IDENTITY_PATH=${IDENTITY_PATH:-tokens}
121
Attila Fazekas65c08462012-12-07 14:20:51 +0100122 password=${ADMIN_PASSWORD:-secrete}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100123
124 # See files/keystone_data.sh where alt_demo user
125 # and tenant are set up...
126 ALT_USERNAME=${ALT_USERNAME:-alt_demo}
127 ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo}
128
129 # Check Nova for existing flavors and, if set, look for the
Attila Fazekas65c08462012-12-07 14:20:51 +0100130 # ``DEFAULT_INSTANCE_TYPE`` and use that. Otherwise, just use the first flavor.
131 flavor_lines=`nova flavor-list`
132 IFS=$'\r\n'
133 flavors=""
134 for line in $flavor_lines; do
Attila Fazekas2aa35172012-12-05 20:03:40 +0100135 if [ -z $DEFAULT_INSTANCE_TYPE ]; then
Attila Fazekas65c08462012-12-07 14:20:51 +0100136 flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100137 else
Attila Fazekas65c08462012-12-07 14:20:51 +0100138 flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | grep "$DEFAULT_INSTANCE_TYPE" | cut -d' ' -f2`"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100139 fi
140 done
141
142 IFS=" "
Attila Fazekas65c08462012-12-07 14:20:51 +0100143 flavors=($flavors)
144 num_flavors=${#flavors[*]}
145 echo "Found $num_flavors flavors"
146 if [[ $num_flavors -eq 0 ]]; then
Attila Fazekas2aa35172012-12-05 20:03:40 +0100147 echo "Found no valid flavors to use!"
148 exit 1
149 fi
Attila Fazekas65c08462012-12-07 14:20:51 +0100150 flavor_ref=${flavors[0]}
151 flavor_ref_alt=$flavor_ref
152 if [[ $num_flavors -gt 1 ]]; then
153 flavor_ref_alt=${flavors[1]}
Attila Fazekas2aa35172012-12-05 20:03:40 +0100154 fi
155
156 # Timeouts
157 iniset $TEMPEST_CONF compute build_timeout $BUILD_TIMEOUT
158 iniset $TEMPEST_CONF volume build_timeout $BUILD_TIMEOUT
159 iniset $TEMPEST_CONF boto build_timeout $BUILD_TIMEOUT
160 iniset $TEMPEST_CONF compute build_interval $BUILD_INTERVAL
161 iniset $TEMPEST_CONF volume build_interval $BUILD_INTERVAL
162 iniset $TEMPEST_CONF boto build_interval $BUILD_INTERVAL
163 iniset $TEMPEST_CONF boto http_socket_timeout 5
164
165 iniset $TEMPEST_CONF identity use_ssl $IDENTITY_USE_SSL
166 iniset $TEMPEST_CONF identity host $IDENTITY_HOST
167 iniset $TEMPEST_CONF identity port $IDENTITY_PORT
168 iniset $TEMPEST_CONF identity path $IDENTITY_PATH
169
Attila Fazekas65c08462012-12-07 14:20:51 +0100170 iniset $TEMPEST_CONF compute password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100171 iniset $TEMPEST_CONF compute alt_username $ALT_USERNAME
Attila Fazekas65c08462012-12-07 14:20:51 +0100172 iniset $TEMPEST_CONF compute alt_password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100173 iniset $TEMPEST_CONF compute alt_tenant_name $ALT_TENANT_NAME
174 iniset $TEMPEST_CONF compute resize_available False
175 iniset $TEMPEST_CONF compute change_password_available False
176 iniset $TEMPEST_CONF compute compute_log_level ERROR
177 #Skip until #1074039 is fixed
178 iniset $TEMPEST_CONF compute run_ssh False
179 iniset $TEMPEST_CONF compute ssh_user ${DEFAULT_INSTANCE_USER:-$OS_USERNAME}
180 iniset $TEMPEST_CONF compute network_for_ssh private
181 iniset $TEMPEST_CONF compute ip_version_for_ssh 4
182 iniset $TEMPEST_CONF compute ssh_timeout 4
Attila Fazekas65c08462012-12-07 14:20:51 +0100183 iniset $TEMPEST_CONF compute image_ref $image_uuid
184 iniset $TEMPEST_CONF compute image_ref_alt $image_uuid_alt
185 iniset $TEMPEST_CONF compute flavor_ref $flavor_ref
186 iniset $TEMPEST_CONF compute flavor_ref_alt $flavor_ref_alt
Attila Fazekas2aa35172012-12-05 20:03:40 +0100187 iniset $TEMPEST_CONF compute source_dir $NOVA_SOURCE_DIR
188 iniset $TEMPEST_CONF compute live_migration_available ${LIVE_MIGRATION_AVAILABLE:-False}
189 iniset $TEMPEST_CONF compute use_block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
190 # Inherited behavior, might be wrong
191 iniset $TEMPEST_CONF compute bin_dir $NOVA_BIN_DIR
192 # TODO(jaypipes): Create the key file here... right now, no whitebox
193 # tests actually use a key.
194 iniset $TEMPEST_CONF compute path_to_private_key $TEMPEST_DIR/id_rsa
195 iniset $TEMPEST_CONF compute db_uri $BASE_SQL_CONN/nova
196
197 # image
198 iniset $TEMPEST_CONF image host ${IMAGE_HOST:-127.0.0.1}
199 iniset $TEMPEST_CONF image port ${IMAGE_PORT:-9292}
Attila Fazekas65c08462012-12-07 14:20:51 +0100200 iniset $TEMPEST_CONF image password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100201
202 # identity-admin
Attila Fazekas65c08462012-12-07 14:20:51 +0100203 iniset $TEMPEST_CONF "identity-admin" password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100204
205 # compute admin
Attila Fazekas65c08462012-12-07 14:20:51 +0100206 iniset $TEMPEST_CONF "compute-admin" password "$password"
Attila Fazekas2aa35172012-12-05 20:03:40 +0100207
208 # network
209 iniset $TEMPEST_CONF network api_version 2.0
210
211 #boto
212 iniset $TEMPEST_CONF boto ec2_url "http://$SERVICE_HOST:8773/services/Cloud"
213 iniset $TEMPEST_CONF boto s3_url "http://$SERVICE_HOST:${S3_SERVICE_PORT:-3333}"
214
215 echo "Created tempest configuration file:"
216 cat $TEMPEST_CONF
217
218 # Restore IFS
219 IFS=$ifs
220 #Restore errexit
221 $errexit
Sean Dagued0931212012-10-04 16:06:44 -0400222}
223
224
225# install_tempest() - Collect source and prepare
226function install_tempest() {
227 git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH
Jeremy Stanley9a352da2012-11-28 17:22:39 +0000228
229 # Tempest doesn't satisfy its dependencies on its own, so
230 # install them here instead.
jiajun xud75bc1f2012-12-04 08:51:35 +0800231 pip_install -r $TEMPEST_DIR/tools/pip-requires
Sean Dagued0931212012-10-04 16:06:44 -0400232}
233
Sean Dagued0931212012-10-04 16:06:44 -0400234# Restore xtrace
235$XTRACE