From 151cd7b9ac97265590adcd82c3d7a0ed58480e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Mon, 7 Jun 2021 17:48:07 +0000 Subject: [PATCH] Move verify-ipv6-only-deployments from Tempest to DevStack as it tests DevStack side of things and is useful for projects not using Tempest. This is part 2 of 2. The 1st part is DevStack-side, in Depends-On. The script is left calling out to devstack because legacy (dsvm) jobs rely on its presence. Depends-On: Ie166730843f874b9c99e37244e460d7ad33b7eeb Change-Id: I6fa17ae413f106453303c4882925573bd8e05029 --- playbooks/devstack-tempest-ipv6.yaml | 2 +- .../README.rst | 16 ---- .../defaults/main.yaml | 1 - .../tasks/main.yaml | 4 - tools/verify-ipv6-only-deployments.sh | 94 +------------------ 5 files changed, 6 insertions(+), 111 deletions(-) delete mode 100644 roles/ipv6-only-deployments-verification/README.rst delete mode 100644 roles/ipv6-only-deployments-verification/defaults/main.yaml delete mode 100644 roles/ipv6-only-deployments-verification/tasks/main.yaml diff --git a/playbooks/devstack-tempest-ipv6.yaml b/playbooks/devstack-tempest-ipv6.yaml index 4788362ee0..d56fb73567 100644 --- a/playbooks/devstack-tempest-ipv6.yaml +++ b/playbooks/devstack-tempest-ipv6.yaml @@ -15,5 +15,5 @@ # IPv6 only env for example Devstack IPv6 settings and services listen # address is IPv6 etc. This is invoked before tests are run so that we can # fail early if anything missing the IPv6 settings or deployments. - - ipv6-only-deployments-verification + - devstack-ipv6-only-deployments-verification - run-tempest diff --git a/roles/ipv6-only-deployments-verification/README.rst b/roles/ipv6-only-deployments-verification/README.rst deleted file mode 100644 index 400a8da222..0000000000 --- a/roles/ipv6-only-deployments-verification/README.rst +++ /dev/null @@ -1,16 +0,0 @@ -Verify the IPv6-only deployments - -This role needs to be invoked from a playbook that -run tests. This role verifies the IPv6 setting on -devstack side and devstack deploy services on IPv6. -This role is invoked before tests are run so that -if any missing IPv6 setting or deployments can fail -the job early. - - -**Role Variables** - -.. zuul:rolevar:: devstack_base_dir - :default: /opt/stack - - The devstack base directory. diff --git a/roles/ipv6-only-deployments-verification/defaults/main.yaml b/roles/ipv6-only-deployments-verification/defaults/main.yaml deleted file mode 100644 index fea05c8146..0000000000 --- a/roles/ipv6-only-deployments-verification/defaults/main.yaml +++ /dev/null @@ -1 +0,0 @@ -devstack_base_dir: /opt/stack diff --git a/roles/ipv6-only-deployments-verification/tasks/main.yaml b/roles/ipv6-only-deployments-verification/tasks/main.yaml deleted file mode 100644 index d73c79c06f..0000000000 --- a/roles/ipv6-only-deployments-verification/tasks/main.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- name: Verify the ipv6-only deployments - become: true - become_user: stack - shell: "{{ devstack_base_dir }}/tempest/tools/verify-ipv6-only-deployments.sh" diff --git a/tools/verify-ipv6-only-deployments.sh b/tools/verify-ipv6-only-deployments.sh index 2596395165..bfb14030fc 100755 --- a/tools/verify-ipv6-only-deployments.sh +++ b/tools/verify-ipv6-only-deployments.sh @@ -1,92 +1,8 @@ #!/bin/bash -# -# -# NOTE(gmann): This script is used in 'devstack-tempest-ipv6' zuul job to verify that -# services are deployed on IPv6 properly or not. This will capture if any devstck or devstack -# plugins are missing the required setting to listen on IPv6 address. This is run as part of -# run phase of zuul job and before test run. Child job of 'devstack-tempest-ipv6' -# can expand the IPv6 verification specific to project by defining the new post-run script which -# will run along with this base script. -# If there are more common verification for IPv6 then we can always extent this script. -# Keep track of the DevStack directory -TOP_DIR=$(cd $(dirname "$0")/../../devstack && pwd) -source $TOP_DIR/stackrc -source $TOP_DIR/openrc admin admin +# NOTE(yoctozepto): This scripts lives now in devstack where it belongs. +# It is kept here for the legacy (dsvm) jobs which look for it in tempest still. +# TODO: Drop it when no legacy jobs use the master tempest. -function verify_devstack_ipv6_setting { - local _service_host='' - _service_host=$(echo $SERVICE_HOST | tr -d []) - local _host_ipv6='' - _host_ipv6=$(echo $HOST_IPV6 | tr -d []) - local _service_listen_address='' - _service_listen_address=$(echo $SERVICE_LISTEN_ADDRESS | tr -d []) - local _service_local_host='' - _service_local_host=$(echo $SERVICE_LOCAL_HOST | tr -d []) - if [[ "$SERVICE_IP_VERSION" != 6 ]]; then - echo $SERVICE_IP_VERSION "SERVICE_IP_VERSION is not set to 6 which is must for devstack to deploy services with IPv6 address." - exit 1 - fi - is_service_host_ipv6=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$_service_host'"))') - if [[ "$is_service_host_ipv6" != "True" ]]; then - echo $SERVICE_HOST "SERVICE_HOST is not ipv6 which means devstack cannot deploy services on IPv6 address." - exit 1 - fi - is_host_ipv6=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$_host_ipv6'"))') - if [[ "$is_host_ipv6" != "True" ]]; then - echo $HOST_IPV6 "HOST_IPV6 is not ipv6 which means devstack cannot deploy services on IPv6 address." - exit 1 - fi - is_service_listen_address=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$_service_listen_address'"))') - if [[ "$is_service_listen_address" != "True" ]]; then - echo $SERVICE_LISTEN_ADDRESS "SERVICE_LISTEN_ADDRESS is not ipv6 which means devstack cannot deploy services on IPv6 address." - exit 1 - fi - is_service_local_host=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$_service_local_host'"))') - if [[ "$is_service_local_host" != "True" ]]; then - echo $SERVICE_LOCAL_HOST "SERVICE_LOCAL_HOST is not ipv6 which means devstack cannot deploy services on IPv6 address." - exit 1 - fi - echo "Devstack is properly configured with IPv6" - echo "SERVICE_IP_VERSION: " $SERVICE_IP_VERSION "HOST_IPV6: " $HOST_IPV6 "SERVICE_HOST: " $SERVICE_HOST "SERVICE_LISTEN_ADDRESS: " $SERVICE_LISTEN_ADDRESS "SERVICE_LOCAL_HOST: " $SERVICE_LOCAL_HOST -} - -function sanity_check_system_ipv6_enabled { - system_ipv6_enabled=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_ipv6_enabled())') - if [[ $system_ipv6_enabled != "True" ]]; then - echo "IPv6 is disabled in system" - exit 1 - fi - echo "IPv6 is enabled in system" -} - -function verify_service_listen_address_is_ipv6 { - local endpoints_verified=False - local all_ipv6=True - endpoints=$(openstack endpoint list -f value -c URL) - for endpoint in ${endpoints}; do - local endpoint_address='' - endpoint_address=$(echo "$endpoint" | awk -F/ '{print $3}' | awk -F] '{print $1}') - endpoint_address=$(echo $endpoint_address | tr -d []) - local is_endpoint_ipv6='' - is_endpoint_ipv6=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$endpoint_address'"))') - if [[ "$is_endpoint_ipv6" != "True" ]]; then - all_ipv6=False - echo $endpoint ": This is not ipv6 endpoint which means corresponding service is not listening on IPv6 address." - continue - fi - endpoints_verified=True - done - if [[ "$all_ipv6" == "False" ]] || [[ "$endpoints_verified" == "False" ]]; then - exit 1 - fi - echo "All services deployed by devstack is on IPv6 endpoints" - echo $endpoints -} - -#First thing to verify if system has IPv6 enabled or not -sanity_check_system_ipv6_enabled -#Verify whether devstack is configured properly with IPv6 setting -verify_devstack_ipv6_setting -#Get all registrfed endpoints by devstack in keystone and verify that each endpoints address is IPv6. -verify_service_listen_address_is_ipv6 +DEVSTACK_DIR=$(cd $(dirname "$0")/../../devstack && pwd) +$DEVSTACK_DIR/tools/verify-ipv6-only-deployments.sh