blob: 5cdb5e3eb5d94ce44f95db9f8a075273fc90887b [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.
Alexb00fee12022-02-17 14:20:04 -06008now=$(date +'%m-%d-%Y')
9IMAGE=260d1328-5ed0-4e54-a79c-26c98a92ecc9
10FLAVOR=033b82cb-b39f-466c-96c8-cf7c4e910932
11NETWORK=bd76e0b4-e707-4456-905d-834035f8c8e5
12FIP_NET=f424e52d-eefc-4a8c-b51f-490d79a4127b
Nikolay Pliashechnykov316823e2020-08-14 15:44:50 +010013KEY=qa-lb-kp
Alexb00fee12022-02-17 14:20:04 -060014SGID=1b53d9e0-c62f-4e2a-b942-3dd2fb356337
Nikolay Pliashechnykov316823e2020-08-14 15:44:50 +010015PROTO=TCP
16PORT=22
Alexb00fee12022-02-17 14:20:04 -060017LBNAME=qa-testlb-${now}
Nikolay Pliashechnykov316823e2020-08-14 15:44:50 +010018echo "Spawning the pool VMs"
Alexb00fee12022-02-17 14:20:04 -060019openstack server create lb-1-${LBNAME} --image ${IMAGE} --flavor ${FLAVOR} --key ${KEY} --nic net-id=${NETWORK} --security-group ${SGID}
20openstack server create lb-2-${LBNAME} --image ${IMAGE} --flavor ${FLAVOR} --key ${KEY} --nic net-id=${NETWORK} --security-group ${SGID}
21openstack server create lb-3-${LBNAME} --image ${IMAGE} --flavor ${FLAVOR} --key ${KEY} --nic net-id=${NETWORK} --security-group ${SGID}
Nikolay Pliashechnykov316823e2020-08-14 15:44:50 +010022echo "Obtaining the service subnet ID"
23SUBNET=`openstack network show ${NETWORK} | grep subnets | awk '{print $4}'`
24echo "Creating the load balancer"
Alexb00fee12022-02-17 14:20:04 -060025#neutron lbaas-loadbalancer-create --name ${LBNAME} ${SUBNET}
26openstack loadbalancer create --name ${LBNAME} --vip-subnet-id ${SUBNET}
27#LB=`neutron lbaas-loadbalancer-list | grep ${LBNAME} | awk '{print $2}'`
28LB=`openstack loadbalancer list | grep ${LBNAME} | awk '{print $2}'`
Nikolay Pliashechnykov316823e2020-08-14 15:44:50 +010029echo "Obtaining the LB VIP port and adding the permissive security group"
Alexb00fee12022-02-17 14:20:04 -060030#LB_PORT=`neutron lbaas-loadbalancer-show ${LB} | grep 'port_id' | awk '{print $4}'`
31LB_PORT=`openstack loadbalancer show ${LB} | grep 'port_id' | awk '{print $4}'`
Nikolay Pliashechnykov316823e2020-08-14 15:44:50 +010032neutron port-update ${LB_PORT} --no-security-groups
33neutron port-update ${LB_PORT} --security-group ${SGID}
34echo "Creating the LB listener and pool"
Alexb00fee12022-02-17 14:20:04 -060035#LISTENER=`neutron lbaas-listener-create --loadbalancer ${LB} --protocol ${PROTO} --protocol-port ${PORT} --name ${LBNAME}-listener | grep '\ id' | awk '{print $4}'`
36LISTENER=`openstack loadbalancer listener create --protocol ${PROTO} --protocol-port ${PORT} --name ${LBNAME}-listener ${LB} | grep '\ id' | awk '{print $4}'`
37#POOL=`neutron lbaas-pool-create --listener ${LISTENER} --protocol ${PROTO} --name ${LBNAME}-pool --lb-algorithm ROUND_ROBIN | grep '\ id' | awk '{print $4}'`
38POOL=`openstack loadbalancer pool create --listener ${LISTENER} --protocol ${PROTO} --name ${LBNAME}-pool --lb-algorithm ROUND_ROBIN | grep '\ id' | awk '{print $4}'`
Nikolay Pliashechnykov316823e2020-08-14 15:44:50 +010039echo "Obtaining the fixed IP addresses for the pool VMs"
Alexb00fee12022-02-17 14:20:04 -060040IP1=`openstack server show lb-1-${LBNAME} | grep addresses | awk '{print $4}' | cut -d '=' -f 2`
41IP2=`openstack server show lb-2-${LBNAME} | grep addresses | awk '{print $4}' | cut -d '=' -f 2`
42IP3=`openstack server show lb-3-${LBNAME} | grep addresses | awk '{print $4}' | cut -d '=' -f 2`
Nikolay Pliashechnykov316823e2020-08-14 15:44:50 +010043echo "Adding the VMs to the pool"
Alexb00fee12022-02-17 14:20:04 -060044#neutron lbaas-member-create --protocol-port ${PORT} ${POOL} --subnet ${SUBNET} --address ${IP1}
45#neutron lbaas-member-create --protocol-port ${PORT} ${POOL} --subnet ${SUBNET} --address ${IP2}
46#neutron lbaas-member-create --protocol-port ${PORT} ${POOL} --subnet ${SUBNET} --address ${IP3}
47openstack loadbalancer member create --protocol-port ${PORT} --subnet-id ${SUBNET} --address ${IP1} ${POOL}
48openstack loadbalancer member create --protocol-port ${PORT} --subnet-id ${SUBNET} --address ${IP2} ${POOL}
49openstack loadbalancer member create --protocol-port ${PORT} --subnet-id ${SUBNET} --address ${IP3} ${POOL}
Nikolay Pliashechnykov316823e2020-08-14 15:44:50 +010050echo "Associating the floating IP with the LB VIP"
Alexb00fee12022-02-17 14:20:04 -060051#FIP_ID=(neutron floatingip-create ${FIP_NET} | grep '\ id' | awk '{print $4}')
52FIP_ID=$(neutron floatingip-show ${FIP_ID} | grep floating_ip_address | awk '{print $4}')
Nikolay Pliashechnykov316823e2020-08-14 15:44:50 +010053neutron floatingip-associate ${FIP_ID} ${LB_PORT}
54FIP_IP=`neutron floatingip-show ${FIP_ID} | grep address | awk '{print $4}'`
55echo Load balancer is up with the floating IP ${FIP_IP}:${PORT}, protocol ${PROTO}. Press Enter for LB decommissioning.
56read _
57neutron lbaas-member-list ${POOL} | grep ${SUBNET} | awk -v pool=${POOL} '{system("neutron lbaas-member-delete " $2 " " pool)}'
58neutron lbaas-pool-delete ${POOL}
59neutron lbaas-listener-delete ${LISTENER}
60neutron lbaas-loadbalancer-delete ${LB}
61neutron floatingip-delete ${FIP_ID}
Alexb00fee12022-02-17 14:20:04 -060062openstack server delete lb-1-${LBNAME}
63openstack server delete lb-2-${LBNAME}
64openstack server delete lb-3-${LBNAME}