Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 1 | # lib/tempest |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 2 | # Install and configure Tempest |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 3 | |
| 4 | # Dependencies: |
| 5 | # ``functions`` file |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 6 | # ``lib/nova`` service is runing |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 7 | # <list other global vars that are assumed to be defined> |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 8 | # - ``DEST`` |
| 9 | # - ``ADMIN_PASSWORD`` |
| 10 | # - ``DEFAULT_IMAGE_NAME`` |
| 11 | # - ``S3_SERVICE_PORT`` |
| 12 | # - ``SERVICE_HOST`` |
| 13 | # - ``BASE_SQL_CONN`` ``lib/database`` declares |
Maru Newby | 31c94ab | 2012-12-19 03:59:20 +0000 | [diff] [blame^] | 14 | # - ``PUBLIC_NETWORK_NAME`` |
| 15 | # - ``Q_USE_NAMESPACE`` |
| 16 | # - ``Q_ROUTER_NAME`` |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 17 | # Optional Dependencies: |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 18 | # IDENTITY_USE_SSL, IDENTITY_HOST, IDENTITY_PORT, IDENTITY_PATH |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 19 | # ALT_* (similar vars exists in keystone_data.sh) |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 20 | # ``OS_USERNAME`` |
| 21 | # ``IMAGE_PORT``, ``IMAGE_HOST`` |
| 22 | # ``LIVE_MIGRATION_AVAILABLE`` |
| 23 | # ``USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION`` |
| 24 | # ``DEFAULT_INSTANCE_TYPE`` |
| 25 | # ``DEFAULT_INSTANCE_USER`` |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 26 | # ``stack.sh`` calls the entry points in this order: |
| 27 | # |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 28 | # install_tempest |
| 29 | # configure_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 | |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 35 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 36 | # Defaults |
| 37 | # -------- |
| 38 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 39 | # Set up default directories |
| 40 | TEMPEST_DIR=$DEST/tempest |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 41 | TEMPEST_CONF_DIR=$TEMPEST_DIR/etc |
| 42 | TEMPEST_CONF=$TEMPEST_CONF_DIR/tempest.conf |
| 43 | |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 44 | NOVA_SOURCE_DIR=$DEST/nova |
| 45 | |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 46 | BUILD_INTERVAL=3 |
| 47 | BUILD_TIMEOUT=400 |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 48 | |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 49 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 50 | # Entry Points |
| 51 | # ------------ |
| 52 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 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 |
Maru Newby | a5c774e | 2012-12-10 10:40:01 +0000 | [diff] [blame] | 66 | local public_network_id |
Maru Newby | 31c94ab | 2012-12-19 03:59:20 +0000 | [diff] [blame^] | 67 | local public_router_id |
Maru Newby | a5c774e | 2012-12-10 10:40:01 +0000 | [diff] [blame] | 68 | local tenant_networks_reachable |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 69 | |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 70 | # TODO(afazekas): |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 71 | # sudo python setup.py deploy |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 72 | |
| 73 | # This function exits on an error so that errors don't compound and you see |
| 74 | # only the first error that occured. |
| 75 | errexit=$(set +o | grep errexit) |
| 76 | set -o errexit |
| 77 | |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 78 | # Save IFS |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 79 | ifs=$IFS |
| 80 | |
| 81 | # Glance should already contain images to be used in tempest |
| 82 | # testing. Here we simply look for images stored in Glance |
| 83 | # and set the appropriate variables for use in the tempest config |
| 84 | # We ignore ramdisk and kernel images, look for the default image |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 85 | # ``DEFAULT_IMAGE_NAME``. If not found, we set the ``image_uuid`` to the |
| 86 | # first image returned and set ``image_uuid_alt`` to the second, |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 87 | # if there is more than one returned... |
| 88 | # ... Also ensure we only take active images, so we don't get snapshots in process |
Cody A.W. Somerville | c24e23b | 2012-12-21 02:10:45 -0500 | [diff] [blame] | 89 | declare -a images |
| 90 | |
| 91 | while read -r IMAGE_NAME IMAGE_UUID; do |
| 92 | if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then |
| 93 | image_uuid="$IMAGE_UUID" |
| 94 | image_uuid_alt="$IMAGE_UUID" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 95 | fi |
Cody A.W. Somerville | c24e23b | 2012-12-21 02:10:45 -0500 | [diff] [blame] | 96 | images+=($IMAGE_UUID) |
| 97 | done < <(glance image-list --status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }') |
| 98 | |
| 99 | case "${#images[*]}" in |
| 100 | 0) |
| 101 | echo "Found no valid images to use!" |
| 102 | exit 1 |
| 103 | ;; |
| 104 | 1) |
| 105 | if [ -z "$image_uuid" ]; then |
| 106 | image_uuid=${images[0]} |
| 107 | image_uuid_alt=${images[0]} |
| 108 | fi |
| 109 | ;; |
| 110 | *) |
| 111 | if [ -z "$image_uuid" ]; then |
| 112 | image_uuid=${images[0]} |
| 113 | image_uuid_alt=${images[1]} |
| 114 | fi |
| 115 | ;; |
| 116 | esac |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 117 | |
| 118 | # Create tempest.conf from tempest.conf.sample |
| 119 | # copy every time, because the image UUIDS are going to change |
| 120 | cp $TEMPEST_CONF.sample $TEMPEST_CONF |
| 121 | |
| 122 | IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False} |
| 123 | IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1} |
| 124 | IDENTITY_PORT=${IDENTITY_PORT:-5000} |
| 125 | # TODO(jaypipes): This is dumb and needs to be removed |
| 126 | # from the Tempest configuration file entirely... |
| 127 | IDENTITY_PATH=${IDENTITY_PATH:-tokens} |
| 128 | |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 129 | password=${ADMIN_PASSWORD:-secrete} |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 130 | |
| 131 | # See files/keystone_data.sh where alt_demo user |
| 132 | # and tenant are set up... |
| 133 | ALT_USERNAME=${ALT_USERNAME:-alt_demo} |
| 134 | ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo} |
| 135 | |
Attila Fazekas | 7bf1dd3 | 2013-01-12 17:31:26 +0100 | [diff] [blame] | 136 | # If the ``DEFAULT_INSTANCE_TYPE`` not declared, use the new behavior |
| 137 | # Tempest creates instane types for himself |
| 138 | if [[ -z "$DEFAULT_INSTANCE_TYPE" ]]; then |
Attila Fazekas | 02c0bcc | 2013-01-14 19:10:17 +0100 | [diff] [blame] | 139 | nova flavor-create m1.nano 42 64 0 1 |
Attila Fazekas | 7bf1dd3 | 2013-01-12 17:31:26 +0100 | [diff] [blame] | 140 | flavor_ref=42 |
Attila Fazekas | 02c0bcc | 2013-01-14 19:10:17 +0100 | [diff] [blame] | 141 | nova flavor-create m1.micro 84 128 0 1 |
Attila Fazekas | 7bf1dd3 | 2013-01-12 17:31:26 +0100 | [diff] [blame] | 142 | flavor_ref_alt=84 |
| 143 | else |
| 144 | # Check Nova for existing flavors and, if set, look for the |
| 145 | # ``DEFAULT_INSTANCE_TYPE`` and use that. |
| 146 | flavor_lines=`nova flavor-list` |
| 147 | IFS=$'\r\n' |
| 148 | flavors="" |
Dean Troyer | ceaa38b | 2012-12-12 17:09:57 -0600 | [diff] [blame] | 149 | for line in $flavor_lines; do |
| 150 | f=$(echo $line | awk "/ $DEFAULT_INSTANCE_TYPE / { print \$2 }") |
| 151 | flavors="$flavors $f" |
| 152 | done |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 153 | |
Attila Fazekas | 7bf1dd3 | 2013-01-12 17:31:26 +0100 | [diff] [blame] | 154 | for line in $flavor_lines; do |
| 155 | flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`" |
| 156 | done |
| 157 | |
| 158 | IFS=" " |
| 159 | flavors=($flavors) |
| 160 | num_flavors=${#flavors[*]} |
| 161 | echo "Found $num_flavors flavors" |
| 162 | if [[ $num_flavors -eq 0 ]]; then |
| 163 | echo "Found no valid flavors to use!" |
| 164 | exit 1 |
| 165 | fi |
| 166 | flavor_ref=${flavors[0]} |
| 167 | flavor_ref_alt=$flavor_ref |
| 168 | if [[ $num_flavors -gt 1 ]]; then |
| 169 | flavor_ref_alt=${flavors[1]} |
| 170 | fi |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 171 | fi |
| 172 | |
Maru Newby | a5c774e | 2012-12-10 10:40:01 +0000 | [diff] [blame] | 173 | if [ "$Q_USE_NAMESPACE" != "False" ]; then |
| 174 | tenant_networks_reachable=false |
| 175 | else |
| 176 | tenant_networks_reachable=true |
| 177 | fi |
| 178 | |
| 179 | if is_service_enabled q-l3; then |
| 180 | public_network_id=$(quantum net-list | grep $PUBLIC_NETWORK_NAME | \ |
| 181 | awk '{print $2}') |
Maru Newby | 31c94ab | 2012-12-19 03:59:20 +0000 | [diff] [blame^] | 182 | if [ "$Q_USE_NAMESPACE" == "False" ]; then |
| 183 | # If namespaces are disabled, devstack will create a single |
| 184 | # public router that tempest should be configured to use. |
| 185 | public_router_id=$(quantum router-list | awk "/ $Q_ROUTER_NAME / \ |
| 186 | { print \$2 }") |
| 187 | fi |
Maru Newby | a5c774e | 2012-12-10 10:40:01 +0000 | [diff] [blame] | 188 | fi |
| 189 | |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 190 | # Timeouts |
| 191 | iniset $TEMPEST_CONF compute build_timeout $BUILD_TIMEOUT |
| 192 | iniset $TEMPEST_CONF volume build_timeout $BUILD_TIMEOUT |
| 193 | iniset $TEMPEST_CONF boto build_timeout $BUILD_TIMEOUT |
| 194 | iniset $TEMPEST_CONF compute build_interval $BUILD_INTERVAL |
| 195 | iniset $TEMPEST_CONF volume build_interval $BUILD_INTERVAL |
| 196 | iniset $TEMPEST_CONF boto build_interval $BUILD_INTERVAL |
| 197 | iniset $TEMPEST_CONF boto http_socket_timeout 5 |
| 198 | |
| 199 | iniset $TEMPEST_CONF identity use_ssl $IDENTITY_USE_SSL |
| 200 | iniset $TEMPEST_CONF identity host $IDENTITY_HOST |
| 201 | iniset $TEMPEST_CONF identity port $IDENTITY_PORT |
| 202 | iniset $TEMPEST_CONF identity path $IDENTITY_PATH |
| 203 | |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 204 | iniset $TEMPEST_CONF compute password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 205 | iniset $TEMPEST_CONF compute alt_username $ALT_USERNAME |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 206 | iniset $TEMPEST_CONF compute alt_password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 207 | iniset $TEMPEST_CONF compute alt_tenant_name $ALT_TENANT_NAME |
| 208 | iniset $TEMPEST_CONF compute resize_available False |
| 209 | iniset $TEMPEST_CONF compute change_password_available False |
| 210 | iniset $TEMPEST_CONF compute compute_log_level ERROR |
Nachi Ueno | 06fac37 | 2012-12-26 14:09:43 -0800 | [diff] [blame] | 211 | # Note(nati) current tempest don't create network for each tenant |
| 212 | # so reuse same tenant for now |
| 213 | if is_service_enabled quantum; then |
| 214 | TEMPEST_ALLOW_TENANT_ISOLATION=${TEMPEST_ALLOW_TENANT_ISOLATION:-False} |
| 215 | fi |
| 216 | iniset $TEMPEST_CONF compute allow_tenant_isolation ${TEMPEST_ALLOW_TENANT_ISOLATION:-True} |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 217 | #Skip until #1074039 is fixed |
| 218 | iniset $TEMPEST_CONF compute run_ssh False |
| 219 | iniset $TEMPEST_CONF compute ssh_user ${DEFAULT_INSTANCE_USER:-$OS_USERNAME} |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 220 | iniset $TEMPEST_CONF compute network_for_ssh $PRIVATE_NETWORK_NAME |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 221 | iniset $TEMPEST_CONF compute ip_version_for_ssh 4 |
| 222 | iniset $TEMPEST_CONF compute ssh_timeout 4 |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 223 | iniset $TEMPEST_CONF compute image_ref $image_uuid |
| 224 | iniset $TEMPEST_CONF compute image_ref_alt $image_uuid_alt |
| 225 | iniset $TEMPEST_CONF compute flavor_ref $flavor_ref |
| 226 | iniset $TEMPEST_CONF compute flavor_ref_alt $flavor_ref_alt |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 227 | iniset $TEMPEST_CONF compute source_dir $NOVA_SOURCE_DIR |
| 228 | iniset $TEMPEST_CONF compute live_migration_available ${LIVE_MIGRATION_AVAILABLE:-False} |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 229 | iniset $TEMPEST_CONF compute use_block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False} |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 230 | # Inherited behavior, might be wrong |
| 231 | iniset $TEMPEST_CONF compute bin_dir $NOVA_BIN_DIR |
| 232 | # TODO(jaypipes): Create the key file here... right now, no whitebox |
| 233 | # tests actually use a key. |
| 234 | iniset $TEMPEST_CONF compute path_to_private_key $TEMPEST_DIR/id_rsa |
| 235 | iniset $TEMPEST_CONF compute db_uri $BASE_SQL_CONN/nova |
| 236 | |
| 237 | # image |
| 238 | iniset $TEMPEST_CONF image host ${IMAGE_HOST:-127.0.0.1} |
| 239 | iniset $TEMPEST_CONF image port ${IMAGE_PORT:-9292} |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 240 | iniset $TEMPEST_CONF image password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 241 | |
| 242 | # identity-admin |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 243 | iniset $TEMPEST_CONF "identity-admin" password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 244 | |
| 245 | # compute admin |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 246 | iniset $TEMPEST_CONF "compute-admin" password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 247 | |
Maru Newby | a5c774e | 2012-12-10 10:40:01 +0000 | [diff] [blame] | 248 | # network admin |
| 249 | iniset $TEMPEST_CONF "network-admin" password "$password" |
| 250 | |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 251 | # network |
| 252 | iniset $TEMPEST_CONF network api_version 2.0 |
Maru Newby | a5c774e | 2012-12-10 10:40:01 +0000 | [diff] [blame] | 253 | iniset $TEMPEST_CONF network password "$password" |
| 254 | iniset $TEMPEST_CONF network tenant_networks_reachable "$tenant_networks_reachable" |
| 255 | iniset $TEMPEST_CONF network public_network_id "$public_network_id" |
Maru Newby | 31c94ab | 2012-12-19 03:59:20 +0000 | [diff] [blame^] | 256 | iniset $TEMPEST_CONF network public_router_id "$public_router_id" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 257 | |
| 258 | #boto |
| 259 | iniset $TEMPEST_CONF boto ec2_url "http://$SERVICE_HOST:8773/services/Cloud" |
| 260 | iniset $TEMPEST_CONF boto s3_url "http://$SERVICE_HOST:${S3_SERVICE_PORT:-3333}" |
| 261 | |
| 262 | echo "Created tempest configuration file:" |
| 263 | cat $TEMPEST_CONF |
| 264 | |
| 265 | # Restore IFS |
| 266 | IFS=$ifs |
| 267 | #Restore errexit |
| 268 | $errexit |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 269 | } |
| 270 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 271 | # install_tempest() - Collect source and prepare |
| 272 | function install_tempest() { |
| 273 | git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH |
Jeremy Stanley | 9a352da | 2012-11-28 17:22:39 +0000 | [diff] [blame] | 274 | |
| 275 | # Tempest doesn't satisfy its dependencies on its own, so |
| 276 | # install them here instead. |
jiajun xu | d75bc1f | 2012-12-04 08:51:35 +0800 | [diff] [blame] | 277 | pip_install -r $TEMPEST_DIR/tools/pip-requires |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 278 | } |
| 279 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 280 | # Restore xtrace |
| 281 | $XTRACE |