Nikolay Pliashechnykov | 316823e | 2020-08-14 15:44:50 +0100 | [diff] [blame] | 1 | #!/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. |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame^] | 8 | now=$(date +'%m-%d-%Y') |
| 9 | IMAGE=260d1328-5ed0-4e54-a79c-26c98a92ecc9 |
| 10 | FLAVOR=033b82cb-b39f-466c-96c8-cf7c4e910932 |
| 11 | NETWORK=bd76e0b4-e707-4456-905d-834035f8c8e5 |
| 12 | FIP_NET=f424e52d-eefc-4a8c-b51f-490d79a4127b |
Nikolay Pliashechnykov | 316823e | 2020-08-14 15:44:50 +0100 | [diff] [blame] | 13 | KEY=qa-lb-kp |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame^] | 14 | SGID=1b53d9e0-c62f-4e2a-b942-3dd2fb356337 |
Nikolay Pliashechnykov | 316823e | 2020-08-14 15:44:50 +0100 | [diff] [blame] | 15 | PROTO=TCP |
| 16 | PORT=22 |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame^] | 17 | LBNAME=qa-testlb-${now} |
Nikolay Pliashechnykov | 316823e | 2020-08-14 15:44:50 +0100 | [diff] [blame] | 18 | echo "Spawning the pool VMs" |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame^] | 19 | openstack server create lb-1-${LBNAME} --image ${IMAGE} --flavor ${FLAVOR} --key ${KEY} --nic net-id=${NETWORK} --security-group ${SGID} |
| 20 | openstack server create lb-2-${LBNAME} --image ${IMAGE} --flavor ${FLAVOR} --key ${KEY} --nic net-id=${NETWORK} --security-group ${SGID} |
| 21 | openstack server create lb-3-${LBNAME} --image ${IMAGE} --flavor ${FLAVOR} --key ${KEY} --nic net-id=${NETWORK} --security-group ${SGID} |
Nikolay Pliashechnykov | 316823e | 2020-08-14 15:44:50 +0100 | [diff] [blame] | 22 | echo "Obtaining the service subnet ID" |
| 23 | SUBNET=`openstack network show ${NETWORK} | grep subnets | awk '{print $4}'` |
| 24 | echo "Creating the load balancer" |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame^] | 25 | #neutron lbaas-loadbalancer-create --name ${LBNAME} ${SUBNET} |
| 26 | openstack loadbalancer create --name ${LBNAME} --vip-subnet-id ${SUBNET} |
| 27 | #LB=`neutron lbaas-loadbalancer-list | grep ${LBNAME} | awk '{print $2}'` |
| 28 | LB=`openstack loadbalancer list | grep ${LBNAME} | awk '{print $2}'` |
Nikolay Pliashechnykov | 316823e | 2020-08-14 15:44:50 +0100 | [diff] [blame] | 29 | echo "Obtaining the LB VIP port and adding the permissive security group" |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame^] | 30 | #LB_PORT=`neutron lbaas-loadbalancer-show ${LB} | grep 'port_id' | awk '{print $4}'` |
| 31 | LB_PORT=`openstack loadbalancer show ${LB} | grep 'port_id' | awk '{print $4}'` |
Nikolay Pliashechnykov | 316823e | 2020-08-14 15:44:50 +0100 | [diff] [blame] | 32 | neutron port-update ${LB_PORT} --no-security-groups |
| 33 | neutron port-update ${LB_PORT} --security-group ${SGID} |
| 34 | echo "Creating the LB listener and pool" |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame^] | 35 | #LISTENER=`neutron lbaas-listener-create --loadbalancer ${LB} --protocol ${PROTO} --protocol-port ${PORT} --name ${LBNAME}-listener | grep '\ id' | awk '{print $4}'` |
| 36 | LISTENER=`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}'` |
| 38 | POOL=`openstack loadbalancer pool create --listener ${LISTENER} --protocol ${PROTO} --name ${LBNAME}-pool --lb-algorithm ROUND_ROBIN | grep '\ id' | awk '{print $4}'` |
Nikolay Pliashechnykov | 316823e | 2020-08-14 15:44:50 +0100 | [diff] [blame] | 39 | echo "Obtaining the fixed IP addresses for the pool VMs" |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame^] | 40 | IP1=`openstack server show lb-1-${LBNAME} | grep addresses | awk '{print $4}' | cut -d '=' -f 2` |
| 41 | IP2=`openstack server show lb-2-${LBNAME} | grep addresses | awk '{print $4}' | cut -d '=' -f 2` |
| 42 | IP3=`openstack server show lb-3-${LBNAME} | grep addresses | awk '{print $4}' | cut -d '=' -f 2` |
Nikolay Pliashechnykov | 316823e | 2020-08-14 15:44:50 +0100 | [diff] [blame] | 43 | echo "Adding the VMs to the pool" |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame^] | 44 | #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} |
| 47 | openstack loadbalancer member create --protocol-port ${PORT} --subnet-id ${SUBNET} --address ${IP1} ${POOL} |
| 48 | openstack loadbalancer member create --protocol-port ${PORT} --subnet-id ${SUBNET} --address ${IP2} ${POOL} |
| 49 | openstack loadbalancer member create --protocol-port ${PORT} --subnet-id ${SUBNET} --address ${IP3} ${POOL} |
Nikolay Pliashechnykov | 316823e | 2020-08-14 15:44:50 +0100 | [diff] [blame] | 50 | echo "Associating the floating IP with the LB VIP" |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame^] | 51 | #FIP_ID=(neutron floatingip-create ${FIP_NET} | grep '\ id' | awk '{print $4}') |
| 52 | FIP_ID=$(neutron floatingip-show ${FIP_ID} | grep floating_ip_address | awk '{print $4}') |
Nikolay Pliashechnykov | 316823e | 2020-08-14 15:44:50 +0100 | [diff] [blame] | 53 | neutron floatingip-associate ${FIP_ID} ${LB_PORT} |
| 54 | FIP_IP=`neutron floatingip-show ${FIP_ID} | grep address | awk '{print $4}'` |
| 55 | echo Load balancer is up with the floating IP ${FIP_IP}:${PORT}, protocol ${PROTO}. Press Enter for LB decommissioning. |
| 56 | read _ |
| 57 | neutron lbaas-member-list ${POOL} | grep ${SUBNET} | awk -v pool=${POOL} '{system("neutron lbaas-member-delete " $2 " " pool)}' |
| 58 | neutron lbaas-pool-delete ${POOL} |
| 59 | neutron lbaas-listener-delete ${LISTENER} |
| 60 | neutron lbaas-loadbalancer-delete ${LB} |
| 61 | neutron floatingip-delete ${FIP_ID} |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame^] | 62 | openstack server delete lb-1-${LBNAME} |
| 63 | openstack server delete lb-2-${LBNAME} |
| 64 | openstack server delete lb-3-${LBNAME} |