Test metadata over IPv6

To ssh into the instance we use an IPv4 floating IP,
but then we test accessing metadata over IPv6.

tempest.conf:

[neutron_plugin_options]
advanced_image_ref = ubuntu 16.04 does not but 18.04 and 20.04 work
advanced_image_flavor_ref = d1 # ds512M
advanced_image_ssh_user = ubuntu
default_image_is_advanced = False

Introduce new tempest(-plugin) boolean config option:
    neutron_plugin_options.ipv6_metadata
    Defaults to True.
This controls whether the test should run since API extension based
auto-discovery is naturally unavailable for the feature.

Disable executing the test in ovn and older-than-victoria gate jobs.

Change-Id: I7a1d2057489067e555cb247e473ad11e63dbdd86
Related-Bug: #1460177
This commit is contained in:
Bence Romsics 2020-09-04 14:49:58 +02:00
parent 67621f75bc
commit 6158965423
6 changed files with 200 additions and 0 deletions

View File

@ -120,6 +120,18 @@ NeutronPluginOptions = [
'This is required if advanced image has to be used in '
'tests.'),
# Enable/disable metadata over IPv6 tests. This feature naturally
# does not have an API extension, but at the time of first implementation
# it works only on victoria+ deployments with dhcp- and/or l3-agents
# (which in the gate is the same as non-ovn jobs).
cfg.BoolOpt('ipv6_metadata',
default=True,
help='Enable metadata over IPv6 tests where the feature is '
'implemented, disable where it is not. Use this instead '
'of network-feature-enabled.api_extensions, since API '
'extensions do not make sense for a feature not '
'exposed on the API.'),
# Option for creating QoS policies configures as "shared".
# The default is false in order to prevent undesired usage
# while testing in parallel.

View File

@ -0,0 +1,142 @@
# Copyright 2020 Ericsson Software Technology
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import collections
from neutron_lib import constants as nlib_const
from oslo_log import log as logging
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
import testtools
from neutron_tempest_plugin.common import ssh
from neutron_tempest_plugin import config
from neutron_tempest_plugin.scenario import base
LOG = logging.getLogger(__name__)
CONF = config.CONF
Server = collections.namedtuple(
'Server', ['floating_ip', 'server', 'ssh_client'])
class MetadataTest(base.BaseTempestTestCase):
"""Test metadata access over IPv6 tenant subnet.
Please note that there is metadata over IPv4 test coverage in tempest:
tempest.scenario.test_server_basic_ops\
.TestServerBasicOps.test_server_basic_ops
"""
credentials = ['primary', 'admin']
force_tenant_isolation = False
@classmethod
def resource_setup(cls):
super(MetadataTest, cls).resource_setup()
cls.rand_name = data_utils.rand_name(
cls.__name__.rsplit('.', 1)[-1])
cls.network = cls.create_network(name=cls.rand_name)
cls.subnet_v4 = cls.create_subnet(
network=cls.network, name=cls.rand_name)
cls.subnet_v6 = cls.create_subnet(
network=cls.network, name=cls.rand_name, ip_version=6)
cls.router = cls.create_router_by_client()
cls.create_router_interface(cls.router['id'], cls.subnet_v4['id'])
cls.create_router_interface(cls.router['id'], cls.subnet_v6['id'])
cls.keypair = cls.create_keypair(name=cls.rand_name)
cls.security_group = cls.create_security_group(name=cls.rand_name)
cls.create_loginable_secgroup_rule(cls.security_group['id'])
def _create_server_with_network(self, network, use_advanced_image=False):
port = self._create_server_port(network=network)
floating_ip = self.create_floatingip(port=port)
ssh_client = self._create_ssh_client(
floating_ip=floating_ip, use_advanced_image=use_advanced_image)
server = self._create_server(port=port,
use_advanced_image=use_advanced_image)
return Server(
floating_ip=floating_ip, server=server, ssh_client=ssh_client)
def _create_server_port(self, network=None, **params):
network = network or self.network
return self.create_port(network=network, name=self.rand_name,
security_groups=[self.security_group['id']],
**params)
def _create_server(self, port, use_advanced_image=False, **params):
if use_advanced_image:
flavor_ref = CONF.neutron_plugin_options.advanced_image_flavor_ref
image_ref = CONF.neutron_plugin_options.advanced_image_ref
else:
flavor_ref = CONF.compute.flavor_ref
image_ref = CONF.compute.image_ref
return self.create_server(flavor_ref=flavor_ref,
image_ref=image_ref,
key_name=self.keypair['name'],
networks=[{'port': port['id']}],
**params)['server']
def _create_ssh_client(self, floating_ip, use_advanced_image=False):
if use_advanced_image:
username = CONF.neutron_plugin_options.advanced_image_ssh_user
else:
username = CONF.validation.image_ssh_user
return ssh.Client(host=floating_ip['floating_ip_address'],
username=username,
pkey=self.keypair['private_key'])
def _assert_has_ssh_connectivity(self, ssh_client):
ssh_client.exec_command('true')
def _get_primary_interface(self, ssh_client):
out = ssh_client.exec_command(
"ip -6 -br address show scope link up | head -1 | cut -d ' ' -f1")
interface = out.strip()
if not interface:
self.fail(
'Could not find a single interface '
'with an IPv6 link-local address.')
return interface
@testtools.skipUnless(
(CONF.neutron_plugin_options.ipv6_metadata and
(CONF.neutron_plugin_options.advanced_image_ref or
CONF.neutron_plugin_options.default_image_is_advanced)),
'Advanced image and neutron_plugin_options.ipv6_metadata=True '
'is required to run this test.')
@decorators.idempotent_id('e680949a-f1cc-11ea-b49a-cba39bbbe5ad')
def test_metadata_routed(self):
use_advanced_image = (
not CONF.neutron_plugin_options.default_image_is_advanced)
vm = self._create_server_with_network(
self.network, use_advanced_image=use_advanced_image)
self.wait_for_server_active(server=vm.server)
self._assert_has_ssh_connectivity(vm.ssh_client)
interface = self._get_primary_interface(vm.ssh_client)
out = vm.ssh_client.exec_command(
'curl http://[%(address)s%%25%(interface)s]/' % {
'address': nlib_const.METADATA_V6_IP,
'interface': interface})
self.assertIn('latest', out)
out = vm.ssh_client.exec_command(
'curl http://[%(address)s%%25%(interface)s]/openstack/' % {
'address': nlib_const.METADATA_V6_IP,
'interface': interface})
self.assertIn('latest', out)

