Merge "Switch scenario jobs to nested-virt nodes"
diff --git a/neutron_tempest_plugin/scenario/test_internal_dns.py b/neutron_tempest_plugin/scenario/test_internal_dns.py
index c0a2c04..e9f7823 100644
--- a/neutron_tempest_plugin/scenario/test_internal_dns.py
+++ b/neutron_tempest_plugin/scenario/test_internal_dns.py
@@ -13,7 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_log import log
from tempest.common import utils
+from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from neutron_tempest_plugin.common import ssh
@@ -21,9 +23,63 @@
from neutron_tempest_plugin.scenario import base
CONF = config.CONF
+LOG = log.getLogger(__name__)
-class InternalDNSTest(base.BaseTempestTestCase):
+class InternalDNSBase(base.BaseTempestTestCase):
+ """Base class of useful resources and functionalities for test class."""
+
+ port_error_msg = ('Openstack command returned incorrect '
+ 'hostname value in port.')
+ ssh_error_msg = ('Remote shell command returned incorrect hostname value '
+ "(command: 'hostname' OR 'cat /etc/hostname').")
+
+ @staticmethod
+ def _rand_name(name):
+ """'data_utils.rand_name' wrapper, show name related to test suite."""
+ return data_utils.rand_name(f'internal-dns-test-{name}')
+
+ @classmethod
+ def resource_setup(cls):
+ super(InternalDNSBase, cls).resource_setup()
+ cls.router = cls.create_router_by_client()
+ cls.keypair = cls.create_keypair(
+ name=cls._rand_name('shared-keypair'))
+ cls.secgroup = cls.create_security_group(
+ name=cls._rand_name('shared-secgroup'))
+ cls.security_groups.append(cls.secgroup)
+ cls.create_loginable_secgroup_rule(
+ secgroup_id=cls.secgroup['id'])
+ cls.vm_kwargs = {
+ 'flavor_ref': CONF.compute.flavor_ref,
+ 'image_ref': CONF.compute.image_ref,
+ 'key_name': cls.keypair['name'],
+ 'security_groups': [{'name': cls.secgroup['name']}]
+ }
+
+ def _create_ssh_client(self, ip_addr):
+ return ssh.Client(ip_addr,
+ CONF.validation.image_ssh_user,
+ pkey=self.keypair['private_key'])
+
+ def _validate_port_dns_details(self, checked_hostname, checked_port):
+ """Validates reused objects for correct dns values in tests."""
+ dns_details = checked_port['dns_assignment'][0]
+ self.assertEqual(checked_hostname, checked_port['dns_name'],
+ self.port_error_msg)
+ self.assertEqual(checked_hostname, dns_details['hostname'],
+ self.port_error_msg)
+ self.assertIn(checked_hostname, dns_details['fqdn'],
+ self.port_error_msg)
+
+ def _validate_ssh_dns_details(self, checked_hostname, ssh_client):
+ """Validates correct dns values returned from ssh command in tests."""
+ ssh_output = ssh_client.get_hostname()
+ self.assertIn(checked_hostname, ssh_output, self.ssh_error_msg)
+
+
+class InternalDNSTest(InternalDNSBase):
+ """Tests internal DNS capabilities."""
credentials = ['primary', 'admin']
@utils.requires_ext(extension="dns-integration", service="network")
@@ -52,8 +108,6 @@
security_groups=[
{'name': self.security_groups[-1]['name']}],
name='leia')
- self.wait_for_server_active(leia['server'])
- self.wait_for_guest_os_ready(leia['server'])
ssh_client = ssh.Client(
self.fip['floating_ip_address'],
@@ -82,3 +136,41 @@
servers=[self.server, leia])
self.check_remote_connectivity(ssh_client, 'leia.openstackgate.local',
servers=[self.server, leia])
+
+ @utils.requires_ext(extension="dns-integration", service="network")
+ @decorators.idempotent_id('db5e612f-f17f-4974-b5f1-9fe89f4a6fc9')
+ def test_create_port_with_dns_name(self):
+ """Test creation of port with correct internal dns-name (hostname)."""
+
+ # 1) Create network and subnet.
+ # 2) Create a port with dns-name.
+ # 3) Verify that correct port initial dns-name (as VM name)
+ # were queried from openstack API.
+ # 4) Boot a VM with predefined port.
+ # 5) Validate hostname configured in VM is same as VM's name.
+
+ # NOTE: VM's hostname has to be the same as VM's name
+ # when a VM is created, it is a known limitation.
+ # Therefore VM's dns-name/hostname is checked to be as VM's name.
+
+ vm_name = self._rand_name('vm')
+ # create resources
+ network = self.create_network(name=self._rand_name('network'))
+ subnet = self.create_subnet(network, name=self._rand_name('subnet'))
+ self.create_router_interface(self.router['id'], subnet['id'])
+ # create port with dns-name (as VM name)
+ dns_port = self.create_port(network,
+ dns_name=vm_name,
+ security_groups=[self.secgroup['id']],
+ name=self._rand_name('port'))
+ # validate dns port initial hostname from API
+ self._validate_port_dns_details(vm_name, dns_port)
+ # create VM with predefined dns-name on port
+ vm_1 = self.create_server(name=vm_name,
+ networks=[{'port': dns_port['id']}],
+ **self.vm_kwargs)
+ # validate hostname configured in VM is same as VM's name.
+ vm_1['fip'] = self.create_floatingip(port=dns_port)
+ vm_1['ssh_client'] = self._create_ssh_client(
+ vm_1['fip']['floating_ip_address'])
+ self._validate_ssh_dns_details(vm_name, vm_1['ssh_client'])
diff --git a/neutron_tempest_plugin/scenario/test_mac_learning.py b/neutron_tempest_plugin/scenario/test_mac_learning.py
index 736d46c..6cd894f 100644
--- a/neutron_tempest_plugin/scenario/test_mac_learning.py
+++ b/neutron_tempest_plugin/scenario/test_mac_learning.py
@@ -14,8 +14,10 @@
# under the License.
from oslo_log import log
+from paramiko import ssh_exception as ssh_exc
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
+from tempest.lib import exceptions as lib_exc
from neutron_tempest_plugin.common import ssh
from neutron_tempest_plugin.common import utils
@@ -116,17 +118,22 @@
pkey=self.keypair['private_key'])
return server
- def _check_cmd_installed_on_server(self, ssh_client, server_id, cmd):
+ def _check_cmd_installed_on_server(self, ssh_client, server, cmd):
try:
ssh_client.execute_script('which %s' % cmd)
+ except (lib_exc.SSHTimeout, ssh_exc.AuthenticationException) as ssh_e:
+ LOG.debug(ssh_e)
+ self._log_console_output([server])
+ self._log_local_network_status()
+ raise
except exceptions.SSHScriptFailed:
raise self.skipException(
- "%s is not available on server %s" % (cmd, server_id))
+ "%s is not available on server %s" % (cmd, server['id']))
def _prepare_sender(self, server, address):
check_script = get_sender_script(self.sender_output_file, address,
self.completed_message)
- self._check_cmd_installed_on_server(server['ssh_client'], server['id'],
+ self._check_cmd_installed_on_server(server['ssh_client'], server,
'tcpdump')
server['ssh_client'].execute_script(
'echo "%s" > %s' % (check_script, self.sender_script_file))
@@ -135,7 +142,7 @@
check_script = get_receiver_script(
result_file=self.output_file,
packets_expected=n_packets)
- self._check_cmd_installed_on_server(server['ssh_client'], server['id'],
+ self._check_cmd_installed_on_server(server['ssh_client'], server,
'tcpdump')
server['ssh_client'].execute_script(
'echo "%s" > %s' % (check_script, self.receiver_script_file))
diff --git a/neutron_tempest_plugin/scenario/test_multicast.py b/neutron_tempest_plugin/scenario/test_multicast.py
index 726d1e0..acfb75c 100644
--- a/neutron_tempest_plugin/scenario/test_multicast.py
+++ b/neutron_tempest_plugin/scenario/test_multicast.py
@@ -16,8 +16,10 @@
import netaddr
from neutron_lib import constants
from oslo_log import log
+from paramiko import ssh_exception as ssh_exc
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
+from tempest.lib import exceptions as lib_exc
from neutron_tempest_plugin.common import ip
from neutron_tempest_plugin.common import ssh
@@ -210,15 +212,20 @@
self.username,
pkey=self.keypair['private_key'])
self._check_cmd_installed_on_server(server['ssh_client'],
- server['id'], PYTHON3_BIN)
+ server, PYTHON3_BIN)
return server
- def _check_cmd_installed_on_server(self, ssh_client, server_id, cmd):
+ def _check_cmd_installed_on_server(self, ssh_client, server, cmd):
try:
ssh_client.execute_script('which %s' % cmd)
+ except (lib_exc.SSHTimeout, ssh_exc.AuthenticationException) as ssh_e:
+ LOG.debug(ssh_e)
+ self._log_console_output([server])
+ self._log_local_network_status()
+ raise
except exceptions.SSHScriptFailed:
raise self.skipException(
- "%s is not available on server %s" % (cmd, server_id))
+ "%s is not available on server %s" % (cmd, server['id']))
def _prepare_sender(self, server, mcast_address):
check_script = get_sender_script(
@@ -237,7 +244,7 @@
server['fip']['floating_ip_address'],
self.username,
pkey=self.keypair['private_key'])
- self._check_cmd_installed_on_server(ssh_client, server['id'],
+ self._check_cmd_installed_on_server(ssh_client, server,
PYTHON3_BIN)
server['ssh_client'].execute_script(
'echo "%s" > /tmp/multicast_traffic_receiver.py' % check_script)
@@ -253,7 +260,7 @@
check_script = get_unregistered_script(
interface=port_iface, group=mcast_address,
result_file=self.unregistered_output_file)
- self._check_cmd_installed_on_server(ssh_client, server['id'],
+ self._check_cmd_installed_on_server(ssh_client, server,
'tcpdump')
server['ssh_client'].execute_script(
'echo "%s" > /tmp/unregistered_traffic_receiver.sh' % check_script)
diff --git a/neutron_tempest_plugin/scenario/test_ports.py b/neutron_tempest_plugin/scenario/test_ports.py
index fb2d2b0..c661d39 100644
--- a/neutron_tempest_plugin/scenario/test_ports.py
+++ b/neutron_tempest_plugin/scenario/test_ports.py
@@ -107,8 +107,8 @@
if port is not None:
break
except Exception as e:
- LOG.warn('Failed to create Port, using Fixed_IP:{}, '
- 'the Error was:{}'.format(ip, e))
+ LOG.warning('Failed to create Port, using Fixed_IP:{}, '
+ 'the Error was:{}'.format(ip, e))
fip, server = self._create_instance_with_port(port)
self.check_connectivity(fip[0]['floating_ip_address'],
CONF.validation.image_ssh_user,
diff --git a/neutron_tempest_plugin/scenario/test_trunk.py b/neutron_tempest_plugin/scenario/test_trunk.py
index b86c019..b994775 100644
--- a/neutron_tempest_plugin/scenario/test_trunk.py
+++ b/neutron_tempest_plugin/scenario/test_trunk.py
@@ -114,11 +114,6 @@
vlan_tag=segmentation_id,
vlan_subnet=vlan_subnet)
- for server in server_list:
- self.check_connectivity(
- host=vm.floating_ip['floating_ip_address'],
- ssh_client=vm.ssh_client)
-
return server_list
def _check_servers_remote_connectivity(self, vms=None,
@@ -197,6 +192,10 @@
self._wait_for_trunk(trunk=vm.trunk)
self._wait_for_port(port=vm.port)
self._wait_for_port(port=vm.subport)
+ self.check_connectivity(
+ host=vm.floating_ip['floating_ip_address'],
+ ssh_client=vm.ssh_client,
+ servers=[vm.server])
ip_command = ip.IPCommand(ssh_client=vm.ssh_client)
for address in ip_command.list_addresses(port=vm.port):