Skip to content

Commit

Permalink
Merge pull request #271 from dosaboy/pre-allocate-vip-ports
Browse files Browse the repository at this point in the history
Pre-allocate func test vip ports
  • Loading branch information
rodrigogansobarbieri authored Nov 19, 2024
2 parents 53dbd6f + 83d0951 commit ea6ff3e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
12 changes: 4 additions & 8 deletions openstack/tools/charmed_openstack_functest_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,10 @@ FIP_MIN_ABC=${FIP_MIN%.*}
FIP_MIN_D=${FIP_MIN##*.}
FIP_MIN=${FIP_MIN_ABC}.$(($FIP_MIN_D + 64))

CIDR_OAM=$(openstack subnet show subnet_${OS_USERNAME}-psd -c cidr -f value)
OAM_MAX=$(ipcalc $CIDR_OAM| awk '$1=="HostMax:" {print $2}')
OAM_MIN=$(ipcalc $CIDR_OAM| awk '$1=="HostMin:" {print $2}')
OAM_MIN_ABC=${OAM_MIN%.*}
OAM_MAX_D=${OAM_MAX##*.}
# Picking last two addresses and hoping they dont get used by Neutron.
export {OS,TEST}_VIP00=${OAM_MIN_ABC}.$(($OAM_MAX_D - 1))
export {OS,TEST}_VIP01=${OAM_MIN_ABC}.$(($OAM_MAX_D - 2))
# Setup vips needed by zaza tests.
for ((i=2;i;i-=1)); do
export {OS,TEST}_VIP0$((i-1))=$(create_zaza_vip 0$i)
done

# More information on config https://github.com/openstack-charmers/zaza/blob/master/doc/source/runningcharmtests.rst
export {,TEST_}NET_ID=$(openstack network show net_${OS_USERNAME}-psd-extra -f value -c id)
Expand Down
29 changes: 29 additions & 0 deletions openstack/tools/func_test_tools/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,32 @@ apply_func_test_pr ()
-f './src/test-requirements*.txt' \
"$msg"
}

allocate_port ()
{
# Returns address of port created.
#
local net_name=$1
local port_name=$2
local port_id=$(openstack port create --network $net_name $port_name -c id -f value)
openstack port show -c fixed_ips $port_id -f yaml| yq .fixed_ips[0].ip_address
}

create_zaza_vip ()
{
# Allocates a vip ensuring to use existing ones if they exist.
#
# Returns the address of the vip.
#
local vip_id=$1
# We use the same naming convention as ../tools/allocate_vips.sh to avoid conflicts and re-use
# those vips.
vip_port_name=ps6-vip-ip$vip_id
vip_addr=$(openstack port show -c fixed_ips $vip_port_name -f yaml| yq .fixed_ips[0].ip_address)
if [[ $vip_addr = null ]]; then
# Pre-allocate ports with addresses used for VIPs so that they don't
# collide with the deployment itself.
vip_addr=$(allocate_port net_${OS_USERNAME}-psd $vip_port_name)
fi
echo $vip_addr
}
12 changes: 4 additions & 8 deletions openstack/tools/openstack_regression_tests_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,10 @@ FIP_MIN_ABC=${FIP_MIN%.*}
FIP_MIN_D=${FIP_MIN##*.}
FIP_MIN=${FIP_MIN_ABC}.$(($FIP_MIN_D + 64))

CIDR_OAM=$(openstack subnet show subnet_${OS_USERNAME}-psd -c cidr -f value)
OAM_MAX=$(ipcalc $CIDR_OAM| awk '$1=="HostMax:" {print $2}')
OAM_MIN=$(ipcalc $CIDR_OAM| awk '$1=="HostMin:" {print $2}')
OAM_MIN_ABC=${OAM_MIN%.*}
OAM_MAX_D=${OAM_MAX##*.}
# Picking last two addresses and hoping they dont get used by Neutron.
export {OS,TEST}_VIP00=${OAM_MIN_ABC}.$(($OAM_MAX_D - 1))
export {OS,TEST}_VIP01=${OAM_MIN_ABC}.$(($OAM_MAX_D - 2))
# Setup vips needed by zaza tests.
for ((i=2;i;i-=1)); do
export {OS,TEST}_VIP0$((i-1))=$(create_zaza_vip 0$i)
done

# More information on config https://github.com/openstack-charmers/zaza/blob/master/doc/source/runningcharmtests.rst
export {,TEST_}NET_ID=$(openstack network show net_${OS_USERNAME}-psd-extra -f value -c id)
Expand Down

0 comments on commit ea6ff3e

Please sign in to comment.