[CI] Test Neutron with IPv6 networks

Make sure to actually test IPv6 connectivity to our test instance in the
IPv6 jobs.

Change-Id: I7845448804e191af356e82f8ad33c563ffd8ebd5
This commit is contained in:
Radosław Piliszek 2020-03-12 19:50:16 +01:00
parent 4971eccd62
commit 7367427338
5 changed files with 85 additions and 19 deletions

View File

@ -13,6 +13,12 @@ function init_runonce {
echo "Initialising OpenStack resources via init-runonce"
KOLLA_DEBUG=1 tools/init-runonce |& gawk '{ print strftime("%F %T"), $0; }' &> /tmp/logs/ansible/init-runonce
if [[ $IP_VERSION -eq 6 ]]; then
# NOTE(yoctozepto): In case of IPv6 there is no NAT support in Neutron,
# so we have to set up native routing. Static routes are the simplest.
sudo ip route add ${DEMO_NET_CIDR} via ${EXT_NET_DEMO_ROUTER_ADDR}
fi
}

View File

@ -408,9 +408,14 @@
executable: /bin/bash
chdir: "{{ kolla_ansible_src_dir }}"
environment:
IP_VERSION: "{{ 6 if address_family == 'ipv6' else 4 }}"
DEMO_NET_CIDR: "{{ neutron_tenant_network_prefix }}0/{{ neutron_tenant_network_prefix_length }}"
DEMO_NET_GATEWAY: "{{ neutron_tenant_network_prefix }}1"
DEMO_NET_DNS: "{{ neutron_tenant_network_dns_server }}"
EXT_NET_CIDR: "{{ neutron_external_network_prefix }}0/{{ neutron_external_network_prefix_length }}"
EXT_NET_RANGE: "start={{ neutron_external_network_prefix }}150,end={{ neutron_external_network_prefix }}199"
EXT_NET_GATEWAY: "{{ neutron_external_network_prefix }}1"
EXT_NET_DEMO_ROUTER_ADDR: "{{ neutron_external_network_prefix }}10"
SCENARIO: "{{ scenario }}"
when: openstack_core_tested or scenario in ['ironic', 'magnum', 'scenario_nfv', 'zun', 'octavia']
@ -423,6 +428,7 @@
SCENARIO: "{{ scenario }}"
HAS_UPGRADE: "{{ is_upgrade | bool | ternary('yes', 'no') }}"
PHASE: deploy
IP_VERSION: "{{ 6 if address_family == 'ipv6' else 4 }}"
when: openstack_core_tested
- name: Run test-zun.sh script
@ -695,6 +701,7 @@
SCENARIO: "{{ scenario }}"
HAS_UPGRADE: 'yes'
PHASE: upgrade
IP_VERSION: "{{ 6 if address_family == 'ipv6' else 4 }}"
when: openstack_core_tested
- name: Run test-swift.sh script

View File

