Skip to content

Commit

Permalink
Pre-allocate func test vip ports
Browse files Browse the repository at this point in the history
Resolves: #269
  • Loading branch information
dosaboy committed Oct 16, 2024
1 parent f9a3cdb commit 663fa48
Show file tree
Hide file tree
Showing 3 changed files with 35 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 $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
27 changes: 27 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,30 @@ apply_func_test_pr ()
-f './src/test-requirements*.txt' \
"$msg"
}

allocate_port ()
{
local net_name=$1
local port_name=$2
openstack port create --network $net_name $port_name
}

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-1))
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.
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 @@ -90,14 +90,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 $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 663fa48

Please sign in to comment.