View File

@ -240,6 +240,7 @@
$TEMPEST_CONFIG:
neutron_plugin_options:
available_type_drivers: local,flat,vlan,geneve
ipv6_metadata: False
is_igmp_snooping_enabled: True
- job:

View File

@ -84,6 +84,11 @@
network_api_extensions: *api_extensions
devstack_localrc:
NETWORK_API_EXTENSIONS: "{{ network_api_extensions | join(',') }}"
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
neutron_plugin_options:
ipv6_metadata: False
- job:
name: neutron-tempest-plugin-scenario-openvswitch-iptables_hybrid-stein
@ -94,6 +99,11 @@
network_api_extensions: *api_extensions
devstack_localrc:
NETWORK_API_EXTENSIONS: "{{ network_api_extensions | join(',') }}"
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
neutron_plugin_options:
ipv6_metadata: False
- job:
name: neutron-tempest-plugin-scenario-linuxbridge-stein
@ -104,6 +114,11 @@
network_api_extensions: *api_extensions
devstack_localrc:
NETWORK_API_EXTENSIONS: "{{ network_api_extensions | join(',') }}"
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
neutron_plugin_options:
ipv6_metadata: False
- job:
name: neutron-tempest-plugin-dvr-multinode-scenario-stein

View File

@ -89,6 +89,11 @@
network_api_extensions: *api_extensions
devstack_localrc:
NETWORK_API_EXTENSIONS: "{{ network_api_extensions | join(',') }}"
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
neutron_plugin_options:
ipv6_metadata: False
- job:
name: neutron-tempest-plugin-scenario-openvswitch-iptables_hybrid-train
@ -99,6 +104,11 @@
network_api_extensions: *api_extensions
devstack_localrc:
NETWORK_API_EXTENSIONS: "{{ network_api_extensions | join(',') }}"
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
neutron_plugin_options:
ipv6_metadata: False
- job:
name: neutron-tempest-plugin-scenario-linuxbridge-train
@ -109,6 +119,11 @@
network_api_extensions: *api_extensions
devstack_localrc:
NETWORK_API_EXTENSIONS: "{{ network_api_extensions | join(',') }}"
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
neutron_plugin_options:
ipv6_metadata: False
- job:
name: neutron-tempest-plugin-dvr-multinode-scenario-train

View File

@ -93,6 +93,11 @@
network_api_extensions: *api_extensions
devstack_localrc:
NETWORK_API_EXTENSIONS: "{{ network_api_extensions | join(',') }}"
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
neutron_plugin_options:
ipv6_metadata: False
- job:
name: neutron-tempest-plugin-scenario-openvswitch-iptables_hybrid-ussuri
@ -103,6 +108,11 @@
network_api_extensions: *api_extensions
devstack_localrc:
NETWORK_API_EXTENSIONS: "{{ network_api_extensions | join(',') }}"
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
neutron_plugin_options:
ipv6_metadata: False
- job:
name: neutron-tempest-plugin-scenario-linuxbridge-ussuri
@ -113,6 +123,11 @@
network_api_extensions: *api_extensions
devstack_localrc:
NETWORK_API_EXTENSIONS: "{{ network_api_extensions | join(',') }}"
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
neutron_plugin_options:
ipv6_metadata: False
- job:
name: neutron-tempest-plugin-scenario-ovn-ussuri