Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 1 | # lib/tempest |
| 2 | |
| 3 | # Dependencies: |
| 4 | # ``functions`` file |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 5 | # ``lib/nova`` service is runing |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 6 | # <list other global vars that are assumed to be defined> |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 7 | # - ``DEST`` |
| 8 | # - ``ADMIN_PASSWORD`` |
| 9 | # - ``DEFAULT_IMAGE_NAME`` |
| 10 | # - ``S3_SERVICE_PORT`` |
| 11 | # - ``SERVICE_HOST`` |
| 12 | # - ``BASE_SQL_CONN`` ``lib/database`` declares |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 13 | # Optional Dependencies: |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 14 | # IDENTITY_USE_SSL, IDENTITY_HOST, IDENTITY_PORT, IDENTITY_PATH |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 15 | # ALT_* (similar vars exists in keystone_data.sh) |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 16 | # ``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 Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 22 | # ``stack.sh`` calls the entry points in this order: |
| 23 | # |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 24 | # install_tempest |
| 25 | # configure_tempest |
| 26 | # init_tempest |
| 27 | ## start_tempest |
| 28 | ## stop_tempest |
| 29 | ## cleanup_tempest |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 30 | |
| 31 | # Save trace setting |
| 32 | XTRACE=$(set +o | grep xtrace) |
| 33 | set +o xtrace |
| 34 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 35 | # Defaults |
| 36 | # -------- |
| 37 | |
| 38 | # <define global variables here that belong to this project> |
| 39 | |
| 40 | # Set up default directories |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 41 | NOVA_SOURCE_DIR=$DEST/nova |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 42 | TEMPEST_DIR=$DEST/tempest |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 43 | TEMPEST_CONF_DIR=$TEMPEST_DIR/etc |
| 44 | TEMPEST_CONF=$TEMPEST_CONF_DIR/tempest.conf |
| 45 | |
| 46 | BUILD_INTERVAL=3 |
| 47 | BUILD_TIMEOUT=400 |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 48 | |
| 49 | # Entry Points |
| 50 | # ------------ |
| 51 | |
| 52 | |
| 53 | # configure_tempest() - Set config files, create data dirs, etc |
| 54 | function configure_tempest() { |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 55 | local image_lines |
| 56 | local images |
| 57 | local num_images |
| 58 | local image_uuid |
| 59 | local image_uuid_alt |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 60 | local errexit |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 61 | local password |
| 62 | local line |
| 63 | local flavors |
| 64 | local flavors_ref |
| 65 | local flavor_lines |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 66 | |
| 67 | #TODO(afazekas): |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 68 | # sudo python setup.py deploy |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 69 | |
| 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 Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 82 | # ``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 Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 84 | # if there is more than one returned... |
| 85 | # ... Also ensure we only take active images, so we don't get snapshots in process |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 86 | image_lines=`glance image-list` |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 87 | IFS=$'\n\r' |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 88 | images="" |
| 89 | for line in $image_lines; do |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 90 | if [ -z $DEFAULT_IMAGE_NAME ]; then |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 91 | images="$images `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | cut -d' ' -f2`" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 92 | else |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 93 | images="$images `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | grep "$DEFAULT_IMAGE_NAME" | cut -d' ' -f2`" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 94 | fi |
| 95 | done |
| 96 | # Create array of image UUIDs... |
| 97 | IFS=" " |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 98 | images=($images) |
| 99 | num_images=${#images[*]} |
| 100 | echo "Found $num_images images" |
| 101 | if [[ $num_images -eq 0 ]]; then |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 102 | echo "Found no valid images to use!" |
| 103 | exit 1 |
| 104 | fi |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 105 | image_uuid=${images[0]} |
| 106 | image_uuid_alt=$image_uuid |
| 107 | if [[ $num_images -gt 1 ]]; then |
| 108 | image_uuid_alt=${images[1]} |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 109 | 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 Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 122 | password=${ADMIN_PASSWORD:-secrete} |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 123 | |
| 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 Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 130 | # ``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 Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 135 | if [ -z $DEFAULT_INSTANCE_TYPE ]; then |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 136 | flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 137 | else |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 138 | flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | grep "$DEFAULT_INSTANCE_TYPE" | cut -d' ' -f2`" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 139 | fi |
| 140 | done |
| 141 | |
| 142 | IFS=" " |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 143 | flavors=($flavors) |
| 144 | num_flavors=${#flavors[*]} |
| 145 | echo "Found $num_flavors flavors" |
| 146 | if [[ $num_flavors -eq 0 ]]; then |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 147 | echo "Found no valid flavors to use!" |
| 148 | exit 1 |
| 149 | fi |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 150 | flavor_ref=${flavors[0]} |
| 151 | flavor_ref_alt=$flavor_ref |
| 152 | if [[ $num_flavors -gt 1 ]]; then |
| 153 | flavor_ref_alt=${flavors[1]} |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 154 | 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 Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 170 | iniset $TEMPEST_CONF compute password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 171 | iniset $TEMPEST_CONF compute alt_username $ALT_USERNAME |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 172 | iniset $TEMPEST_CONF compute alt_password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 173 | 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 Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 183 | 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 Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 187 | 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 Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 200 | iniset $TEMPEST_CONF image password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 201 | |
| 202 | # identity-admin |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 203 | iniset $TEMPEST_CONF "identity-admin" password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 204 | |
| 205 | # compute admin |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 206 | iniset $TEMPEST_CONF "compute-admin" password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 207 | |
| 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 Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | |
| 225 | # install_tempest() - Collect source and prepare |
| 226 | function install_tempest() { |
| 227 | git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH |
Jeremy Stanley | 9a352da | 2012-11-28 17:22:39 +0000 | [diff] [blame] | 228 | |
| 229 | # Tempest doesn't satisfy its dependencies on its own, so |
| 230 | # install them here instead. |
jiajun xu | d75bc1f | 2012-12-04 08:51:35 +0800 | [diff] [blame] | 231 | pip_install -r $TEMPEST_DIR/tools/pip-requires |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 232 | } |
| 233 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 234 | # Restore xtrace |
| 235 | $XTRACE |