blob: f706dea1bc589cf5f01fd5c5edbcc9ed1ba0153d [file] [log] [blame]
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06001#!/bin/bash
2
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 Zhurbab810c9d2019-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 Zhurba93b35512019-05-30 17:03:54 -050033 # remove dashes from rally user passwords to fit into 32 char limit
Oleksii Zhurbaaab4e222019-05-31 14:54:26 -050034 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 Zhurba53cca042019-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
42tempest_configuration () {
43 sub_name=`date "+%H_%M_%S"`
Oleksii Zhurba33671b62019-02-21 17:55:22 -060044 # default tempest version is 18.0.0 now, unless
Oleksii Zhurbad85b0022018-09-11 15:43:43 -050045 # it is explicitly defined in pipelines
46 if [ "$tempest_version" == "" ]; then
Oleksii Zhurba33671b62019-02-21 17:55:22 -060047 tempest_version='18.0.0'
Oleksii Zhurbad85b0022018-09-11 15:43:43 -050048 fi
Oleksii Zhurba991dbc62018-07-25 16:03:51 -050049 if [ "$PROXY" == "offline" ]; then
Oleksii Zhurbac8058d62018-06-21 17:46:11 -050050 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 -060051 #rally verify add-verifier-ext --source /var/lib/telemetry-tempest-plugin
Oleksii Zhurba991dbc62018-07-25 16:03:51 -050052 rally verify add-verifier-ext --source /var/lib/heat-tempest-plugin
Oleksii Zhurbac8058d62018-06-21 17:46:11 -050053 else
54 if [ -n "${PROXY}" ]; then
55 export https_proxy=$PROXY
56 fi
57 rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_REPO --version $tempest_version
Oleksii Zhurba33671b62019-02-21 17:55:22 -060058 #rally verify add-verifier-ext --version 7a4bff728fbd8629ec211669264ab645aa921e2b --source https://github.com/openstack/telemetry-tempest-plugin
59 rally verify add-verifier-ext --version 0.2.0 --source https://github.com/openstack/heat-tempest-plugin
Oleksii Zhurba8b76f3d2018-08-07 12:38:26 -050060 pip install --force-reinstall python-cinderclient==3.2.0
Oleksii Zhurbac8058d62018-06-21 17:46:11 -050061 unset https_proxy
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060062 fi
Oleksii Zhurbafe0f68b2019-06-04 18:08:07 -050063 # set password length to 32
64 data_utils_path=`find /home/rally/.rally/verification/ -name data_utils.py`
65 sed -i 's/length=15/length=32/g' $data_utils_path
Oleksii Zhurba991dbc62018-07-25 16:03:51 -050066 # supress tempest.conf display in console
67 #rally verify configure-verifier --show
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060068}
69
Oleksii Zhurbab9133f72017-11-15 17:53:02 -060070quick_configuration () {
71current_path=$(pwd)
Oleksii Zhurba4a480a32018-07-31 22:21:47 -050072# Remove this if you use local gerrit cvp-configuration repo
73if [ "$PROXY" == "offline" ]; then
74 current_path=/var/lib
75fi
Oleksii Zhurbab9133f72017-11-15 17:53:02 -060076#image
Oleksii Zhurbafe6b5712018-06-14 13:05:00 -050077glance image-list | grep "\btestvm\b" 2>&1 >/dev/null || {
Oleksii Zhurbab810c9d2019-05-23 19:32:14 -050078 if [ -n "${PROXY}" ] && [ "$PROXY" != "offline" ]; then
Oleksii Zhurbab9133f72017-11-15 17:53:02 -060079 export http_proxy=$PROXY
80 fi
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060081 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 Zhurbab9133f72017-11-15 17:53:02 -060082 unset http_proxy
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060083 echo "MD5 should be ee1eca47dc88f4879d8a229cc70a07c6"
Oleksii Zhurbab9133f72017-11-15 17:53:02 -060084 md5sum $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img
Oleksii Zhurbafe6b5712018-06-14 13:05:00 -050085 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 Zhurbab9133f72017-11-15 17:53:02 -060086}
Oleksii Zhurbafe6b5712018-06-14 13:05:00 -050087IMAGE_REF2=$(glance image-list | grep 'testvm' | awk '{print $2}')
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060088#flavor for rally
89nova flavor-list | grep tiny 2>&1 >/dev/null || {
90 echo "Let's create m1.tiny flavor"
91 nova flavor-create --is-public true m1.tiny auto 128 1 1
92}
93#shared fixed network
Oleksii Zhurba43830462019-06-20 16:38:01 -050094shared_count=`neutron net-list -c name -c shared | grep True | grep "fixed-net" | wc -l`
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060095if [ $shared_count -eq 0 ]; then
96 echo "Let's create shared fixed net"
Oleksii Zhurbaa2770002018-08-07 11:25:56 -050097 neutron net-create --shared fixed-net
Oleksii Zhurba43830462019-06-20 16:38:01 -050098 FIXED_NET_ID=$(neutron net-list -c id -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1)
99 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
100fi
101fixed_count=`neutron net-list | grep "fixed-net" | wc -l`
102if [ $fixed_count -gt 1 ]; then
103 echo "TOO MANY NETWORKS WITH fixed-net NAME! This may affect tests. Please review your network list."
Oleksii Zhurba0aa46702018-02-07 16:17:39 -0600104fi
Oleksii Zhurbaaab4e222019-05-31 14:54:26 -0500105# public/floating net
106PUBLIC_NET=$(neutron net-list -c name -c router:external | grep True | awk '{print $2}' | tail -n 1)
Oleksii Zhurba53cca042019-04-18 18:07:35 -0500107FIXED_NET=$(neutron net-list -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1)
108FIXED_NET_ID=$(neutron net-list -c id -c name -c shared | grep "fixed-net" | grep True | awk '{print $2}' | tail -n 1)
109FIXED_SUBNET_ID=$(neutron net-show $FIXED_NET_ID -c subnets | grep subnets | awk '{print $4}')
110FIXED_SUBNET_NAME=$(neutron subnet-show -c name $FIXED_SUBNET_ID | grep name | awk '{print $4}')
Oleksii Zhurbaaab4e222019-05-31 14:54:26 -0500111echo "Public net name is $PUBLIC_NET"
Oleksii Zhurba53cca042019-04-18 18:07:35 -0500112echo "Fixed net name is $FIXED_NET, id is $FIXED_NET_ID"
113echo "Fixed subnet is: $FIXED_SUBNET_ID, name: $FIXED_SUBNET_NAME"
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600114sed -i 's/${IMAGE_REF2}/'$IMAGE_REF2'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba53cca042019-04-18 18:07:35 -0500115sed -i 's/${FIXED_NET}/'$FIXED_NET_ID'/g' $current_path/cvp-configuration/rally/rally_scenarios.json
116sed -i 's/${FIXED_NET}/'$FIXED_NET_ID'/g' $current_path/cvp-configuration/rally/rally_scenarios_100.json
117sed -i 's/${FIXED_NET}/'$FIXED_NET_ID'/g' $current_path/cvp-configuration/rally/rally_scenarios_fip_and_ubuntu.json
118sed -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 -0600119sed -i 's/${FIXED_NET}/'$FIXED_NET'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba53cca042019-04-18 18:07:35 -0500120sed -i 's/${FIXED_SUBNET_NAME}/'$FIXED_SUBNET_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba080efa22018-11-12 13:05:44 -0600121sed -i 's/${OS_USERNAME}/'$OS_USERNAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
122sed -i 's/${OS_TENANT_NAME}/'$OS_TENANT_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
123sed -i 's/${OS_REGION_NAME}/'$OS_REGION_NAME'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
124sed -i 's|${OS_AUTH_URL}|'"${OS_AUTH_URL}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf
125sed -i 's|${OS_PASSWORD}|'"${OS_PASSWORD}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurbaaab4e222019-05-31 14:54:26 -0500126sed -i 's|${PUBLIC_NET}|'"${PUBLIC_NET}"'|g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600127sed -i 's/publicURL/'$TEMPEST_ENDPOINT_TYPE'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba991dbc62018-07-25 16:03:51 -0500128#supress tempest.conf display in console
129#cat $current_path/cvp-configuration/tempest/tempest_ext.conf
130cp $current_path/cvp-configuration/tempest/boot_config_none_env.yaml /home/rally/boot_config_none_env.yaml
Oleksii Zhurba421c2182019-05-31 16:31:14 -0500131cp $current_path/cvp-configuration/rally/default.yaml.template /home/rally/default.yaml.template
Oleksii Zhurbaaab4e222019-05-31 14:54:26 -0500132cp $current_path/cvp-configuration/rally/instance_test.sh /home/rally/instance_test.sh
Oleksii Zhurba53cca042019-04-18 18:07:35 -0500133cp $current_path/cvp-configuration/cleanup.sh /home/rally/cleanup.sh
Oleksii Zhurbab810c9d2019-05-23 19:32:14 -0500134chmod 755 /home/rally/cleanup.sh
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600135}
136
Oleksii Zhurbaba5883f2018-01-18 09:52:08 -0600137if [ "$1" == "reconfigure" ]; then
138 echo "This is reconfiguration"
139 rally verify configure-verifier --reconfigure
Oleksii Zhurbac8058d62018-06-21 17:46:11 -0500140 rally verify configure-verifier --extend $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurbaba5883f2018-01-18 09:52:08 -0600141 rally verify configure-verifier --show
142 exit 0
143fi
144
Oleksii Zhurba1580fc52017-11-14 15:20:44 -0600145check_variables
146rally_configuration
Oleksii Zhurba53cca042019-04-18 18:07:35 -0500147quick_configuration
Oleksii Zhurba0aa46702018-02-07 16:17:39 -0600148if [ -n "${TEMPEST_REPO}" ]; then
Oleksii Zhurba1580fc52017-11-14 15:20:44 -0600149 tempest_configuration
Oleksii Zhurba33671b62019-02-21 17:55:22 -0600150 # If you do not have fip network, use this command
151 #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 -0500152 # If Opencontrail is deployed, use this command
Oleksii Zhurbaaab4e222019-05-31 14:54:26 -0500153 #cat $current_path/cvp-configuration/tempest/skip-list-oc4.yaml >> $current_path/cvp-configuration/tempest/skip-list-queens.yaml
154 #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 -0500155 rally verify configure-verifier --extend $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba991dbc62018-07-25 16:03:51 -0500156 rally verify configure-verifier --show
Oleksii Zhurbaca050172018-07-30 11:53:32 -0500157 # If Barbican tempest plugin is installed, use this
Oleksii Zhurba33671b62019-02-21 17:55:22 -0600158 #mkdir /etc/tempest
159 #rally verify configure-verifier --show | grep -v "rally.api" > /etc/tempest/tempest.conf
Oleksii Zhurba7f3941b2018-03-27 14:38:42 -0500160 # Add 2 additional tempest tests (live migration to all nodes + ssh to all nodes)
161 # TBD
162 #cat tempest/test_extension.py >> repo/tempest/scenario/test_server_multinode.py
Oleksii Zhurba1580fc52017-11-14 15:20:44 -0600163fi
164set -e
165
Oleksii Zhurbac8058d62018-06-21 17:46:11 -0500166echo "Configuration is done!"