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 |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 14 | # Optional Dependencies: |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 15 | # IDENTITY_USE_SSL, IDENTITY_HOST, IDENTITY_PORT, IDENTITY_PATH |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 16 | # ALT_* (similar vars exists in keystone_data.sh) |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 17 | # ``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 Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 23 | # ``stack.sh`` calls the entry points in this order: |
| 24 | # |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 25 | # install_tempest |
| 26 | # configure_tempest |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 27 | |
| 28 | # Save trace setting |
| 29 | XTRACE=$(set +o | grep xtrace) |
| 30 | set +o xtrace |
| 31 | |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame^] | 32 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 33 | # Defaults |
| 34 | # -------- |
| 35 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 36 | # Set up default directories |
| 37 | TEMPEST_DIR=$DEST/tempest |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 38 | TEMPEST_CONF_DIR=$TEMPEST_DIR/etc |
| 39 | TEMPEST_CONF=$TEMPEST_CONF_DIR/tempest.conf |
| 40 | |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame^] | 41 | NOVA_SOURCE_DIR=$DEST/nova |
| 42 | |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 43 | BUILD_INTERVAL=3 |
| 44 | BUILD_TIMEOUT=400 |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 45 | |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame^] | 46 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 47 | # Entry Points |
| 48 | # ------------ |
| 49 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 50 | # configure_tempest() - Set config files, create data dirs, etc |
| 51 | function configure_tempest() { |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 52 | local image_lines |
| 53 | local images |
| 54 | local num_images |
| 55 | local image_uuid |
| 56 | local image_uuid_alt |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 57 | local errexit |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 58 | local password |
| 59 | local line |
| 60 | local flavors |
| 61 | local flavors_ref |
| 62 | local flavor_lines |
Maru Newby | a5c774e | 2012-12-10 10:40:01 +0000 | [diff] [blame] | 63 | local public_network_id |
| 64 | local tenant_networks_reachable |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 65 | |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame^] | 66 | # TODO(afazekas): |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 67 | # sudo python setup.py deploy |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 68 | |
| 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 Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame^] | 74 | # Save IFS |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 75 | 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 Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 81 | # ``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 Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 83 | # if there is more than one returned... |
| 84 | # ... 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] | 85 | image_lines=`glance image-list` |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 86 | IFS=$'\n\r' |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 87 | images="" |
| 88 | for line in $image_lines; do |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 89 | if [ -z $DEFAULT_IMAGE_NAME ]; then |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 90 | 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] | 91 | else |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 92 | 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] | 93 | fi |
| 94 | done |
| 95 | # Create array of image UUIDs... |
| 96 | IFS=" " |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 97 | images=($images) |
| 98 | num_images=${#images[*]} |
| 99 | echo "Found $num_images images" |
| 100 | if [[ $num_images -eq 0 ]]; then |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 101 | echo "Found no valid images to use!" |
| 102 | exit 1 |
| 103 | fi |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 104 | image_uuid=${images[0]} |
| 105 | image_uuid_alt=$image_uuid |
| 106 | if [[ $num_images -gt 1 ]]; then |
| 107 | image_uuid_alt=${images[1]} |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 108 | fi |
| 109 | |
| 110 | # Create tempest.conf from tempest.conf.sample |
| 111 | # copy every time, because the image UUIDS are going to change |
| 112 | cp $TEMPEST_CONF.sample $TEMPEST_CONF |
| 113 | |
| 114 | IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False} |
| 115 | IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1} |
| 116 | IDENTITY_PORT=${IDENTITY_PORT:-5000} |
| 117 | # TODO(jaypipes): This is dumb and needs to be removed |
| 118 | # from the Tempest configuration file entirely... |
| 119 | IDENTITY_PATH=${IDENTITY_PATH:-tokens} |
| 120 | |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 121 | password=${ADMIN_PASSWORD:-secrete} |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 122 | |
| 123 | # See files/keystone_data.sh where alt_demo user |
| 124 | # and tenant are set up... |
| 125 | ALT_USERNAME=${ALT_USERNAME:-alt_demo} |
| 126 | ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo} |
| 127 | |
| 128 | # Check Nova for existing flavors and, if set, look for the |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 129 | # ``DEFAULT_INSTANCE_TYPE`` and use that. Otherwise, just use the first flavor. |
| 130 | flavor_lines=`nova flavor-list` |
| 131 | IFS=$'\r\n' |
| 132 | flavors="" |
| 133 | for line in $flavor_lines; do |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 134 | if [ -z $DEFAULT_INSTANCE_TYPE ]; then |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 135 | flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 136 | else |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 137 | 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] | 138 | fi |
| 139 | done |
| 140 | |
| 141 | IFS=" " |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 142 | flavors=($flavors) |
| 143 | num_flavors=${#flavors[*]} |
| 144 | echo "Found $num_flavors flavors" |
| 145 | if [[ $num_flavors -eq 0 ]]; then |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 146 | echo "Found no valid flavors to use!" |
| 147 | exit 1 |
| 148 | fi |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 149 | flavor_ref=${flavors[0]} |
| 150 | flavor_ref_alt=$flavor_ref |
| 151 | if [[ $num_flavors -gt 1 ]]; then |
| 152 | flavor_ref_alt=${flavors[1]} |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 153 | fi |
| 154 | |
Maru Newby | a5c774e | 2012-12-10 10:40:01 +0000 | [diff] [blame] | 155 | if [ "$Q_USE_NAMESPACE" != "False" ]; then |
| 156 | tenant_networks_reachable=false |
| 157 | else |
| 158 | tenant_networks_reachable=true |
| 159 | fi |
| 160 | |
| 161 | if is_service_enabled q-l3; then |
| 162 | public_network_id=$(quantum net-list | grep $PUBLIC_NETWORK_NAME | \ |
| 163 | awk '{print $2}') |
| 164 | fi |
| 165 | |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 166 | # Timeouts |
| 167 | iniset $TEMPEST_CONF compute build_timeout $BUILD_TIMEOUT |
| 168 | iniset $TEMPEST_CONF volume build_timeout $BUILD_TIMEOUT |
| 169 | iniset $TEMPEST_CONF boto build_timeout $BUILD_TIMEOUT |
| 170 | iniset $TEMPEST_CONF compute build_interval $BUILD_INTERVAL |
| 171 | iniset $TEMPEST_CONF volume build_interval $BUILD_INTERVAL |
| 172 | iniset $TEMPEST_CONF boto build_interval $BUILD_INTERVAL |
| 173 | iniset $TEMPEST_CONF boto http_socket_timeout 5 |
| 174 | |
| 175 | iniset $TEMPEST_CONF identity use_ssl $IDENTITY_USE_SSL |
| 176 | iniset $TEMPEST_CONF identity host $IDENTITY_HOST |
| 177 | iniset $TEMPEST_CONF identity port $IDENTITY_PORT |
| 178 | iniset $TEMPEST_CONF identity path $IDENTITY_PATH |
| 179 | |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 180 | iniset $TEMPEST_CONF compute password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 181 | iniset $TEMPEST_CONF compute alt_username $ALT_USERNAME |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 182 | iniset $TEMPEST_CONF compute alt_password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 183 | iniset $TEMPEST_CONF compute alt_tenant_name $ALT_TENANT_NAME |
| 184 | iniset $TEMPEST_CONF compute resize_available False |
| 185 | iniset $TEMPEST_CONF compute change_password_available False |
| 186 | iniset $TEMPEST_CONF compute compute_log_level ERROR |
| 187 | #Skip until #1074039 is fixed |
| 188 | iniset $TEMPEST_CONF compute run_ssh False |
| 189 | iniset $TEMPEST_CONF compute ssh_user ${DEFAULT_INSTANCE_USER:-$OS_USERNAME} |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 190 | iniset $TEMPEST_CONF compute network_for_ssh $PRIVATE_NETWORK_NAME |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 191 | iniset $TEMPEST_CONF compute ip_version_for_ssh 4 |
| 192 | iniset $TEMPEST_CONF compute ssh_timeout 4 |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 193 | iniset $TEMPEST_CONF compute image_ref $image_uuid |
| 194 | iniset $TEMPEST_CONF compute image_ref_alt $image_uuid_alt |
| 195 | iniset $TEMPEST_CONF compute flavor_ref $flavor_ref |
| 196 | iniset $TEMPEST_CONF compute flavor_ref_alt $flavor_ref_alt |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 197 | iniset $TEMPEST_CONF compute source_dir $NOVA_SOURCE_DIR |
| 198 | iniset $TEMPEST_CONF compute live_migration_available ${LIVE_MIGRATION_AVAILABLE:-False} |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 199 | 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] | 200 | # Inherited behavior, might be wrong |
| 201 | iniset $TEMPEST_CONF compute bin_dir $NOVA_BIN_DIR |
| 202 | # TODO(jaypipes): Create the key file here... right now, no whitebox |
| 203 | # tests actually use a key. |
| 204 | iniset $TEMPEST_CONF compute path_to_private_key $TEMPEST_DIR/id_rsa |
| 205 | iniset $TEMPEST_CONF compute db_uri $BASE_SQL_CONN/nova |
| 206 | |
| 207 | # image |
| 208 | iniset $TEMPEST_CONF image host ${IMAGE_HOST:-127.0.0.1} |
| 209 | iniset $TEMPEST_CONF image port ${IMAGE_PORT:-9292} |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 210 | iniset $TEMPEST_CONF image password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 211 | |
| 212 | # identity-admin |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 213 | iniset $TEMPEST_CONF "identity-admin" password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 214 | |
| 215 | # compute admin |
Attila Fazekas | 65c0846 | 2012-12-07 14:20:51 +0100 | [diff] [blame] | 216 | iniset $TEMPEST_CONF "compute-admin" password "$password" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 217 | |
Maru Newby | a5c774e | 2012-12-10 10:40:01 +0000 | [diff] [blame] | 218 | # network admin |
| 219 | iniset $TEMPEST_CONF "network-admin" password "$password" |
| 220 | |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 221 | # network |
| 222 | iniset $TEMPEST_CONF network api_version 2.0 |
Maru Newby | a5c774e | 2012-12-10 10:40:01 +0000 | [diff] [blame] | 223 | iniset $TEMPEST_CONF network password "$password" |
| 224 | iniset $TEMPEST_CONF network tenant_networks_reachable "$tenant_networks_reachable" |
| 225 | iniset $TEMPEST_CONF network public_network_id "$public_network_id" |
Attila Fazekas | 2aa3517 | 2012-12-05 20:03:40 +0100 | [diff] [blame] | 226 | |
| 227 | #boto |
| 228 | iniset $TEMPEST_CONF boto ec2_url "http://$SERVICE_HOST:8773/services/Cloud" |
| 229 | iniset $TEMPEST_CONF boto s3_url "http://$SERVICE_HOST:${S3_SERVICE_PORT:-3333}" |
| 230 | |
| 231 | echo "Created tempest configuration file:" |
| 232 | cat $TEMPEST_CONF |
| 233 | |
| 234 | # Restore IFS |
| 235 | IFS=$ifs |
| 236 | #Restore errexit |
| 237 | $errexit |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 238 | } |
| 239 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 240 | # install_tempest() - Collect source and prepare |
| 241 | function install_tempest() { |
| 242 | git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH |
Jeremy Stanley | 9a352da | 2012-11-28 17:22:39 +0000 | [diff] [blame] | 243 | |
| 244 | # Tempest doesn't satisfy its dependencies on its own, so |
| 245 | # install them here instead. |
jiajun xu | d75bc1f | 2012-12-04 08:51:35 +0800 | [diff] [blame] | 246 | pip_install -r $TEMPEST_DIR/tools/pip-requires |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 247 | } |
| 248 | |
Sean Dague | d093121 | 2012-10-04 16:06:44 -0400 | [diff] [blame] | 249 | # Restore xtrace |
| 250 | $XTRACE |