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) |
| 23 | if [ "$rally_version" == "0.9.0" ] || [ "$rally_version" == "0.9.1" ]; then |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 24 | echo "Please use rally 0.10.1" |
| 25 | exit |
| 26 | fi |
| 27 | if [ "$PROXY" != "offline" ]; then |
| 28 | if [ -n "${PROXY}" ]; then |
| 29 | export http_proxy=$PROXY |
| 30 | export https_proxy=$PROXY |
| 31 | fi |
| 32 | pip install --force-reinstall python-glanceclient==2.11 |
| 33 | apt-get update; apt-get install -y iputils-ping curl wget |
| 34 | unset http_proxy |
| 35 | unset https_proxy |
Oleksii Zhurba | 2273790 | 2018-02-07 14:09:47 -0600 | [diff] [blame] | 36 | fi |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 37 | sub_name=`date "+%H_%M_%S"` |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 38 | # remove dashes from rally user passwords to fit into 32 char limit |
| 39 | sed -i 's/uuid4())/uuid4()).replace("-","")/g' /usr/local/lib/python2.7/dist-packages/rally/plugins/openstack/scenarios/keystone/utils.py |
| 40 | sed -i 's/uuid4())/uuid4()).replace("-","")/g' /usr/local/lib/python2.7/dist-packages/rally/plugins/openstack/context/keystone/users.py |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 41 | rally deployment create --fromenv --name=tempest_$sub_name |
| 42 | rally deployment config |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 43 | echo "[openstack]" >> /etc/rally/rally.conf |
| 44 | echo "pre_newton_neutron=True" >> /etc/rally/rally.conf |
| 45 | } |
| 46 | |
| 47 | update_cacerts () { |
| 48 | # configuring certificates file |
| 49 | if [ -z ${OS_CACERT+x} ]; then |
| 50 | echo '# No OS_CACERT is set, update of crt file skipped' |
| 51 | else |
| 52 | echo '# Adding custom certificates' |
| 53 | ca=( $(find ${1} -name cacert.pem) ) |
| 54 | for crt in ${ca[@]}; do |
| 55 | cat ${OS_CACERT} >>${crt} |
| 56 | echo '-> ${crt}' |
| 57 | done |
| 58 | fi |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | tempest_configuration () { |
| 62 | sub_name=`date "+%H_%M_%S"` |
Oleksii Zhurba | d85b002 | 2018-09-11 15:43:43 -0500 | [diff] [blame] | 63 | # default tempest version is 17.2.0 now, unless |
| 64 | # it is explicitly defined in pipelines |
| 65 | if [ "$tempest_version" == "" ]; then |
| 66 | tempest_version='17.2.0' |
| 67 | fi |
Oleksii Zhurba | 991dbc6 | 2018-07-25 16:03:51 -0500 | [diff] [blame] | 68 | if [ "$PROXY" == "offline" ]; then |
Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 69 | rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_REPO --system-wide --version $tempest_version |
Oleksii Zhurba | 991dbc6 | 2018-07-25 16:03:51 -0500 | [diff] [blame] | 70 | rally verify add-verifier-ext --source /var/lib/telemetry-tempest-plugin |
| 71 | rally verify add-verifier-ext --source /var/lib/heat-tempest-plugin |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 72 | update_cacerts "/usr/local/lib" |
Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 73 | else |
| 74 | if [ -n "${PROXY}" ]; then |
| 75 | export https_proxy=$PROXY |
| 76 | fi |
| 77 | rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_REPO --version $tempest_version |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 78 | #rally verify add-verifier-ext --version 7a4bff728fbd8629ec211669264ab645aa921e2b --source https://github.com/openstack/telemetry-tempest-plugin |
| 79 | rally verify add-verifier-ext --version mcp/ocata --source https://gerrit.mcp.mirantis.com/packaging/sources/heat-tempest-plugin |
Oleksii Zhurba | 8b76f3d | 2018-08-07 12:38:26 -0500 | [diff] [blame] | 80 | pip install --force-reinstall python-cinderclient==3.2.0 |
Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 81 | unset https_proxy |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 82 | update_cacerts "/home/rally/.rally/verification" |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 83 | fi |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 84 | # set password length to 32 |
| 85 | data_utils_path=`find /home/rally/.rally/verification/ -name data_utils.py` |
| 86 | sed -i 's/length=15/length=32/g' $data_utils_path |
| 87 | |
Oleksii Zhurba | 991dbc6 | 2018-07-25 16:03:51 -0500 | [diff] [blame] | 88 | # supress tempest.conf display in console |
| 89 | #rally verify configure-verifier --show |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 90 | } |
| 91 | |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 92 | glance_image() { |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 93 | current_path=$(pwd) |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 94 | # fetch image with exact name: testvm |
| 95 | IMAGE_NAME2=testvm |
| 96 | IMAGE_REF2=$(glance image-list | grep "\b${IMAGE_NAME2}\b" | awk '{print $2}') |
| 97 | if [ "${IMAGE_REF2}" == "" ]; then |
| 98 | if [ "$PROXY" != "offline" ]; then |
| 99 | if [ -n "${PROXY}" ]; then |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 100 | export http_proxy=$PROXY |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 101 | export https_proxy=$PROXY |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 102 | fi |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 103 | 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] | 104 | unset http_proxy |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 105 | unset https_proxy |
| 106 | fi |
| 107 | if [ -e $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img ]; then |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 108 | echo "MD5 should be ee1eca47dc88f4879d8a229cc70a07c6" |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 109 | md5sum $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 110 | glance image-create --name=${IMAGE_NAME2} --visibility=public --container-format=bare --disk-format=qcow2 < $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img |
| 111 | IMAGE_REF2=$(glance image-list | grep "\b${IMAGE_NAME2}\b" | awk '{print $2}') |
| 112 | else |
| 113 | echo "Cirros image was not downloaded! Some tests may fail" |
| 114 | IMAGE_REF2="" |
| 115 | fi |
| 116 | fi |
| 117 | sed -i 's/${IMAGE_REF2}/'$IMAGE_REF2'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
| 118 | sed -i 's/${IMAGE_NAME2}/'$IMAGE_NAME2'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 119 | } |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 120 | |
| 121 | quick_configuration () { |
| 122 | current_path=$(pwd) |
| 123 | #image |
| 124 | glance_image |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 125 | #flavor for rally |
| 126 | nova flavor-list | grep tiny 2>&1 >/dev/null || { |
| 127 | echo "Let's create m1.tiny flavor" |
| 128 | nova flavor-create --is-public true m1.tiny auto 128 1 1 |
| 129 | } |
| 130 | #shared fixed network |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 131 | shared_count=`neutron net-list -c name -c shared | grep True | grep "fixed-net" | wc -l` |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 132 | if [ $shared_count -eq 0 ]; then |
| 133 | echo "Let's create shared fixed net" |
Oleksii Zhurba | a277000 | 2018-08-07 11:25:56 -0500 | [diff] [blame] | 134 | neutron net-create --shared fixed-net |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 135 | FIXED_NET_ID=$(neutron net-list -c id -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1) |
| 136 | neutron subnet-create --name fixed-subnet --gateway 192.168.0.1 --allocation-pool start=192.168.0.2,end=192.168.0.254 --ip-version 4 $FIXED_NET_ID 192.168.0.0/24 |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 137 | fi |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 138 | fixed_count=`neutron net-list | grep "fixed-net" | wc -l` |
| 139 | if [ $fixed_count -gt 1 ]; then |
| 140 | echo "TOO MANY NETWORKS WITH fixed-net NAME! This may affect tests. Please review your network list." |
| 141 | fi |
| 142 | # public/floating net |
| 143 | PUBLIC_NET=$(neutron net-list -c name -c router:external | grep True | awk '{print $2}' | tail -n 1) |
| 144 | FIXED_NET=$(neutron net-list -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1) |
| 145 | FIXED_NET_ID=$(neutron net-list -c id -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1) |
| 146 | FIXED_SUBNET_ID=$(neutron net-show $FIXED_NET_ID -c subnets | grep subnets | awk '{print $4}') |
| 147 | FIXED_SUBNET_NAME=$(neutron subnet-show -c name $FIXED_SUBNET_ID | grep name | awk '{print $4}') |
| 148 | echo "Public net name is $PUBLIC_NET" |
| 149 | echo "Fixed net name is $FIXED_NET, id is $FIXED_NET_ID" |
| 150 | echo "Fixed subnet is: $FIXED_SUBNET_ID, name: $FIXED_SUBNET_NAME" |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 151 | sed -i 's/${FIXED_NET}/'$FIXED_NET'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 152 | sed -i 's/${FIXED_SUBNET_NAME}/'$FIXED_SUBNET_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
| 153 | sed -i 's/${OS_USERNAME}/'$OS_USERNAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
| 154 | sed -i 's/${OS_TENANT_NAME}/'$OS_TENANT_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
| 155 | sed -i 's/${OS_REGION_NAME}/'$OS_REGION_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
| 156 | sed -i 's|${OS_AUTH_URL}|'"${OS_AUTH_URL}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
| 157 | sed -i 's|${OS_PASSWORD}|'"${OS_PASSWORD}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
| 158 | sed -i 's|${PUBLIC_NET}|'"${PUBLIC_NET}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 159 | sed -i 's/publicURL/'$TEMPEST_ENDPOINT_TYPE'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
Oleksii Zhurba | 991dbc6 | 2018-07-25 16:03:51 -0500 | [diff] [blame] | 160 | #supress tempest.conf display in console |
| 161 | #cat $current_path/cvp-configuration/tempest/tempest_ext.conf |
| 162 | cp $current_path/cvp-configuration/tempest/boot_config_none_env.yaml /home/rally/boot_config_none_env.yaml |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 163 | cp $current_path/cvp-configuration/cleanup.sh /home/rally/cleanup.sh |
| 164 | chmod 755 /home/rally/cleanup.sh |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 165 | } |
| 166 | |
Oleksii Zhurba | ba5883f | 2018-01-18 09:52:08 -0600 | [diff] [blame] | 167 | if [ "$1" == "reconfigure" ]; then |
| 168 | echo "This is reconfiguration" |
| 169 | rally verify configure-verifier --reconfigure |
Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 170 | 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] | 171 | rally verify configure-verifier --show |
| 172 | exit 0 |
| 173 | fi |
| 174 | |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 175 | check_variables |
| 176 | rally_configuration |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 177 | quick_configuration |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 178 | if [ -n "${TEMPEST_REPO}" ]; then |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 179 | tempest_configuration |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 180 | # If you do not have fip network, use this command |
| 181 | #cat $current_path/cvp-configuration/tempest/skip-list-fip-only.yaml >> $current_path/cvp-configuration/tempest/skip-list-queens.yaml |
Oleksii Zhurba | ca05017 | 2018-07-30 11:53:32 -0500 | [diff] [blame] | 182 | # If Opencontrail is deployed, use this command |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 183 | #cat $current_path/cvp-configuration/tempest/skip-list-oc4.yaml >> $current_path/cvp-configuration/tempest/skip-list-queens.yaml |
| 184 | #cat $current_path/cvp-configuration/tempest/skip-list-heat.yaml >> $current_path/cvp-configuration/tempest/skip-list-queens.yaml |
Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 185 | rally verify configure-verifier --extend $current_path/cvp-configuration/tempest/tempest_ext.conf |
Oleksii Zhurba | 991dbc6 | 2018-07-25 16:03:51 -0500 | [diff] [blame] | 186 | rally verify configure-verifier --show |
Oleksii Zhurba | ca05017 | 2018-07-30 11:53:32 -0500 | [diff] [blame] | 187 | # If Barbican tempest plugin is installed, use this |
dtsapikov | 17da9c2 | 2019-09-03 13:39:34 +0400 | [diff] [blame] | 188 | #mkdir /etc/tempest |
| 189 | #rally verify configure-verifier --show | grep -v "rally.api" > /etc/tempest/tempest.conf |
Oleksii Zhurba | 7f3941b | 2018-03-27 14:38:42 -0500 | [diff] [blame] | 190 | # Add 2 additional tempest tests (live migration to all nodes + ssh to all nodes) |
| 191 | # TBD |
| 192 | #cat tempest/test_extension.py >> repo/tempest/scenario/test_server_multinode.py |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 193 | fi |
| 194 | set -e |
| 195 | |
Oleksii Zhurba | c8058d6 | 2018-06-21 17:46:11 -0500 | [diff] [blame] | 196 | echo "Configuration is done!" |