blob: 2b33ff1fd4ee305b7d31b3543198f62b5a60a2ba [file] [log] [blame]
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06001#!/bin/bash
Sergey Galkin2b0cea62019-11-07 18:45:15 +04002
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06003variables=(
4OS_USERNAME
5OS_PASSWORD
6OS_TENANT_NAME
7OS_AUTH_URL
8)
9
10check_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 Zhurbac8058d62018-06-21 17:46:11 -050017 ip=$(echo ${OS_AUTH_URL} | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/')
18 export no_proxy=$ip
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060019}
20
21rally_configuration () {
Oleksii Zhurbac7d07842019-05-23 19:32:14 -050022 if [ "$PROXY" != "offline" ]; then
23 if [ -n "${PROXY}" ]; then
24 export http_proxy=$PROXY
25 export https_proxy=$PROXY
26 fi
27 pip install --force-reinstall python-glanceclient==2.11
28 apt-get update; apt-get install -y iputils-ping curl wget
29 unset http_proxy
30 unset https_proxy
31 fi
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060032 sub_name=`date "+%H_%M_%S"`
Oleksii Zhurba12ff95b2019-05-30 17:03:54 -050033 # remove dashes from rally user passwords to fit into 32 char limit
34 sed -i 's/uuid4())/uuid4()).replace("-","")/g' /usr/local/lib/python2.7/dist-packages/rally/plugins/openstack/scenarios/keystone/utils.py
35 sed -i 's/uuid4())/uuid4()).replace("-","")/g' /usr/local/lib/python2.7/dist-packages/rally/plugins/openstack/context/keystone/users.py
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060036 rally deployment create --fromenv --name=tempest_$sub_name
Oleksii Zhurba4be28322019-04-18 18:07:35 -050037 echo "[openstack]" >> /etc/rally/rally.conf
38 echo "pre_newton_neutron=True" >> /etc/rally/rally.conf
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060039}
40
Alex Savatieiev719c7612019-07-24 13:33:47 -050041update_cacerts () {
Oleksii Zhurba88375f32019-07-26 16:04:44 -050042 # configuring certificates file
43 if [ -z ${OS_CACERT+x} ]; then
Alex Savatieievc13c8dd2019-10-25 13:34:13 -050044 echo "# No OS_CACERT is set, update of crt file skipped"
Oleksii Zhurba88375f32019-07-26 16:04:44 -050045 else
Alex Savatieievc13c8dd2019-10-25 13:34:13 -050046 echo "# Adding custom certificates"
Oleksii Zhurba88375f32019-07-26 16:04:44 -050047 ca=( $(find ${1} -name cacert.pem) )
48 for crt in ${ca[@]}; do
49 cat ${OS_CACERT} >>${crt}
Alex Savatieievc13c8dd2019-10-25 13:34:13 -050050 echo "-> ${crt}"
Oleksii Zhurba88375f32019-07-26 16:04:44 -050051 done
52 fi
Alex Savatieiev719c7612019-07-24 13:33:47 -050053}
54
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060055tempest_configuration () {
56 sub_name=`date "+%H_%M_%S"`
Oleksii Zhurba33671b62019-02-21 17:55:22 -060057 # default tempest version is 18.0.0 now, unless
Oleksii Zhurbad85b0022018-09-11 15:43:43 -050058 # it is explicitly defined in pipelines
59 if [ "$tempest_version" == "" ]; then
Alex83075ac2022-02-16 13:39:50 -060060 tempest_version='master'
Oleksii Zhurbad85b0022018-09-11 15:43:43 -050061 fi
Oleksii Zhurba991dbc62018-07-25 16:03:51 -050062 if [ "$PROXY" == "offline" ]; then
Oleksii Zhurbac8058d62018-06-21 17:46:11 -050063 rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_REPO --system-wide --version $tempest_version
Oleksii Zhurba33671b62019-02-21 17:55:22 -060064 #rally verify add-verifier-ext --source /var/lib/telemetry-tempest-plugin
Oleksii Zhurba991dbc62018-07-25 16:03:51 -050065 rally verify add-verifier-ext --source /var/lib/heat-tempest-plugin
Alex Savatieiev719c7612019-07-24 13:33:47 -050066 update_cacerts "/usr/local/lib"
Oleksii Zhurbac8058d62018-06-21 17:46:11 -050067 else
68 if [ -n "${PROXY}" ]; then
69 export https_proxy=$PROXY
70 fi
71 rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_REPO --version $tempest_version
Oleksii Zhurba33671b62019-02-21 17:55:22 -060072 #rally verify add-verifier-ext --version 7a4bff728fbd8629ec211669264ab645aa921e2b --source https://github.com/openstack/telemetry-tempest-plugin
73 rally verify add-verifier-ext --version 0.2.0 --source https://github.com/openstack/heat-tempest-plugin
Oleksii Zhurba8b76f3d2018-08-07 12:38:26 -050074 pip install --force-reinstall python-cinderclient==3.2.0
Oleksii Zhurbac8058d62018-06-21 17:46:11 -050075 unset https_proxy
Alex Savatieiev719c7612019-07-24 13:33:47 -050076 update_cacerts "/home/rally/.rally/verification"
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060077 fi
Oleksii Zhurba12ff95b2019-05-30 17:03:54 -050078 # set password length to 32
79 data_utils_path=`find /home/rally/.rally/verification/ -name data_utils.py`
80 sed -i 's/length=15/length=32/g' $data_utils_path
Alex Savatieiev719c7612019-07-24 13:33:47 -050081
Oleksii Zhurba991dbc62018-07-25 16:03:51 -050082 # supress tempest.conf display in console
83 #rally verify configure-verifier --show
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060084}
85
Oleksii Zhurba24cdf082019-07-17 14:55:05 -050086glance_image() {
87current_path=$(pwd)
88# fetch image with exact name: testvm
Alexdb7786b2022-02-21 17:58:29 -060089IMAGE_NAME=cvp.cirros.51
90IMAGE_NAME2=cvp.cirros.52
Alex83075ac2022-02-16 13:39:50 -060091IMAGE_REF=$(glance image-list | grep "\b${IMAGE_NAME}\b" | awk '{print $2}')
Oleksii Zhurba88375f32019-07-26 16:04:44 -050092IMAGE_REF2=$(glance image-list | grep "\b${IMAGE_NAME2}\b" | awk '{print $2}')
Oleksii Zhurba24cdf082019-07-17 14:55:05 -050093if [ "${IMAGE_REF2}" == "" ]; then
Alexdb7786b2022-02-21 17:58:29 -060094 imagefile51=cirros-0.5.1-x86_64-disk.img
95 imagefile52=cirros-0.5.2-x86_64-disk.img
96 imageurl51=https://download.cirros-cloud.net/0.5.1/${imagefile51}
97 imageurl52=https://download.cirros-cloud.net/0.5.2/${imagefile52}
98 imagepath51=$current_path/cvp-configuration/${imagefile51}
99 imagepath52=$current_path/cvp-configuration/${imagefile52}
Oleksii Zhurba24cdf082019-07-17 14:55:05 -0500100 if [ "$PROXY" != "offline" ]; then
101 if [ -n "${PROXY}" ]; then
102 export http_proxy=$PROXY
103 export https_proxy=$PROXY
104 fi
Alexdb7786b2022-02-21 17:58:29 -0600105 ls ${imagepath51} || wget ${imageurl51} -O ${imagepath51}
106 ls ${imagepath52} || wget ${imageurl52} -O ${imagepath52}
Oleksii Zhurba24cdf082019-07-17 14:55:05 -0500107 unset http_proxy
108 unset https_proxy
109 fi
Alexdb7786b2022-02-21 17:58:29 -0600110 # v5.1
111 if [ -e $current_path/cvp-configuration/${imagefile51} ]; then
112 echo "MD5 for the file is:"
113 md5sum ${imagepath51}
114 glance image-create --name=${IMAGE_NAME} --visibility=public --container-format=bare --disk-format=qcow2 < ${imagepath51}
115 IMAGE_REF=$(glance image-list | grep "\b${IMAGE_NAME}\b" | awk '{print $2}')
116 else
117 echo "Cirros image v5.1 was not downloaded! Some tests may fail"
118 IMAGE_REF=""
119 fi
120 # v5.2
121 if [ -e $current_path/cvp-configuration/${imagefile52} ]; then
122 echo "MD5 for the file is:"
123 md5sum ${imagepath52}
124 glance image-create --name=${IMAGE_NAME2} --visibility=public --container-format=bare --disk-format=qcow2 < ${imagepath52}
Oleksii Zhurba88375f32019-07-26 16:04:44 -0500125 IMAGE_REF2=$(glance image-list | grep "\b${IMAGE_NAME2}\b" | awk '{print $2}')
Oleksii Zhurba24cdf082019-07-17 14:55:05 -0500126 else
Alexdb7786b2022-02-21 17:58:29 -0600127 echo "Cirros image v5.2 was not downloaded! Some tests may fail"
Oleksii Zhurba24cdf082019-07-17 14:55:05 -0500128 IMAGE_REF2=""
129 fi
Alexdb7786b2022-02-21 17:58:29 -0600130
Oleksii Zhurba24cdf082019-07-17 14:55:05 -0500131fi
Alex83075ac2022-02-16 13:39:50 -0600132
133sed -i 's/${IMAGE_REF}/'$IMAGE_REF'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba24cdf082019-07-17 14:55:05 -0500134sed -i 's/${IMAGE_REF2}/'$IMAGE_REF2'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Alex83075ac2022-02-16 13:39:50 -0600135sed -i 's/${IMAGE_NAME}/'$IMAGE_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Alex Savatieiev719c7612019-07-24 13:33:47 -0500136sed -i 's/${IMAGE_NAME2}/'$IMAGE_NAME2'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba24cdf082019-07-17 14:55:05 -0500137}
138
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600139quick_configuration () {
140current_path=$(pwd)
141#image
Oleksii Zhurba24cdf082019-07-17 14:55:05 -0500142glance_image
Alexdb7786b2022-02-21 17:58:29 -0600143
144#flavors for rally
145nova flavor-list | grep cvp.tiny 2>&1 >/dev/null || {
146 echo "Let's create cvp.tiny flavor"
147 #nova flavor-create --is-public true m1.tiny auto 128 1 1
148 openstack flavor create --id 1 --ram 64 --disk 1 --vcpus 1 cvp.tiny
Oleksii Zhurba0aa46702018-02-07 16:17:39 -0600149}
Alexdb7786b2022-02-21 17:58:29 -0600150nova flavor-list | grep cvp.small 2>&1 >/dev/null || {
151 echo "Let's create cvp.small flavor"
152 openstack flavor create --id 2 --ram 256 --disk 2 --vcpus 1 cvp.small
153}
154
155
Oleksii Zhurba0aa46702018-02-07 16:17:39 -0600156#shared fixed network
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500157shared_count=`neutron net-list -c name -c shared | grep True | grep "fixed-net" | wc -l`
Oleksii Zhurba0aa46702018-02-07 16:17:39 -0600158if [ $shared_count -eq 0 ]; then
159 echo "Let's create shared fixed net"
Oleksii Zhurbaa2770002018-08-07 11:25:56 -0500160 neutron net-create --shared fixed-net
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500161 FIXED_NET_ID=$(neutron net-list -c id -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1)
162 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 Zhurba0aa46702018-02-07 16:17:39 -0600163fi
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500164fixed_count=`neutron net-list | grep "fixed-net" | wc -l`
165if [ $fixed_count -gt 1 ]; then
166 echo "TOO MANY NETWORKS WITH fixed-net NAME! This may affect tests. Please review your network list."
167fi
168# public/floating net
169PUBLIC_NET=$(neutron net-list -c name -c router:external | grep True | awk '{print $2}' | tail -n 1)
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500170FIXED_NET=$(neutron net-list -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1)
171FIXED_NET_ID=$(neutron net-list -c id -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1)
172FIXED_SUBNET_ID=$(neutron net-show $FIXED_NET_ID -c subnets | grep subnets | awk '{print $4}')
173FIXED_SUBNET_NAME=$(neutron subnet-show -c name $FIXED_SUBNET_ID | grep name | awk '{print $4}')
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500174echo "Public net name is $PUBLIC_NET"
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500175echo "Fixed net name is $FIXED_NET, id is $FIXED_NET_ID"
176echo "Fixed subnet is: $FIXED_SUBNET_ID, name: $FIXED_SUBNET_NAME"
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500177sed -i 's/${FIXED_NET}/'$FIXED_NET_ID'/g' $current_path/cvp-configuration/rally/rally_scenarios.json
178sed -i 's/${FIXED_NET}/'$FIXED_NET_ID'/g' $current_path/cvp-configuration/rally/rally_scenarios_100.json
179sed -i 's/${FIXED_NET}/'$FIXED_NET_ID'/g' $current_path/cvp-configuration/rally/rally_scenarios_fip_and_ubuntu.json
180sed -i 's/${FIXED_NET}/'$FIXED_NET_ID'/g' $current_path/cvp-configuration/rally/rally_scenarios_fip_and_ubuntu_100.json
Oleksii Zhurba0aa46702018-02-07 16:17:39 -0600181sed -i 's/${FIXED_NET}/'$FIXED_NET'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500182sed -i 's/${FIXED_SUBNET_NAME}/'$FIXED_SUBNET_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba080efa22018-11-12 13:05:44 -0600183sed -i 's/${OS_USERNAME}/'$OS_USERNAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
184sed -i 's/${OS_TENANT_NAME}/'$OS_TENANT_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
185sed -i 's/${OS_REGION_NAME}/'$OS_REGION_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
186sed -i 's|${OS_AUTH_URL}|'"${OS_AUTH_URL}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf
187sed -i 's|${OS_PASSWORD}|'"${OS_PASSWORD}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500188sed -i 's|${PUBLIC_NET}|'"${PUBLIC_NET}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600189sed -i 's/publicURL/'$TEMPEST_ENDPOINT_TYPE'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba991dbc62018-07-25 16:03:51 -0500190#supress tempest.conf display in console
191#cat $current_path/cvp-configuration/tempest/tempest_ext.conf
192cp $current_path/cvp-configuration/tempest/boot_config_none_env.yaml /home/rally/boot_config_none_env.yaml
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500193cp $current_path/cvp-configuration/rally/default.yaml.template /home/rally/default.yaml.template
194cp $current_path/cvp-configuration/rally/instance_test.sh /home/rally/instance_test.sh
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500195cp $current_path/cvp-configuration/cleanup.sh /home/rally/cleanup.sh
Oleksii Zhurbac7d07842019-05-23 19:32:14 -0500196chmod 755 /home/rally/cleanup.sh
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600197}
198
Oleksii Zhurbaba5883f2018-01-18 09:52:08 -0600199if [ "$1" == "reconfigure" ]; then
200 echo "This is reconfiguration"
201 rally verify configure-verifier --reconfigure
Oleksii Zhurbac8058d62018-06-21 17:46:11 -0500202 rally verify configure-verifier --extend $current_path/cvp-configuration/tempest/tempest_ext.conf
Sergey Galkin2b0cea62019-11-07 18:45:15 +0400203 rally verify configure-verifier
Oleksii Zhurbaba5883f2018-01-18 09:52:08 -0600204 exit 0
205fi
206
Oleksii Zhurba1580fc52017-11-14 15:20:44 -0600207check_variables
208rally_configuration
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500209quick_configuration
Oleksii Zhurba0aa46702018-02-07 16:17:39 -0600210if [ -n "${TEMPEST_REPO}" ]; then
Oleksii Zhurba1580fc52017-11-14 15:20:44 -0600211 tempest_configuration
Oleksii Zhurba33671b62019-02-21 17:55:22 -0600212 # If you do not have fip network, use this command
213 #cat $current_path/cvp-configuration/tempest/skip-list-fip-only.yaml >> $current_path/cvp-configuration/tempest/skip-list-queens.yaml
Oleksii Zhurbaca050172018-07-30 11:53:32 -0500214 # If Opencontrail is deployed, use this command
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500215 #cat $current_path/cvp-configuration/tempest/skip-list-oc4.yaml >> $current_path/cvp-configuration/tempest/skip-list-queens.yaml
216 #cat $current_path/cvp-configuration/tempest/skip-list-heat.yaml >> $current_path/cvp-configuration/tempest/skip-list-queens.yaml
Oleksii Zhurbac8058d62018-06-21 17:46:11 -0500217 rally verify configure-verifier --extend $current_path/cvp-configuration/tempest/tempest_ext.conf
Sergey Galkin2b0cea62019-11-07 18:45:15 +0400218 rally verify configure-verifier
Oleksii Zhurbaca050172018-07-30 11:53:32 -0500219 # If Barbican tempest plugin is installed, use this
Oleksii Zhurba33671b62019-02-21 17:55:22 -0600220 #mkdir /etc/tempest
221 #rally verify configure-verifier --show | grep -v "rally.api" > /etc/tempest/tempest.conf
Oleksii Zhurba7f3941b2018-03-27 14:38:42 -0500222 # Add 2 additional tempest tests (live migration to all nodes + ssh to all nodes)
223 # TBD
224 #cat tempest/test_extension.py >> repo/tempest/scenario/test_server_multinode.py
Oleksii Zhurba1580fc52017-11-14 15:20:44 -0600225fi
226set -e
227
Oleksii Zhurbac8058d62018-06-21 17:46:11 -0500228echo "Configuration is done!"