[CI] Test neutron DNS integration and designate

This patch adds tests for neutron and designate DNS
integration.

Tests are based on scenarios described below in [1][2].

[1] https://docs.openstack.org/neutron/latest/admin/config-dns-int.html
[2] https://docs.openstack.org/neutron/latest/admin/config-dns-int-ext-serv.html

Change-Id: I3953f760458285e5c9a818599492c6176e857dde
This commit is contained in:
Michal Arbet 2024-01-16 07:46:06 +01:00
parent 6f847610b5
commit f0b7bf33ab
4 changed files with 253 additions and 29 deletions

View File

@ -204,11 +204,16 @@ enable_prometheus_openstack_exporter: "no"
{% if scenario == "magnum" %}
enable_designate: "yes"
designate_ns_record:
- "ns.example.org"
enable_magnum: "yes"
enable_trove: "yes"
neutron_dns_domain: "example.org."
{% endif %}
{% if scenario == "octavia" %}
neutron_dns_integration: "yes"
neutron_dns_domain: "example.org."
enable_octavia: "yes"
# NOTE(wuchunyang): work around for qemu-kvm 5.1 can not attach second NIC.
# more: http://lists.openstack.org/pipermail/openstack-discuss/2021-February/020218.html

View File

@ -408,12 +408,81 @@ function test_instance_boot {
fi
}
function test_internal_dns_integration {
# As per test globals - neutron integration is turned off
if openstack extension list --network -f value -c Alias | grep -q dns-integration; then
DNS_NAME="my-port"
PORT_NAME="${DNS_NAME}"
DNS_DOMAIN=$(awk -F ':' '/neutron_dns_domain:/ { print $2 }' /etc/kolla/globals.yml \
| sed -e 's/"//g' -e "s/'//g" -e "s/\ *//g")
openstack network create dns-test-network
openstack subnet create --network dns-test-network --subnet-range 192.168.88.0/24 dns-test-subnet
openstack port create --network dns-test-network --dns-name ${DNS_NAME} ${PORT_NAME}
DNS_ASSIGNMENT=$(openstack port show ${DNS_NAME} -f json -c dns_assignment)
FQDN=$(echo ${DNS_ASSIGNMENT} | python -c 'import json,sys;obj=json.load(sys.stdin);print(obj["dns_assignment"][0]["fqdn"]);')
HOSTNAME=$(echo ${DNS_ASSIGNMENT} | python -c 'import json,sys;obj=json.load(sys.stdin);print(obj["dns_assignment"][0]["hostname"]);')
if [ "${DNS_NAME}.${DNS_DOMAIN}" == "${FQDN}" ]; then
echo "[i] Test neutron internal DNS integration FQDN check port - PASS"
else
echo "[e] Test neutron internal DNS integration FQDN check port - FAIL"
exit 1
fi
if [ "${DNS_NAME}" == "${HOSTNAME}" ]; then
echo "[i] Test neutron internal DNS integration HOSTNAME check port - PASS"
else
echo "[e] Test neutron internal DNS integration HOSTNAME check port - FAIL"
exit 1
fi
openstack port delete ${PORT_NAME}
SERVER_NAME="my_vm"
SERVER_NAME_SANITIZED=$(echo ${SERVER_NAME} | sed -e 's/_/-/g')
openstack server create --image cirros --flavor m1.tiny --network dns-test-network ${SERVER_NAME}
SERVER_ID=$(openstack server show ${SERVER_NAME} -f value -c id)
PORT_ID=$(openstack port list --device-id ${SERVER_ID} -f value -c ID)
DNS_ASSIGNMENT=$(openstack port show ${PORT_ID} -f json -c dns_assignment)
FQDN=$(echo ${DNS_ASSIGNMENT} | python -c 'import json,sys;obj=json.load(sys.stdin);print(obj["dns_assignment"][0]["fqdn"]);')
HOSTNAME=$(echo ${DNS_ASSIGNMENT} | python -c 'import json,sys;obj=json.load(sys.stdin);print(obj["dns_assignment"][0]["hostname"]);')
if [ "${SERVER_NAME_SANITIZED}.${DNS_DOMAIN}" == "${FQDN}" ]; then
echo "[i] Test neutron internal DNS integration FQDN check instance create - PASS"
else
echo "[e] Test neutron internal DNS integration FQDN check instance create - FAIL"
exit 1
fi
if [ "${SERVER_NAME_SANITIZED}" == "${HOSTNAME}" ]; then
echo "[i] Test neutron internal DNS integration HOSTNAME check instance create - PASS"
else
echo "[e] Test neutron internal DNS integration HOSTNAME check instance create - FAIL"
exit 1
fi
openstack server delete --wait ${SERVER_NAME}
openstack subnet delete dns-test-subnet
openstack network delete dns-test-network
else
echo "[i] DNS Integration is not enabled."
fi
}
function test_openstack_logged {
. /etc/kolla/admin-openrc.sh
. ~/openstackclient-venv/bin/activate
test_smoke
test_neutron_modules
test_instance_boot
test_internal_dns_integration
# Check for x86_64 architecture to run q35 tests
if [[ $(uname -m) == "x86_64" ]]; then

View File

@ -20,48 +20,129 @@ function test_trove {
openstack database cluster list
}
function test_designate {
# Smoke test.
openstack zone list --all
function check_if_resolvable {
local dns_domain="${1}"
local dns_record="${2}"
local record_type="${3}"
# Create a default zone for fixed and floating IPs, then reconfigure nova
# and neutron to use it.
openstack zone create --email admin@example.org example.org.
ZONE_ID=$(openstack zone show example.org. -f value -c id)
mkdir -p /etc/kolla/config/designate/
cat << EOF > /etc/kolla/config/designate/designate-sink.conf
[handler:nova_fixed]
zone_id = ${ZONE_ID}
[handler:neutron_floatingip]
zone_id = ${ZONE_ID}
EOF
RAW_INVENTORY=/etc/kolla/inventory
deactivate
source $KOLLA_ANSIBLE_VENV_PATH/bin/activate
kolla-ansible -i ${RAW_INVENTORY} --tags designate -vvv reconfigure &> /tmp/logs/ansible/reconfigure-designate
deactivate
source ~/openstackclient-venv/bin/activate
# Create an instance, and check that its name resolves.
openstack server create --wait --image cirros --flavor m1.tiny --key-name mykey --network demo-net dns-test --wait
attempt=1
while true; do
IP=$(dig +short @192.0.2.1 dns-test.example.org. A)
IP=$(dig +short @192.0.2.1 ${dns_record} ${record_type})
if [[ -n $IP ]]; then
break
fi
attempt=$((attempt+1))
if [[ $attempt -eq 10 ]]; then
echo "Failed to resolve dns-test.example.org."
openstack recordset list ${ZONE_ID}
echo "[e] Failed to resolve ${dns_record}"
openstack recordset list ${dns_domain}
exit 1
fi
sleep 10
done
}
function test_designate {
# Smoke test.
openstack zone list --all
SERVER_NAME="my_vm"
SERVER_NAME_SANITIZED=$(echo ${SERVER_NAME} | sed -e 's/_/-/g')
DNS_DOMAIN="floating.example.org."
openstack zone create --email admin@example.org ${DNS_DOMAIN}
openstack network create --dns-domain ${DNS_DOMAIN} tenant-dns-test
openstack subnet create --subnet-range 192.168.99.0/24 --network tenant-dns-test tenant-dns-test
openstack router create router-dns-test
openstack router set --external-gateway public1 router-dns-test
openstack router add subnet router-dns-test tenant-dns-test
openstack server create --image cirros --flavor m1.tiny --network tenant-dns-test ${SERVER_NAME}
SERVER_ID=$(openstack server show ${SERVER_NAME} -f value -c id)
PORT_ID=$(openstack port list --device-id ${SERVER_ID} -f value -c ID)
openstack floating ip create public1 --port ${PORT_ID}
check_if_resolvable "${DNS_DOMAIN}" "${SERVER_NAME_SANITIZED}.${DNS_DOMAIN}" "A"
FLOATING_IP_ID=$(openstack floating ip list --port ${PORT_ID} -f value -c ID)
openstack server remove floating ip ${SERVER_ID} ${FLOATING_IP_ID}
openstack floating ip delete ${FLOATING_IP_ID}
openstack server delete --wait ${SERVER_ID}
DNS_DOMAIN="floating-2.example.org."
DNS_NAME="my-floatingip"
ZONE_ID=$(openstack zone create --email admin@example.org ${DNS_DOMAIN} -f value -c id)
FLOATING_IP_ID=$(openstack floating ip create --dns-domain ${DNS_DOMAIN} --dns-name ${DNS_NAME} public1 -f value -c id)
check_if_resolvable "${DNS_DOMAIN}" "${DNS_NAME}.${DNS_DOMAIN}" "A"
openstack floating ip delete ${FLOATING_IP_ID}
openstack zone delete ${ZONE_ID}
DNS_DOMAIN="fixed.example.org."
DNS_NAME="port"
ZONE_ID=$(openstack zone create --email admin@example.org ${DNS_DOMAIN} -f value -c id)
SUBNET_ID=$(openstack subnet create --network public1 public1-subnet-ipv6 --ip-version 6 --subnet-range 2001:db8:42:42::/64 --dns-publish-fixed-ip -f value -c id)
PORT_ID=$(openstack port create ${DNS_NAME} --dns-domain ${DNS_DOMAIN} --dns-name ${DNS_NAME} --network public1 -f value -c id)
check_if_resolvable "${DNS_DOMAIN}" "${DNS_NAME}.${DNS_DOMAIN}" "AAAA"
openstack port delete ${PORT_ID}
DNS_DOMAIN="fixed.sink.example.org."
openstack zone create --email admin@example.org ${DNS_DOMAIN}
ZONE_ID_FIXED=$(openstack zone show ${DNS_DOMAIN} -f value -c id)
DNS_DOMAIN="floating.sink.example.org."
openstack zone create --email admin@example.org ${DNS_DOMAIN}
ZONE_ID_FLOATING=$(openstack zone show ${DNS_DOMAIN} -f value -c id)
mkdir -p /etc/kolla/config/designate/
cat << EOF > /etc/kolla/config/designate/designate-sink.conf
[handler:nova_fixed]
zone_id = ${ZONE_ID_FIXED}
[handler:neutron_floatingip]
zone_id = ${ZONE_ID_FLOATING}
EOF
RAW_INVENTORY=/etc/kolla/inventory
deactivate
source $KOLLA_ANSIBLE_VENV_PATH/bin/activate
echo 'designate_enable_notifications_sink: "yes"' >> /etc/kolla/globals.yml
kolla-ansible -i ${RAW_INVENTORY} --tags designate,nova,nova-cell,neutron -vvv reconfigure &> /tmp/logs/ansible/reconfigure-designate
deactivate
source ~/openstackclient-venv/bin/activate
DNS_DOMAIN="fixed.sink.example.org."
SERVER_NAME="sink-server"
openstack server create --image cirros --flavor m1.tiny --network tenant-dns-test ${SERVER_NAME}
check_if_resolvable "${DNS_DOMAIN}" "${SERVER_NAME}.${DNS_DOMAIN}" "A"
SERVER_ID=$(openstack server show ${SERVER_NAME} -f value -c id)
FLOATING_IP_ID=$(openstack floating ip create public1 -f value -c id)
DNS_DOMAIN="floating.sink.example.org."
openstack server add floating ip ${SERVER_ID} ${FLOATING_IP_ID}
FLOATING_IP_IP=$(openstack floating ip show ${FLOATING_IP_ID} -f value -c floating_ip_address)
DNS_NAME_ASSIGNMENT=$(echo "${FLOATING_IP_IP}" | sed -e 's/\./-/g')
check_if_resolvable "${DNS_DOMAIN}" "${DNS_NAME_ASSIGNMENT}.${DNS_DOMAIN}" "A"
openstack server remove floating ip ${SERVER_ID} ${FLOATING_IP_ID}
openstack server delete --wait ${SERVER_ID}
openstack zone delete ${ZONE_ID_FIXED}
openstack zone delete ${ZONE_ID_FLOATING}
openstack zone delete floating.example.org.
}
function test_magnum_logged {
. /etc/kolla/admin-openrc.sh
. ~/openstackclient-venv/bin/activate

View File

@ -84,6 +84,75 @@ function test_octavia {
openstack server delete --wait lb_member
}
function test_internal_dns_integration {
# As per test globals - neutron integration is turned on
if openstack extension list --network -f value -c Alias | grep -q dns-integration; then
DNS_NAME="my-port"
PORT_NAME="${DNS_NAME}"
DNS_DOMAIN=$(grep 'neutron_dns_domain:' /etc/kolla/globals.yml \
| awk -F ':' '{print $2}' \
| sed -e 's/"//g' -e "s/'//g" -e "s/\ *//g")
openstack network create dns-test-network
openstack subnet create --network dns-test-network --subnet-range 192.168.88.0/24 dns-test-subnet
openstack port create --network dns-test-network --dns-name ${DNS_NAME} ${PORT_NAME}
DNS_ASSIGNMENT=$(openstack port show ${DNS_NAME} -f json -c dns_assignment)
FQDN=$(echo ${DNS_ASSIGNMENT} | python -c 'import json,sys;obj=json.load(sys.stdin);print(obj["dns_assignment"][0]["fqdn"]);')
HOSTNAME=$(echo ${DNS_ASSIGNMENT} | python -c 'import json,sys;obj=json.load(sys.stdin);print(obj["dns_assignment"][0]["hostname"]);')
if [ "${DNS_NAME}.${DNS_DOMAIN}" == "${FQDN}" ]; then
echo "[i] Test neutron internal DNS integration FQDN check port - PASS"
else
echo "[e] Test neutron internal DNS integration FQDN check port - FAIL"
exit 1
fi
if [ "${DNS_NAME}" == "${HOSTNAME}" ]; then
echo "[i] Test neutron internal DNS integration HOSTNAME check port - PASS"
else
echo "[e] Test neutron internal DNS integration HOSTNAME check port - FAIL"
exit 1
fi
openstack port delete ${PORT_NAME}
SERVER_NAME="my_vm"
SERVER_NAME_SANITIZED=$(echo ${SERVER_NAME} | sed -e 's/_/-/g')
openstack server create --image cirros --flavor m1.tiny --network dns-test-network ${SERVER_NAME}
SERVER_ID=$(openstack server show ${SERVER_NAME} -f value -c id)
PORT_ID=$(openstack port list --device-id ${SERVER_ID} -f value -c ID)
DNS_ASSIGNMENT=$(openstack port show ${PORT_ID} -f json -c dns_assignment)
FQDN=$(echo ${DNS_ASSIGNMENT} | python -c 'import json,sys;obj=json.load(sys.stdin);print(obj["dns_assignment"][0]["fqdn"]);')
HOSTNAME=$(echo ${DNS_ASSIGNMENT} | python -c 'import json,sys;obj=json.load(sys.stdin);print(obj["dns_assignment"][0]["hostname"]);')
if [ "${SERVER_NAME_SANITIZED}.${DNS_DOMAIN}" == "${FQDN}" ]; then
echo "[i] Test neutron internal DNS integration FQDN check instance create - PASS"
else
echo "[e] Test neutron internal DNS integration FQDN check instance create - FAIL"
exit 1
fi
if [ "${SERVER_NAME_SANITIZED}" == "${HOSTNAME}" ]; then
echo "[i] Test neutron internal DNS integration HOSTNAME check instance create - PASS"
else
echo "[e] Test neutron internal DNS integration HOSTNAME check instance create - FAIL"
exit 1
fi
openstack server delete --wait ${SERVER_NAME}
openstack subnet delete dns-test-subnet
openstack network delete dns-test-network
else
echo "[i] DNS Integration is not enabled."
fi
}
function test_octavia_logged {
# Check if any certs expire within a week.
check_certificate_expiry
@ -91,6 +160,7 @@ function test_octavia_logged {
. /etc/kolla/admin-openrc.sh
. ~/openstackclient-venv/bin/activate
test_octavia
test_internal_dns_integration
}
function test_octavia_setup {
@ -106,4 +176,3 @@ function test_octavia_setup {
}
test_octavia_setup