blob: 870e71fd4d53b49f14bc4aba1dad5b2887b7315a [file] [log] [blame]
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06001#!/bin/bash
Alex Savatieiev719c7612019-07-24 13:33:47 -05002
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
37 rally deployment config
Oleksii Zhurba4be28322019-04-18 18:07:35 -050038 echo "[openstack]" >> /etc/rally/rally.conf
39 echo "pre_newton_neutron=True" >> /etc/rally/rally.conf
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060040}
41
Alex Savatieiev719c7612019-07-24 13:33:47 -050042update_cacerts () {
Oleksii Zhurba88375f32019-07-26 16:04:44 -050043 # configuring certificates file
44 if [ -z ${OS_CACERT+x} ]; then
Alex Savatieievc13c8dd2019-10-25 13:34:13 -050045 echo "# No OS_CACERT is set, update of crt file skipped"
Oleksii Zhurba88375f32019-07-26 16:04:44 -050046 else
Alex Savatieievc13c8dd2019-10-25 13:34:13 -050047 echo "# Adding custom certificates"
Oleksii Zhurba88375f32019-07-26 16:04:44 -050048 ca=( $(find ${1} -name cacert.pem) )
49 for crt in ${ca[@]}; do
50 cat ${OS_CACERT} >>${crt}
Alex Savatieievc13c8dd2019-10-25 13:34:13 -050051 echo "-> ${crt}"
Oleksii Zhurba88375f32019-07-26 16:04:44 -050052 done
53 fi
Alex Savatieiev719c7612019-07-24 13:33:47 -050054}
55
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060056tempest_configuration () {
57 sub_name=`date "+%H_%M_%S"`
Oleksii Zhurba33671b62019-02-21 17:55:22 -060058 # default tempest version is 18.0.0 now, unless
Oleksii Zhurbad85b0022018-09-11 15:43:43 -050059 # it is explicitly defined in pipelines
60 if [ "$tempest_version" == "" ]; then
Oleksii Zhurba33671b62019-02-21 17:55:22 -060061 tempest_version='18.0.0'
Oleksii Zhurbad85b0022018-09-11 15:43:43 -050062 fi
Oleksii Zhurba991dbc62018-07-25 16:03:51 -050063 if [ "$PROXY" == "offline" ]; then
Oleksii Zhurbac8058d62018-06-21 17:46:11 -050064 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 -060065 #rally verify add-verifier-ext --source /var/lib/telemetry-tempest-plugin
Oleksii Zhurba991dbc62018-07-25 16:03:51 -050066 rally verify add-verifier-ext --source /var/lib/heat-tempest-plugin
Alex Savatieiev719c7612019-07-24 13:33:47 -050067 update_cacerts "/usr/local/lib"
Oleksii Zhurbac8058d62018-06-21 17:46:11 -050068 else
69 if [ -n "${PROXY}" ]; then
70 export https_proxy=$PROXY
71 fi
72 rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_REPO --version $tempest_version
Oleksii Zhurba33671b62019-02-21 17:55:22 -060073 #rally verify add-verifier-ext --version 7a4bff728fbd8629ec211669264ab645aa921e2b --source https://github.com/openstack/telemetry-tempest-plugin
74 rally verify add-verifier-ext --version 0.2.0 --source https://github.com/openstack/heat-tempest-plugin
Oleksii Zhurba8b76f3d2018-08-07 12:38:26 -050075 pip install --force-reinstall python-cinderclient==3.2.0
Oleksii Zhurbac8058d62018-06-21 17:46:11 -050076 unset https_proxy
Alex Savatieiev719c7612019-07-24 13:33:47 -050077 update_cacerts "/home/rally/.rally/verification"
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060078 fi
Oleksii Zhurba12ff95b2019-05-30 17:03:54 -050079 # set password length to 32
80 data_utils_path=`find /home/rally/.rally/verification/ -name data_utils.py`
81 sed -i 's/length=15/length=32/g' $data_utils_path
Alex Savatieiev719c7612019-07-24 13:33:47 -050082
Oleksii Zhurba991dbc62018-07-25 16:03:51 -050083 # supress tempest.conf display in console
84 #rally verify configure-verifier --show
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060085}
86
Oleksii Zhurba24cdf082019-07-17 14:55:05 -050087glance_image() {
88current_path=$(pwd)
89# fetch image with exact name: testvm
Alex Savatieiev719c7612019-07-24 13:33:47 -050090IMAGE_NAME2=testvm
Oleksii Zhurba88375f32019-07-26 16:04:44 -050091IMAGE_REF2=$(glance image-list | grep "\b${IMAGE_NAME2}\b" | awk '{print $2}')
Oleksii Zhurba24cdf082019-07-17 14:55:05 -050092if [ "${IMAGE_REF2}" == "" ]; then
93 if [ "$PROXY" != "offline" ]; then
94 if [ -n "${PROXY}" ]; then
95 export http_proxy=$PROXY
96 export https_proxy=$PROXY
97 fi
98 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
99 unset http_proxy
100 unset https_proxy
101 fi
102 if [ -e $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img ]; then
103 echo "MD5 should be ee1eca47dc88f4879d8a229cc70a07c6"
104 md5sum $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img
Alex Savatieiev719c7612019-07-24 13:33:47 -0500105 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
Oleksii Zhurba88375f32019-07-26 16:04:44 -0500106 IMAGE_REF2=$(glance image-list | grep "\b${IMAGE_NAME2}\b" | awk '{print $2}')
Oleksii Zhurba24cdf082019-07-17 14:55:05 -0500107 else
108 echo "Cirros image was not downloaded! Some tests may fail"
109 IMAGE_REF2=""
110 fi
111fi
112sed -i 's/${IMAGE_REF2}/'$IMAGE_REF2'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Alex Savatieiev719c7612019-07-24 13:33:47 -0500113sed -i 's/${IMAGE_NAME2}/'$IMAGE_NAME2'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba24cdf082019-07-17 14:55:05 -0500114}
115
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600116quick_configuration () {
117current_path=$(pwd)
118#image
Oleksii Zhurba24cdf082019-07-17 14:55:05 -0500119glance_image
Oleksii Zhurba0aa46702018-02-07 16:17:39 -0600120#flavor for rally
121nova flavor-list | grep tiny 2>&1 >/dev/null || {
122 echo "Let's create m1.tiny flavor"
123 nova flavor-create --is-public true m1.tiny auto 128 1 1
124}
125#shared fixed network
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500126shared_count=`neutron net-list -c name -c shared | grep True | grep "fixed-net" | wc -l`
Oleksii Zhurba0aa46702018-02-07 16:17:39 -0600127if [ $shared_count -eq 0 ]; then
128 echo "Let's create shared fixed net"
Oleksii Zhurbaa2770002018-08-07 11:25:56 -0500129 neutron net-create --shared fixed-net
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500130 FIXED_NET_ID=$(neutron net-list -c id -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1)
131 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 -0600132fi
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500133fixed_count=`neutron net-list | grep "fixed-net" | wc -l`
134if [ $fixed_count -gt 1 ]; then
135 echo "TOO MANY NETWORKS WITH fixed-net NAME! This may affect tests. Please review your network list."
136fi
137# public/floating net
138PUBLIC_NET=$(neutron net-list -c name -c router:external | grep True | awk '{print $2}' | tail -n 1)
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500139FIXED_NET=$(neutron net-list -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1)
140FIXED_NET_ID=$(neutron net-list -c id -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1)
141FIXED_SUBNET_ID=$(neutron net-show $FIXED_NET_ID -c subnets | grep subnets | awk '{print $4}')
142FIXED_SUBNET_NAME=$(neutron subnet-show -c name $FIXED_SUBNET_ID | grep name | awk '{print $4}')
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500143echo "Public net name is $PUBLIC_NET"
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500144echo "Fixed net name is $FIXED_NET, id is $FIXED_NET_ID"
145echo "Fixed subnet is: $FIXED_SUBNET_ID, name: $FIXED_SUBNET_NAME"
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500146sed -i 's/${FIXED_NET}/'$FIXED_NET_ID'/g' $current_path/cvp-configuration/rally/rally_scenarios.json
147sed -i 's/${FIXED_NET}/'$FIXED_NET_ID'/g' $current_path/cvp-configuration/rally/rally_scenarios_100.json
148sed -i 's/${FIXED_NET}/'$FIXED_NET_ID'/g' $current_path/cvp-configuration/rally/rally_scenarios_fip_and_ubuntu.json
149sed -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 -0600150sed -i 's/${FIXED_NET}/'$FIXED_NET'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500151sed -i 's/${FIXED_SUBNET_NAME}/'$FIXED_SUBNET_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba080efa22018-11-12 13:05:44 -0600152sed -i 's/${OS_USERNAME}/'$OS_USERNAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
153sed -i 's/${OS_TENANT_NAME}/'$OS_TENANT_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
154sed -i 's/${OS_REGION_NAME}/'$OS_REGION_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
155sed -i 's|${OS_AUTH_URL}|'"${OS_AUTH_URL}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf
156sed -i 's|${OS_PASSWORD}|'"${OS_PASSWORD}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500157sed -i 's|${PUBLIC_NET}|'"${PUBLIC_NET}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600158sed -i 's/publicURL/'$TEMPEST_ENDPOINT_TYPE'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba991dbc62018-07-25 16:03:51 -0500159#supress tempest.conf display in console
160#cat $current_path/cvp-configuration/tempest/tempest_ext.conf
161cp $current_path/cvp-configuration/tempest/boot_config_none_env.yaml /home/rally/boot_config_none_env.yaml
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500162cp $current_path/cvp-configuration/rally/default.yaml.template /home/rally/default.yaml.template
163cp $current_path/cvp-configuration/rally/instance_test.sh /home/rally/instance_test.sh
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500164cp $current_path/cvp-configuration/cleanup.sh /home/rally/cleanup.sh
Oleksii Zhurbac7d07842019-05-23 19:32:14 -0500165chmod 755 /home/rally/cleanup.sh
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600166}
167
Oleksii Zhurbaba5883f2018-01-18 09:52:08 -0600168if [ "$1" == "reconfigure" ]; then
169 echo "This is reconfiguration"
170 rally verify configure-verifier --reconfigure
Oleksii Zhurbac8058d62018-06-21 17:46:11 -0500171 rally verify configure-verifier --extend $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurbaba5883f2018-01-18 09:52:08 -0600172 rally verify configure-verifier --show
173 exit 0
174fi
175
Oleksii Zhurba1580fc52017-11-14 15:20:44 -0600176check_variables
177rally_configuration
Oleksii Zhurba4be28322019-04-18 18:07:35 -0500178quick_configuration
Oleksii Zhurba0aa46702018-02-07 16:17:39 -0600179if [ -n "${TEMPEST_REPO}" ]; then
Oleksii Zhurba1580fc52017-11-14 15:20:44 -0600180 tempest_configuration
Oleksii Zhurba33671b62019-02-21 17:55:22 -0600181 # If you do not have fip network, use this command
182 #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 -0500183 # If Opencontrail is deployed, use this command
Oleksii Zhurba687e8952019-05-31 14:54:26 -0500184 #cat $current_path/cvp-configuration/tempest/skip-list-oc4.yaml >> $current_path/cvp-configuration/tempest/skip-list-queens.yaml
185 #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 -0500186 rally verify configure-verifier --extend $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba991dbc62018-07-25 16:03:51 -0500187 rally verify configure-verifier --show
Oleksii Zhurbaca050172018-07-30 11:53:32 -0500188 # If Barbican tempest plugin is installed, use this
Oleksii Zhurba33671b62019-02-21 17:55:22 -0600189 #mkdir /etc/tempest
190 #rally verify configure-verifier --show | grep -v "rally.api" > /etc/tempest/tempest.conf
Oleksii Zhurba7f3941b2018-03-27 14:38:42 -0500191 # Add 2 additional tempest tests (live migration to all nodes + ssh to all nodes)
192 # TBD
193 #cat tempest/test_extension.py >> repo/tempest/scenario/test_server_multinode.py
Oleksii Zhurba1580fc52017-11-14 15:20:44 -0600194fi
195set -e
196
Oleksii Zhurbac8058d62018-06-21 17:46:11 -0500197echo "Configuration is done!"