diff --git a/openstack/tools/charmed_openstack_functest_runner.sh b/openstack/tools/charmed_openstack_functest_runner.sh index f7aa130d..7993d498 100755 --- a/openstack/tools/charmed_openstack_functest_runner.sh +++ b/openstack/tools/charmed_openstack_functest_runner.sh @@ -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) diff --git a/openstack/tools/func_test_tools/common.sh b/openstack/tools/func_test_tools/common.sh index 7a958a62..ac08b5c8 100644 --- a/openstack/tools/func_test_tools/common.sh +++ b/openstack/tools/func_test_tools/common.sh @@ -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 +} diff --git a/openstack/tools/openstack_regression_tests_runner.sh b/openstack/tools/openstack_regression_tests_runner.sh index c2842969..693a1380 100755 --- a/openstack/tools/openstack_regression_tests_runner.sh +++ b/openstack/tools/openstack_regression_tests_runner.sh @@ -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)