| Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 1 | #!/bin/bash | 
|  | 2 |  | 
| Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 3 | variables=( | 
|  | 4 | OS_USERNAME | 
|  | 5 | OS_PASSWORD | 
|  | 6 | OS_TENANT_NAME | 
|  | 7 | OS_AUTH_URL | 
|  | 8 | ) | 
|  | 9 |  | 
|  | 10 | check_variables () { | 
|  | 11 | for i in $(seq 0 $(( ${#variables[@]} - 1 )) ); do | 
|  | 12 | if [ -z "${!variables[$i]}" ]; then | 
|  | 13 | echo "Variable \"${variables[$i]}\" is not defined" | 
|  | 14 | exit 1 | 
|  | 15 | fi | 
|  | 16 | done | 
| Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 17 | ip=$(echo ${OS_AUTH_URL} | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/') | 
|  | 18 | export no_proxy=$ip | 
| Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 19 | } | 
|  | 20 |  | 
|  | 21 | rally_configuration () { | 
| Oleksii Zhurba | 2273790 | 2018-02-07 14:09:47 -0600 | [diff] [blame] | 22 | rally_version=$(rally version 2>&1) | 
| Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 23 | # will be removed when we switch to Rally 0.9.2+ | 
| Oleksii Zhurba | 2273790 | 2018-02-07 14:09:47 -0600 | [diff] [blame] | 24 | if [ "$rally_version" == "0.9.0" ] || [ "$rally_version" == "0.9.1" ]; then | 
|  | 25 | pip install ansible==2.3.2.0 | 
| Oleksii Zhurba | 167f465 | 2018-03-29 16:43:41 -0500 | [diff] [blame] | 26 | sed -i '270s/,/}#,/g' /usr/local/lib/python2.7/dist-packages/rally/plugins/openstack/wrappers/network.py | 
| Oleksii Zhurba | 2273790 | 2018-02-07 14:09:47 -0600 | [diff] [blame] | 27 | fi | 
| Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 28 | sub_name=`date "+%H_%M_%S"` | 
|  | 29 | rally deployment create --fromenv --name=tempest_$sub_name | 
|  | 30 | rally deployment config | 
|  | 31 | } | 
|  | 32 |  | 
| Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 33 | additional_tempest_plugins (){ | 
|  | 34 | if [ -n "${PROXY}" ]; then | 
|  | 35 | export https_proxy=$PROXY | 
|  | 36 | fi | 
|  | 37 | rally verify add-verifier-ext --source https://github.com/openstack/telemetry-tempest-plugin | 
|  | 38 | rally verify add-verifier-ext --source https://github.com/openstack/heat-tempest-plugin | 
|  | 39 | unset https_proxy | 
|  | 40 | } | 
|  | 41 |  | 
| Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 42 | tempest_configuration () { | 
|  | 43 | sub_name=`date "+%H_%M_%S"` | 
| Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 44 | if [ -n "${OFFLINE}" ]; then | 
|  | 45 | rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_REPO --system-wide --version $tempest_version | 
|  | 46 | cd /var/lib/ | 
|  | 47 | else | 
|  | 48 | if [ -n "${PROXY}" ]; then | 
|  | 49 | export https_proxy=$PROXY | 
|  | 50 | fi | 
|  | 51 | rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_REPO --version $tempest_version | 
|  | 52 | unset https_proxy | 
| Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 53 | fi | 
| Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 54 | rally verify configure-verifier --show | 
| Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 55 | additional_tempest_plugins | 
| Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 56 | } | 
|  | 57 |  | 
| Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 58 | quick_configuration () { | 
|  | 59 | current_path=$(pwd) | 
|  | 60 | #image | 
| Oleksii Zhurba | fe6b571 | 2018-06-14 13:05:00 -0500 | [diff] [blame] | 61 | glance image-list | grep "\btestvm\b" 2>&1 >/dev/null || { | 
| Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 62 | if [ -n "${PROXY}" ]; then | 
|  | 63 | export http_proxy=$PROXY | 
|  | 64 | fi | 
| Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 65 | ls $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img || wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img -O $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img | 
| Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 66 | unset http_proxy | 
| Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 67 | echo "MD5 should be ee1eca47dc88f4879d8a229cc70a07c6" | 
| Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 68 | md5sum $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img | 
| Oleksii Zhurba | fe6b571 | 2018-06-14 13:05:00 -0500 | [diff] [blame] | 69 | glance image-create --name=testvm --visibility=public --container-format=bare --disk-format=qcow2 < $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img | 
| Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 70 | } | 
| Oleksii Zhurba | fe6b571 | 2018-06-14 13:05:00 -0500 | [diff] [blame] | 71 | IMAGE_REF2=$(glance image-list | grep 'testvm' | awk '{print $2}') | 
| Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 72 | #flavor for rally | 
|  | 73 | nova flavor-list | grep tiny 2>&1 >/dev/null || { | 
|  | 74 | echo "Let's create m1.tiny flavor" | 
|  | 75 | nova flavor-create --is-public true m1.tiny auto 128 1 1 | 
|  | 76 | } | 
|  | 77 | #shared fixed network | 
|  | 78 | shared_count=`neutron net-list -c name -c shared | grep True | wc -l` | 
|  | 79 | if [ $shared_count -gt 1 ]; then | 
|  | 80 | echo "TOO MANY SHARED NETWORKS! Script will choose just 1 random" | 
|  | 81 | fi | 
|  | 82 | if [ $shared_count -eq 0 ]; then | 
|  | 83 | echo "Let's create shared fixed net" | 
| Oleksii Zhurba | fe6b571 | 2018-06-14 13:05:00 -0500 | [diff] [blame] | 84 | neutron net-create --shared tempest-net | 
|  | 85 | neutron subnet-create --name tempest-subnet --gateway 192.168.0.1 --allocation-pool start=192.168.0.2,end=192.168.0.254 --ip-version 4 tempest-net 192.168.0.0/24 | 
| Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 86 | fi | 
|  | 87 | FIXED_NET=$(neutron net-list -c name -c shared | grep True | awk '{print $2}' | tail -n 1) | 
|  | 88 | echo "Fixed net is: $FIXED_NET" | 
|  | 89 | #Updating of tempest_full.conf file is skipped/deprecated | 
| Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 90 | sed -i 's/${IMAGE_REF2}/'$IMAGE_REF2'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf | 
| Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 91 | sed -i 's/${FIXED_NET}/'$FIXED_NET'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf | 
| Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 92 | sed -i 's/publicURL/'$TEMPEST_ENDPOINT_TYPE'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf | 
|  | 93 | cat $current_path/cvp-configuration/tempest/tempest_ext.conf | 
|  | 94 | } | 
|  | 95 |  | 
| Oleksii Zhurba | ba5883f | 2018-01-18 09:52:08 -0600 | [diff] [blame] | 96 | if [ "$1" == "reconfigure" ]; then | 
|  | 97 | echo "This is reconfiguration" | 
|  | 98 | rally verify configure-verifier --reconfigure | 
| Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 99 | rally verify configure-verifier --extend $current_path/cvp-configuration/tempest/tempest_ext.conf | 
| Oleksii Zhurba | ba5883f | 2018-01-18 09:52:08 -0600 | [diff] [blame] | 100 | rally verify configure-verifier --show | 
|  | 101 | exit 0 | 
|  | 102 | fi | 
|  | 103 |  | 
| Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 104 | check_variables | 
|  | 105 | rally_configuration | 
| Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 106 | if [ -n "${TEMPEST_REPO}" ]; then | 
| Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 107 | tempest_configuration | 
| Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 108 | quick_configuration | 
| Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 109 | rally verify configure-verifier --extend $current_path/cvp-configuration/tempest/tempest_ext.conf | 
| Oleksii Zhurba | 7f3941b | 2018-03-27 14:38:42 -0500 | [diff] [blame] | 110 | # Add 2 additional tempest tests (live migration to all nodes + ssh to all nodes) | 
|  | 111 | # TBD | 
|  | 112 | #cat tempest/test_extension.py >> repo/tempest/scenario/test_server_multinode.py | 
| Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 113 | fi | 
|  | 114 | set -e | 
|  | 115 |  | 
| Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 116 | echo "Configuration is done!" |