Merge "Add more verbose info for wait_for_..._status methods"
diff --git a/tempest/api/baremetal/admin/test_ports.py b/tempest/api/baremetal/admin/test_ports.py
index b3f9b7f..3392ab9 100644
--- a/tempest/api/baremetal/admin/test_ports.py
+++ b/tempest/api/baremetal/admin/test_ports.py
@@ -57,11 +57,13 @@
_, body = self.client.show_port(uuid)
self._assertExpected(port, body)
+ @test.skip_because(bug='1398350')
@test.attr(type='smoke')
def test_create_port_with_extra(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- extra = {'key': 'value'}
+ extra = {'str': 'value', 'int': 123, 'float': 0.123,
+ 'bool': True, 'list': [1, 2, 3], 'dict': {'foo': 'bar'}}
_, port = self.create_port(node_id=node_id, address=address,
extra=extra)
@@ -224,6 +226,7 @@
_, body = self.client.show_port(port['uuid'])
self.assertEqual(extra, body['extra'])
+ @test.skip_because(bug='1398350')
@test.attr(type='smoke')
def test_update_port_mixed_ops(self):
node_id = self.node['uuid']
@@ -234,7 +237,7 @@
extra=extra)
new_address = data_utils.rand_mac_address()
- new_extra = {'key1': 'new-value1', 'key3': 'new-value3'}
+ new_extra = {'key1': 0.123, 'key3': {'cat': 'meow'}}
patch = [{'path': '/address',
'op': 'replace',
diff --git a/tempest/api/baremetal/admin/test_ports_negative.py b/tempest/api/baremetal/admin/test_ports_negative.py
index ead3799..8080eb6 100644
--- a/tempest/api/baremetal/admin/test_ports_negative.py
+++ b/tempest/api/baremetal/admin/test_ports_negative.py
@@ -34,15 +34,6 @@
self.create_port, node_id=node_id, address=address)
@test.attr(type=['negative', 'smoke'])
- def test_create_port_malformed_extra(self):
- node_id = self.node['uuid']
- address = data_utils.rand_mac_address()
- extra = {'key': 0.123}
- self.assertRaises(exc.BadRequest,
- self.create_port, node_id=node_id,
- address=address, extra=extra)
-
- @test.attr(type=['negative', 'smoke'])
def test_create_port_nonexsistent_node_id(self):
node_id = str(data_utils.rand_uuid())
address = data_utils.rand_mac_address()
@@ -160,31 +151,6 @@
'value': new_address}])
@test.attr(type=['negative', 'smoke'])
- def test_update_port_add_malformed_extra(self):
- node_id = self.node['uuid']
- address = data_utils.rand_mac_address()
-
- _, port = self.create_port(node_id=node_id, address=address)
- port_id = port['uuid']
-
- self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
- [{'path': '/extra/key', ' op': 'add',
- 'value': 0.123}])
-
- @test.attr(type=['negative', 'smoke'])
- def test_update_port_add_whole_malformed_extra(self):
- node_id = self.node['uuid']
- address = data_utils.rand_mac_address()
-
- _, port = self.create_port(node_id=node_id, address=address)
- port_id = port['uuid']
-
- self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
- [{'path': '/extra',
- 'op': 'add',
- 'value': [1, 2, 3, 4, 'a']}])
-
- @test.attr(type=['negative', 'smoke'])
def test_update_port_add_nonexistent_property(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
@@ -257,37 +223,6 @@
self.client.update_port, port_id, patch)
@test.attr(type=['negative', 'smoke'])
- def test_update_port_replace_extra_item_with_malformed(self):
- node_id = self.node['uuid']
- address = data_utils.rand_mac_address()
- extra = {'key': 'value'}
-
- _, port = self.create_port(node_id=node_id, address=address,
- extra=extra)
- port_id = port['uuid']
-
- patch = [{'path': '/extra/key',
- 'op': 'replace',
- 'value': 0.123}]
- self.assertRaises(exc.BadRequest,
- self.client.update_port, port_id, patch)
-
- @test.attr(type=['negative', 'smoke'])
- def test_update_port_replace_whole_extra_with_malformed(self):
- node_id = self.node['uuid']
- address = data_utils.rand_mac_address()
-
- _, port = self.create_port(node_id=node_id, address=address)
- port_id = port['uuid']
-
- patch = [{'path': '/extra',
- 'op': 'replace',
- 'value': [1, 2, 3, 4, 'a']}]
-
- self.assertRaises(exc.BadRequest,
- self.client.update_port, port_id, patch)
-
- @test.attr(type=['negative', 'smoke'])
def test_update_port_replace_nonexistent_property(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
diff --git a/tempest/api/network/test_fwaas_extensions.py b/tempest/api/network/test_fwaas_extensions.py
index 12b8887..0c36820 100644
--- a/tempest/api/network/test_fwaas_extensions.py
+++ b/tempest/api/network/test_fwaas_extensions.py
@@ -38,6 +38,8 @@
Update firewall policy
Insert firewall rule to policy
Remove firewall rule from policy
+ Insert firewall rule after/before rule in policy
+ Update firewall policy audited attribute
Delete firewall policy
Show firewall policy
List firewall
@@ -222,14 +224,14 @@
self.client.delete_firewall(firewall_id)
@test.attr(type='smoke')
- def test_insert_remove_firewall_rule_from_policy(self):
+ def test_firewall_rule_insertion_position_removal_rule_from_policy(self):
# Create firewall rule
resp, body = self.client.create_firewall_rule(
name=data_utils.rand_name("fw-rule"),
action="allow",
protocol="tcp")
- fw_rule_id = body['firewall_rule']['id']
- self.addCleanup(self._try_delete_rule, fw_rule_id)
+ fw_rule_id1 = body['firewall_rule']['id']
+ self.addCleanup(self._try_delete_rule, fw_rule_id1)
# Create firewall policy
_, body = self.client.create_firewall_policy(
name=data_utils.rand_name("fw-policy"))
@@ -238,19 +240,76 @@
# Insert rule to firewall policy
self.client.insert_firewall_rule_in_policy(
- fw_policy_id, fw_rule_id, '', '')
+ fw_policy_id, fw_rule_id1, '', '')
# Verify insertion of rule in policy
- self.assertIn(fw_rule_id, self._get_list_fw_rule_ids(fw_policy_id))
+ self.assertIn(fw_rule_id1, self._get_list_fw_rule_ids(fw_policy_id))
+ # Create another firewall rule
+ _, body = self.client.create_firewall_rule(
+ name=data_utils.rand_name("fw-rule"),
+ action="allow",
+ protocol="icmp")
+ fw_rule_id2 = body['firewall_rule']['id']
+ self.addCleanup(self._try_delete_rule, fw_rule_id2)
+
+ # Insert rule to firewall policy after the first rule
+ self.client.insert_firewall_rule_in_policy(
+ fw_policy_id, fw_rule_id2, fw_rule_id1, '')
+
+ # Verify the posiition of rule after insertion
+ _, fw_rule = self.client.show_firewall_rule(
+ fw_rule_id2)
+
+ self.assertEqual(int(fw_rule['firewall_rule']['position']), 2)
# Remove rule from the firewall policy
self.client.remove_firewall_rule_from_policy(
- fw_policy_id, fw_rule_id)
+ fw_policy_id, fw_rule_id2)
+ # Insert rule to firewall policy before the first rule
+ self.client.insert_firewall_rule_in_policy(
+ fw_policy_id, fw_rule_id2, '', fw_rule_id1)
+ # Verify the posiition of rule after insertion
+ _, fw_rule = self.client.show_firewall_rule(
+ fw_rule_id2)
+ self.assertEqual(int(fw_rule['firewall_rule']['position']), 1)
+ # Remove rule from the firewall policy
+ self.client.remove_firewall_rule_from_policy(
+ fw_policy_id, fw_rule_id2)
+ # Verify removal of rule from firewall policy
+ self.assertNotIn(fw_rule_id2, self._get_list_fw_rule_ids(fw_policy_id))
+
+ # Remove rule from the firewall policy
+ self.client.remove_firewall_rule_from_policy(
+ fw_policy_id, fw_rule_id1)
# Verify removal of rule from firewall policy
- self.assertNotIn(fw_rule_id, self._get_list_fw_rule_ids(fw_policy_id))
+ self.assertNotIn(fw_rule_id1, self._get_list_fw_rule_ids(fw_policy_id))
def _get_list_fw_rule_ids(self, fw_policy_id):
_, fw_policy = self.client.show_firewall_policy(
fw_policy_id)
return [ruleid for ruleid in fw_policy['firewall_policy']
['firewall_rules']]
+
+ def test_update_firewall_policy_audited_attribute(self):
+ # Create firewall rule
+ _, body = self.client.create_firewall_rule(
+ name=data_utils.rand_name("fw-rule"),
+ action="allow",
+ protocol="icmp")
+ fw_rule_id = body['firewall_rule']['id']
+ self.addCleanup(self._try_delete_rule, fw_rule_id)
+ # Create firewall policy
+ _, body = self.client.create_firewall_policy(
+ name=data_utils.rand_name('fw-policy'))
+ fw_policy_id = body['firewall_policy']['id']
+ self.addCleanup(self._try_delete_policy, fw_policy_id)
+ self.assertFalse(body['firewall_policy']['audited'])
+ # Update firewall policy audited attribute to ture
+ self.client.update_firewall_policy(fw_policy_id,
+ audited=True)
+ # Insert Firewall rule to firewall policy
+ self.client.insert_firewall_rule_in_policy(
+ fw_policy_id, fw_rule_id, '', '')
+ _, body = self.client.show_firewall_policy(
+ fw_policy_id)
+ self.assertFalse(body['firewall_policy']['audited'])
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 0e3cd92..52e48f3 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -145,10 +145,6 @@
pass
-class BaseVolumeV1Test(BaseVolumeTest):
- _api_version = 1
-
-
class BaseVolumeAdminTest(BaseVolumeTest):
"""Base test case class for all Volume Admin API tests."""
@classmethod
@@ -222,7 +218,3 @@
except exceptions.NotFound:
# The qos_specs may have already been deleted which is OK.
pass
-
-
-class BaseVolumeV1AdminTest(BaseVolumeAdminTest):
- _api_version = 1
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 522aa43..551a27d 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -297,7 +297,19 @@
return secgroup
- def get_remote_client(self, server_or_ip, username=None, private_key=None):
+ def get_remote_client(self, server_or_ip, username=None, private_key=None,
+ log_console_of_servers=None):
+ """Get a SSH client to a remote server
+
+ @param server_or_ip a server object as returned by Tempest compute
+ client or an IP address to connect to
+ @param username name of the Linux account on the remote server
+ @param private_key the SSH private key to use
+ @param log_console_of_servers a list of server objects. Each server
+ in the list will have its console printed in the logs in case the
+ SSH connection failed to be established
+ @return a RemoteClient object
+ """
if isinstance(server_or_ip, six.string_types):
ip = server_or_ip
else:
@@ -312,9 +324,13 @@
pkey=private_key)
try:
linux_client.validate_authentication()
- except exceptions.SSHTimeout:
- LOG.exception('ssh connection to %s failed' % ip)
+ except Exception:
+ LOG.exception('Initializing SSH connection to %s failed' % ip)
debug.log_net_debug()
+ # If we don't explicitely set for which servers we want to
+ # log the console output then all the servers will be logged.
+ # See the definition of _log_console_output()
+ self._log_console_output(log_console_of_servers)
raise
return linux_client
diff --git a/tempest/scenario/orchestration/test_server_cfn_init.py b/tempest/scenario/orchestration/test_server_cfn_init.py
index ddfabe4..f09f00c 100644
--- a/tempest/scenario/orchestration/test_server_cfn_init.py
+++ b/tempest/scenario/orchestration/test_server_cfn_init.py
@@ -119,14 +119,8 @@
if self.keypair:
# Check that the user can authenticate with the generated
# keypair
- try:
- linux_client = self.get_remote_client(
- server_ip, username='ec2-user')
- linux_client.validate_authentication()
- except (exceptions.ServerUnreachable,
- exceptions.SSHTimeout) as e:
- self._log_console_output(servers=[server])
- raise e
+ self.get_remote_client(server_ip, username='ec2-user',
+ log_console_of_servers=[server])
@test.attr(type='slow')
@test.skip_because(bug='1374175')
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 59af6b3..16a65c9 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -14,7 +14,6 @@
# under the License.
from tempest.common import custom_matchers
-from tempest.common import debug
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
@@ -89,17 +88,6 @@
self.servers_client.reboot(self.server['id'], 'SOFT')
self._wait_for_server_status('ACTIVE')
- def ssh_to_server(self):
- try:
- self.linux_client = self.get_remote_client(self.floating_ip['ip'])
- except Exception as e:
- LOG.exception('ssh to server failed')
- self._log_console_output()
- # network debug is called as part of ssh init
- if not isinstance(e, test.exceptions.SSHTimeout):
- debug.log_net_debug()
- raise
-
def check_partitions(self):
# NOTE(andreaf) The device name may be different on different guest OS
partitions = self.linux_client.get_partitions()
@@ -147,7 +135,9 @@
self.floating_ip = self.create_floating_ip(self.server)
self.create_and_add_security_group()
- self.ssh_to_server()
+
+ self.linux_client = self.get_remote_client(self.floating_ip['ip'])
self.nova_reboot()
- self.ssh_to_server()
+
+ self.linux_client = self.get_remote_client(self.floating_ip['ip'])
self.check_partitions()
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index 7e512a9..23743c5 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -88,15 +88,10 @@
self.floating_ips_client.associate_floating_ip_to_server(
floating_ip['ip'], self.instance['id'])
# Check ssh
- try:
- self.get_remote_client(
- server_or_ip=floating_ip['ip'],
- username=self.image_utils.ssh_user(self.image_ref),
- private_key=self.keypair['private_key'])
- except Exception:
- LOG.exception('ssh to server failed')
- self._log_console_output()
- raise
+ self.get_remote_client(
+ server_or_ip=floating_ip['ip'],
+ username=self.image_utils.ssh_user(self.image_ref),
+ private_key=self.keypair['private_key'])
@test.services('compute', 'network')
def test_server_basicops(self):
diff --git a/tempest/scenario/test_snapshot_pattern.py b/tempest/scenario/test_snapshot_pattern.py
index 159585b..5cb7c99 100644
--- a/tempest/scenario/test_snapshot_pattern.py
+++ b/tempest/scenario/test_snapshot_pattern.py
@@ -47,21 +47,13 @@
def _add_keypair(self):
self.keypair = self.create_keypair()
- def _ssh_to_server(self, server_or_ip):
- try:
- return self.get_remote_client(server_or_ip)
- except Exception:
- LOG.exception('Initializing SSH connection failed')
- self._log_console_output()
- raise
-
def _write_timestamp(self, server_or_ip):
- ssh_client = self._ssh_to_server(server_or_ip)
+ ssh_client = self.get_remote_client(server_or_ip)
ssh_client.exec_command('date > /tmp/timestamp; sync')
self.timestamp = ssh_client.exec_command('cat /tmp/timestamp')
def _check_timestamp(self, server_or_ip):
- ssh_client = self._ssh_to_server(server_or_ip)
+ ssh_client = self.get_remote_client(server_or_ip)
got_timestamp = ssh_client.exec_command('cat /tmp/timestamp')
self.assertEqual(self.timestamp, got_timestamp)
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index dd115e7..c584a6e 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -110,14 +110,8 @@
network_name_for_ssh = CONF.compute.network_for_ssh
ip = server.networks[network_name_for_ssh][0]
- try:
- return self.get_remote_client(
- ip,
- private_key=keypair['private_key'])
- except Exception:
- LOG.exception('ssh to server failed')
- self._log_console_output(servers=[server])
- raise
+ return self.get_remote_client(ip, private_key=keypair['private_key'],
+ log_console_of_servers=[server])
def _get_content(self, ssh_client):
return ssh_client.exec_command('cat /tmp/text')