blob: cdf439ac6121bc05a7ab2e4f0a1e983cd1aea972 [file] [log] [blame]
Nikolay Pliashechnykov316823e2020-08-14 15:44:50 +01001#!/bin/bash
2
3#A simple integration test that will allow you to check whether the LBaaS 2.0 integration is working on your cloud.
4#May require some minor tuning depending on the LB provider (i.e. specifying flavor, order of listener/pool creation etc)
5#Requires a project, permissive security group, tenant network, floating network, keypair and image/flavor to start the VM.
6
7#Testing of the load balancing is still manual. Start the test in screen, wait until the LB is up and then test it in another tab.
8IMAGE=6d989e06-493f-4f2d-9d07-81650fd04581
9FLAVOR=dfa1ecac-e8a9-408a-b93c-75077272e10e
10NETWORK=5435a882-32f0-4abf-b1f6-3f942f85c3e7
11FIP_NET=ee84f06b-be00-4295-a27a-4c6653e960ef
12KEY=qa-lb-kp
13SGID=008f8c20-133c-4ff8-9ae0-5d8de301b3e7
14PROTO=TCP
15PORT=22
16LBNAME=qa-testlb
17echo "Spawning the pool VMs"
18openstack server create lb-1 --image ${IMAGE} --flavor ${FLAVOR} --key ${KEY} --nic net-id=${NETWORK} --security-group ${SGID}
19openstack server create lb-2 --image ${IMAGE} --flavor ${FLAVOR} --key ${KEY} --nic net-id=${NETWORK} --security-group ${SGID}
20openstack server create lb-3 --image ${IMAGE} --flavor ${FLAVOR} --key ${KEY} --nic net-id=${NETWORK} --security-group ${SGID}
21echo "Obtaining the service subnet ID"
22SUBNET=`openstack network show ${NETWORK} | grep subnets | awk '{print $4}'`
23echo "Creating the load balancer"
24neutron lbaas-loadbalancer-create --name ${LBNAME} ${SUBNET}
25LB=`neutron lbaas-loadbalancer-list | grep ${LBNAME} | awk '{print $2}'`
26echo "Obtaining the LB VIP port and adding the permissive security group"
27LB_PORT=`neutron lbaas-loadbalancer-show ${LB} | grep 'port_id' | awk '{print $4}'`
28neutron port-update ${LB_PORT} --no-security-groups
29neutron port-update ${LB_PORT} --security-group ${SGID}
30echo "Creating the LB listener and pool"
31LISTENER=`neutron lbaas-listener-create --loadbalancer ${LB} --protocol ${PROTO} --protocol-port ${PORT} --name ${LBNAME}-listener | grep '\ id' | awk '{print $4}'`
32POOL=`neutron lbaas-pool-create --listener ${LISTENER} --protocol ${PROTO} --name ${LBNAME}-pool --lb-algorithm ROUND_ROBIN | grep '\ id' | awk '{print $4}'`
33echo "Obtaining the fixed IP addresses for the pool VMs"
34IP1=`openstack server show lb-1 | grep addresses | awk '{print $4}' | cut -d '=' -f 2`
35IP2=`openstack server show lb-2 | grep addresses | awk '{print $4}' | cut -d '=' -f 2`
36IP3=`openstack server show lb-3 | grep addresses | awk '{print $4}' | cut -d '=' -f 2`
37echo "Adding the VMs to the pool"
38neutron lbaas-member-create --protocol-port ${PORT} ${POOL} --subnet ${SUBNET} --address ${IP1}
39neutron lbaas-member-create --protocol-port ${PORT} ${POOL} --subnet ${SUBNET} --address ${IP2}
40neutron lbaas-member-create --protocol-port ${PORT} ${POOL} --subnet ${SUBNET} --address ${IP3}
41echo "Associating the floating IP with the LB VIP"
42FIP_ID=`neutron floatingip-create ${FIP_NET} | grep '\ id' | awk '{print $4}'`
43neutron floatingip-associate ${FIP_ID} ${LB_PORT}
44FIP_IP=`neutron floatingip-show ${FIP_ID} | grep address | awk '{print $4}'`
45echo Load balancer is up with the floating IP ${FIP_IP}:${PORT}, protocol ${PROTO}. Press Enter for LB decommissioning.
46read _
47neutron lbaas-member-list ${POOL} | grep ${SUBNET} | awk -v pool=${POOL} '{system("neutron lbaas-member-delete " $2 " " pool)}'
48neutron lbaas-pool-delete ${POOL}
49neutron lbaas-listener-delete ${LISTENER}
50neutron lbaas-loadbalancer-delete ${LB}
51neutron floatingip-delete ${FIP_ID}
52openstack server delete lb-1
53openstack server delete lb-2
54openstack server delete lb-3