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 539b701 commit 3717a70
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
22 changes: 14 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,20 @@ 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
NUM_VIPS=2
for ((i=$NUM_VIPS;i;i-=1)); do
# 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$((i-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
export {OS,TEST}_VIP0$((i-1))=$vip_addr
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
9 changes: 8 additions & 1 deletion openstack/tools/func_test_tools/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ apply_func_test_pr ()
-f './test-requirements*.txt' \
-f './src/test-requirements*.txt' \
"$msg"
}
}

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

0 comments on commit 3717a70

Please sign in to comment.