Fix for test_cross_tenant_traffic failed
This test fails due to wrong floating ips creating
This is the fix for downstream patches: https://gerrit.mcp.mirantis.net/#/q/I8baa3e61789b0553b9f85214b60c9e0b8dafde31
Related-prod: PROD-23364, PROD-22634
Change-Id: I11f184a393575e01c2dc00d2bde4289738d9acb8
(cherry picked from commit 220425bd000d7a4f07f695a7c8ad603be5f9cbf6)
(cherry picked from commit a7902f979ecdfdb49a5d722c8db762b452dcb2d0)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 3fa1667..8d25bff 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -83,7 +83,6 @@
if CONF.service_available.cinder:
cls.volumes_client = cls.os_primary.volumes_client_latest
cls.snapshots_client = cls.os_primary.snapshots_client_latest
- cls.backups_client = cls.os_primary.backups_client_latest
# ## Test functions library
#
@@ -94,10 +93,6 @@
if not client:
client = self.ports_client
name = data_utils.rand_name(self.__class__.__name__)
- if CONF.network.port_vnic_type and 'binding:vnic_type' not in kwargs:
- kwargs['binding:vnic_type'] = CONF.network.port_vnic_type
- if CONF.network.port_profile and 'binding:profile' not in kwargs:
- kwargs['binding:profile'] = CONF.network.port_profile
result = client.create_port(
name=name,
network_id=network_id,
@@ -146,18 +141,13 @@
vnic_type = CONF.network.port_vnic_type
profile = CONF.network.port_profile
- # If vnic_type or profile are configured create port for
+ # If vnic_type is configured create port for
# every network
- if vnic_type or profile:
+ if vnic_type:
ports = []
- create_port_body = {}
- if vnic_type:
- create_port_body['binding:vnic_type'] = vnic_type
-
- if profile:
- create_port_body['binding:profile'] = profile
-
+ create_port_body = {'binding:vnic_type': vnic_type,
+ 'binding:profile': profile}
if kwargs:
# Convert security group names to security group ids
# to pass to create_port
@@ -249,37 +239,6 @@
volume = self.volumes_client.show_volume(volume['id'])['volume']
return volume
- def create_backup(self, volume_id, name=None, description=None,
- force=False, snapshot_id=None, incremental=False,
- container=None):
-
- name = name or data_utils.rand_name(
- self.__class__.__name__ + "-backup")
- kwargs = {'name': name,
- 'description': description,
- 'force': force,
- 'snapshot_id': snapshot_id,
- 'incremental': incremental,
- 'container': container}
- backup = self.backups_client.create_backup(volume_id=volume_id,
- **kwargs)['backup']
- self.addCleanup(self.backups_client.delete_backup, backup['id'])
- waiters.wait_for_volume_resource_status(self.backups_client,
- backup['id'], 'available')
- return backup
-
- def restore_backup(self, backup_id):
- restore = self.backups_client.restore_backup(backup_id)['restore']
- self.addCleanup(self.volumes_client.delete_volume,
- restore['volume_id'])
- waiters.wait_for_volume_resource_status(self.backups_client,
- backup_id, 'available')
- waiters.wait_for_volume_resource_status(self.volumes_client,
- restore['volume_id'],
- 'available')
- self.assertEqual(backup_id, restore['backup_id'])
- return restore
-
def create_volume_snapshot(self, volume_id, name=None, description=None,
metadata=None, force=False):
name = name or data_utils.rand_name(
@@ -295,15 +254,15 @@
self.addCleanup(self.snapshots_client.delete_snapshot, snapshot['id'])
waiters.wait_for_volume_resource_status(self.snapshots_client,
snapshot['id'], 'available')
- snapshot = self.snapshots_client.show_snapshot(
- snapshot['id'])['snapshot']
return snapshot
def create_volume_type(self, client=None, name=None, backend_name=None):
if not client:
- client = self.os_admin.volume_types_client_latest
- randomized_name = name or data_utils.rand_name(
- 'volume-type-' + self.__class__.__name__)
+ client = self.os_admin.volume_types_v2_client
+ if not name:
+ class_name = self.__class__.__name__
+ name = data_utils.rand_name(class_name + '-volume-type')
+ randomized_name = data_utils.rand_name('scenario-type-' + name)
LOG.debug("Creating a volume type: %s on backend %s",
randomized_name, backend_name)
@@ -447,9 +406,7 @@
disk_format=img_disk_format,
properties=img_properties)
except IOError:
- LOG.warning(
- "A(n) %s image was not found. Retrying with uec image.",
- img_disk_format)
+ LOG.debug("A qcow2 image was not found. Try to get a uec image.")
kernel = self._image_create('scenario-aki', 'aki', aki_img_path)
ramdisk = self._image_create('scenario-ari', 'ari', ari_img_path)
properties = {'kernel_id': kernel, 'ramdisk_id': ramdisk}
@@ -547,7 +504,7 @@
volume['id'], 'available')
def ping_ip_address(self, ip_address, should_succeed=True,
- ping_timeout=None, mtu=None, server=None):
+ ping_timeout=None, mtu=None):
timeout = ping_timeout or CONF.validation.ping_timeout
cmd = ['ping', '-c1', '-w1']
@@ -581,16 +538,12 @@
'caller': caller, 'ip': ip_address, 'timeout': timeout,
'result': 'expected' if result else 'unexpected'
})
- if server:
- self._log_console_output([server])
return result
def check_vm_connectivity(self, ip_address,
username=None,
private_key=None,
should_connect=True,
- extra_msg="",
- server=None,
mtu=None):
"""Check server connectivity
@@ -600,36 +553,43 @@
:param should_connect: True/False indicates positive/negative test
positive - attempt ping and ssh
negative - attempt ping and fail if succeed
- :param extra_msg: Message to help with debugging if ``ping_ip_address``
- fails
- :param server: The server whose console to log for debugging
:param mtu: network MTU to use for connectivity validation
:raises: AssertError if the result of the connectivity check does
not match the value of the should_connect param
"""
- LOG.debug('checking network connections to IP %s with user: %s',
- ip_address, username)
if should_connect:
msg = "Timed out waiting for %s to become reachable" % ip_address
else:
msg = "ip address %s is reachable" % ip_address
- if extra_msg:
- msg = "%s\n%s" % (extra_msg, msg)
self.assertTrue(self.ping_ip_address(ip_address,
should_succeed=should_connect,
- mtu=mtu, server=server),
+ mtu=mtu),
msg=msg)
if should_connect:
# no need to check ssh for negative connectivity
- try:
- self.get_remote_client(ip_address, username, private_key,
- server=server)
- except Exception:
- if not extra_msg:
- extra_msg = 'Failed to ssh to %s' % ip_address
- LOG.exception(extra_msg)
- raise
+ self.get_remote_client(ip_address, username, private_key)
+
+ def check_public_network_connectivity(self, ip_address, username,
+ private_key, should_connect=True,
+ msg=None, servers=None, mtu=None):
+ # The target login is assumed to have been configured for
+ # key-based authentication by cloud-init.
+ LOG.debug('checking network connections to IP %s with user: %s',
+ ip_address, username)
+ try:
+ self.check_vm_connectivity(ip_address,
+ username,
+ private_key,
+ should_connect=should_connect,
+ mtu=mtu)
+ except Exception:
+ ex_msg = 'Public network connectivity check failed'
+ if msg:
+ ex_msg += ": " + msg
+ LOG.exception(ex_msg)
+ self._log_console_output(servers)
+ raise
def create_floating_ip(self, thing, pool_name=None):
"""Create a floating IP and associates to a server on Nova"""
@@ -646,10 +606,9 @@
return floating_ip
def create_timestamp(self, ip_address, dev_name=None, mount_path='/mnt',
- private_key=None, server=None):
+ private_key=None):
ssh_client = self.get_remote_client(ip_address,
- private_key=private_key,
- server=server)
+ private_key=private_key)
if dev_name is not None:
ssh_client.make_fs(dev_name)
ssh_client.exec_command('sudo mount /dev/%s %s' % (dev_name,
@@ -663,10 +622,9 @@
return timestamp
def get_timestamp(self, ip_address, dev_name=None, mount_path='/mnt',
- private_key=None, server=None):
+ private_key=None):
ssh_client = self.get_remote_client(ip_address,
- private_key=private_key,
- server=server)
+ private_key=private_key)
if dev_name is not None:
ssh_client.mount(dev_name, mount_path)
timestamp = ssh_client.exec_command('sudo cat %s/timestamp'
@@ -812,13 +770,8 @@
return subnet
def _get_server_port_id_and_ip4(self, server, ip_addr=None):
- if ip_addr:
- ports = self.os_admin.ports_client.list_ports(
- device_id=server['id'],
- fixed_ips='ip_address=%s' % ip_addr)['ports']
- else:
- ports = self.os_admin.ports_client.list_ports(
- device_id=server['id'])['ports']
+ ports = self.os_admin.ports_client.list_ports(
+ device_id=server['id'], fixed_ip=ip_addr)['ports']
# A port can have more than one IP address in some cases.
# If the network is dual-stack (IPv4 + IPv6), this port
# is associated with 2 subnets
@@ -839,9 +792,9 @@
# port on instance at once, and use it here
for pm in port_map:
try:
- port = waiters.wait_for_interface_status(self.interface_client,
- server['id'],
- pm["id"], p_status)
+ port = waiters.wait_for_interface_status(
+ self.os_admin.interfaces_client,
+ server['id'], pm["id"], p_status)
pm["status"] = port['port_state']
except lib_exc.TimeoutException:
# NOTE(pas-ha) as server might have several IPv4 ports
@@ -1223,9 +1176,9 @@
@classmethod
def setup_clients(cls):
super(EncryptionScenarioTest, cls).setup_clients()
- cls.admin_volume_types_client = cls.os_admin.volume_types_client_latest
+ cls.admin_volume_types_client = cls.os_admin.volume_types_v2_client
cls.admin_encryption_types_client =\
- cls.os_admin.encryption_types_client_latest
+ cls.os_admin.encryption_types_v2_client
def create_encryption_type(self, client=None, type_id=None, provider=None,
key_size=None, cipher=None,