@ -159,7 +159,14 @@ function delete_a_volume {
function create_instance {
local name=$1
openstack server create --wait --image cirros --flavor m1.tiny --key-name mykey --network demo-net ${name}
local server_create_extra
if [[ $IP_VERSION -eq 6 ]]; then
# NOTE(yoctozepto): CirrOS has no IPv6 metadata support, hence need to use configdrive
server_create_extra="${server_create_extra} --config-drive True"
fi
openstack server create --wait --image cirros --flavor m1.tiny --key-name mykey --network demo-net ${server_create_extra} ${name}
# If the status is not ACTIVE, print info and exit 1
if [[ $(openstack server show ${name} -f value -c status) != "ACTIVE" ]]; then
echo "FAILED: Instance is not active"
@ -284,19 +291,27 @@ function test_instance_boot {
openstack image delete image_from_instance
echo "SUCCESS: Instance image upload"
echo "TESTING: Floating ip allocation"
fip_addr=$(create_fip)
attach_fip kolla_boot_test ${fip_addr}
echo "SUCCESS: Floating ip allocation"
if [[ $IP_VERSION -eq 4 ]]; then
echo "TESTING: Floating ip allocation"
fip_addr=$(create_fip)
attach_fip kolla_boot_test ${fip_addr}
echo "SUCCESS: Floating ip allocation"
else
# NOTE(yoctozepto): Neutron has no IPv6 NAT support, hence no floating ip addresses
local instance_addresses
fip_addr=$(openstack server show kolla_boot_test -f yaml -c addresses|tail -1|cut -d- -f2)
fi
echo "TESTING: PING&SSH to floating ip"
echo "TESTING: PING&SSH to instance"
test_ssh kolla_boot_test ${fip_addr}
echo "SUCCESS: PING&SSH to floating ip"
echo "SUCCESS: PING&SSH to instance"
echo "TESTING: Floating ip deallocation"
detach_fip kolla_boot_test ${fip_addr}
delete_fip ${fip_addr}
echo "SUCCESS: Floating ip deallocation"
if [[ $IP_VERSION -eq 4 ]]; then
echo "TESTING: Floating ip deallocation"
detach_fip kolla_boot_test ${fip_addr}
delete_fip ${fip_addr}
echo "SUCCESS: Floating ip deallocation"
fi
echo "TESTING: Server deletion"
delete_instance kolla_boot_test

View File

@ -26,6 +26,12 @@ IMAGE=cirros-${CIRROS_RELEASE}-${ARCH}-disk.img
IMAGE_NAME=cirros
IMAGE_TYPE=linux
IP_VERSION=${IP_VERSION:-4}
DEMO_NET_CIDR=${DEMO_NET_CIDR:-'10.0.0.0/24'}
DEMO_NET_GATEWAY=${DEMO_NET_GATEWAY:-'10.0.0.1'}
DEMO_NET_DNS=${DEMO_NET_DNS:-'8.8.8.8'}
# This EXT_NET_CIDR is your public network,that you want to connect to the internet via.
ENABLE_EXT_NET=${ENABLE_EXT_NET:-1}
EXT_NET_CIDR=${EXT_NET_CIDR:-'10.0.2.0/24'}
@ -90,18 +96,42 @@ echo Configuring neutron.
$KOLLA_OPENSTACK_COMMAND router create demo-router
SUBNET_CREATE_EXTRA=""
if [[ $IP_VERSION -eq 6 ]]; then
# NOTE(yoctozepto): Neutron defaults to "unset" (external) addressing for IPv6.
# The following is to use stateful DHCPv6 (RA for routing + DHCPv6 for addressing)
# served by Neutron Router and DHCP services.
# Setting this for IPv4 errors out instead of being ignored.
SUBNET_CREATE_EXTRA="${SUBNET_CREATE_EXTRA} --ipv6-ra-mode dhcpv6-stateful"
SUBNET_CREATE_EXTRA="${SUBNET_CREATE_EXTRA} --ipv6-address-mode dhcpv6-stateful"
fi
$KOLLA_OPENSTACK_COMMAND network create demo-net
$KOLLA_OPENSTACK_COMMAND subnet create --subnet-range 10.0.0.0/24 --network demo-net \
--gateway 10.0.0.1 --dns-nameserver 8.8.8.8 demo-subnet
$KOLLA_OPENSTACK_COMMAND subnet create --ip-version ${IP_VERSION} \
--subnet-range ${DEMO_NET_CIDR} --network demo-net \
--gateway ${DEMO_NET_GATEWAY} --dns-nameserver ${DEMO_NET_DNS} \
${SUBNET_CREATE_EXTRA} demo-subnet
$KOLLA_OPENSTACK_COMMAND router add subnet demo-router demo-subnet
if [[ $ENABLE_EXT_NET -eq 1 ]]; then
$KOLLA_OPENSTACK_COMMAND network create --external --provider-physical-network physnet1 \
--provider-network-type flat public1
$KOLLA_OPENSTACK_COMMAND subnet create --no-dhcp \
$KOLLA_OPENSTACK_COMMAND subnet create --no-dhcp --ip-version ${IP_VERSION} \
--allocation-pool ${EXT_NET_RANGE} --network public1 \
--subnet-range ${EXT_NET_CIDR} --gateway ${EXT_NET_GATEWAY} public1-subnet
$KOLLA_OPENSTACK_COMMAND router set --external-gateway public1 demo-router
if [[ $IP_VERSION -eq 4 ]]; then
$KOLLA_OPENSTACK_COMMAND router set --external-gateway public1 demo-router
else
# NOTE(yoctozepto): In case of IPv6 there is no NAT support in Neutron,
# so we have to set up native routing. Static routes are the simplest.
# We need a static IP address for the router to demo.
$KOLLA_OPENSTACK_COMMAND router set --external-gateway public1 \
--fixed-ip subnet=public1-subnet,ip-address=${EXT_NET_DEMO_ROUTER_ADDR} \
demo-router
fi
fi
# Get admin user and tenant IDs
@ -109,14 +139,14 @@ ADMIN_PROJECT_ID=$($KOLLA_OPENSTACK_COMMAND project list | awk '/ admin / {print
ADMIN_SEC_GROUP=$($KOLLA_OPENSTACK_COMMAND security group list --project ${ADMIN_PROJECT_ID} | awk '/ default / {print $2}')
# Sec Group Config
$KOLLA_OPENSTACK_COMMAND security group rule create --ingress --ethertype IPv4 \
$KOLLA_OPENSTACK_COMMAND security group rule create --ingress --ethertype IPv${IP_VERSION} \
--protocol icmp ${ADMIN_SEC_GROUP}
$KOLLA_OPENSTACK_COMMAND security group rule create --ingress --ethertype IPv4 \
$KOLLA_OPENSTACK_COMMAND security group rule create --ingress --ethertype IPv${IP_VERSION} \
--protocol tcp --dst-port 22 ${ADMIN_SEC_GROUP}
# Open heat-cfn so it can run on a different host
$KOLLA_OPENSTACK_COMMAND security group rule create --ingress --ethertype IPv4 \
$KOLLA_OPENSTACK_COMMAND security group rule create --ingress --ethertype IPv${IP_VERSION} \
--protocol tcp --dst-port 8000 ${ADMIN_SEC_GROUP}
$KOLLA_OPENSTACK_COMMAND security group rule create --ingress --ethertype IPv4 \
$KOLLA_OPENSTACK_COMMAND security group rule create --ingress --ethertype IPv${IP_VERSION} \
--protocol tcp --dst-port 8080 ${ADMIN_SEC_GROUP}
if [ ! -f ~/.ssh/id_ecdsa.pub ]; then

View File

@ -41,6 +41,9 @@
neutron_external_bridge_name: br0
neutron_external_interface_name: "veth-{{ neutron_external_bridge_name }}-ext"
neutron_external_vxlan_interface_name: vxlan1
neutron_tenant_network_prefix: "203.0.113."
neutron_tenant_network_prefix_length: "24"
neutron_tenant_network_dns_server: "8.8.8.8"
tls_enabled: false
configure_swap_size: 0
roles:
@ -65,6 +68,11 @@
api_network_prefix: "fd::"
api_network_prefix_length: "64"
kolla_internal_vip_address: "fd::ff:0"
neutron_external_network_prefix: "fd:1::"
neutron_external_network_prefix_length: "64"
neutron_tenant_network_prefix: "fd:f0::"
neutron_tenant_network_prefix_length: "64"
neutron_tenant_network_dns_server: 2001:4860:4860::8888
address_family: 'ipv6'
- job: