Merge "Ensure we close the file accounts file after reading"
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index 20aa440..798bd30 100644
--- a/tempest/api/compute/admin/test_quotas_negative.py
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -109,7 +109,10 @@
quota_set = self.adm_client.show_quota_set(self.demo_tenant_id)
default_sg_quota = quota_set['security_groups']
- sg_quota = 0 # Set the quota to zero to conserve resources
+
+ # Set the quota to number of used security groups
+ sg_quota = self.limits_client.show_limits()['absolute'][
+ 'totalSecurityGroupsUsed']
quota_set =\
self.adm_client.update_quota_set(self.demo_tenant_id,
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 37c1e0a..759bb8c 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -266,8 +266,8 @@
@classmethod
def prepare_instance_network(cls):
- if (CONF.compute.ssh_auth_method != 'disabled' and
- CONF.compute.ssh_connect_method == 'floating'):
+ if (CONF.validation.auth_method != 'disabled' and
+ CONF.validation.connect_method == 'floating'):
cls.set_network_resources(network=True, subnet=True, router=True,
dhcp=True)
@@ -294,7 +294,7 @@
return image
@classmethod
- def rebuild_server(cls, server_id, **kwargs):
+ def rebuild_server(cls, server_id, validatable=False, **kwargs):
# Destroy an existing server and creates a new one
if server_id:
try:
@@ -302,7 +302,11 @@
cls.servers_client.wait_for_server_termination(server_id)
except Exception:
LOG.exception('Failed to delete server %s' % server_id)
- server = cls.create_test_server(wait_until='ACTIVE', **kwargs)
+
+ server = cls.create_test_server(
+ validatable,
+ wait_until='ACTIVE',
+ **kwargs)
cls.password = server['adminPass']
return server['id']
@@ -320,6 +324,21 @@
"""Deletes the given volume and waits for it to be gone."""
cls._delete_volume(cls.volumes_extensions_client, volume_id)
+ @classmethod
+ def get_server_ip(cls, server):
+ """Get the server fixed or floating IP.
+
+ For the floating IP, the address created by the validation resources
+ is returned.
+ For the fixed IP, the server is returned and the current mechanism of
+ address extraction in the remote_client is followed.
+ """
+ if CONF.validation.connect_method == 'floating':
+ ip_or_server = cls.validation_resources['floating_ip']['ip']
+ elif CONF.validation.connect_method == 'fixed':
+ ip_or_server = server
+ return ip_or_server
+
class BaseV2ComputeTest(BaseComputeTest):
_api_version = 2
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index 2f78e9d..1a74e52 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -69,6 +69,11 @@
raise cls.skipException(skip_msg)
@classmethod
+ def setup_credentials(cls):
+ cls.prepare_instance_network()
+ super(ImagesOneServerNegativeTestJSON, cls).setup_credentials()
+
+ @classmethod
def setup_clients(cls):
super(ImagesOneServerNegativeTestJSON, cls).setup_clients()
cls.client = cls.images_client
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 94b6cf0..39447b8 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -103,8 +103,11 @@
# Verify that the number of vcpus reported by the instance matches
# the amount stated by the flavor
flavor = self.flavors_client.show_flavor(self.flavor_ref)
- linux_client = remote_client.RemoteClient(self.server, self.ssh_user,
- self.password)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(self.server),
+ self.ssh_user,
+ self.password,
+ self.validation_resources['keypair']['private_key'])
self.assertEqual(flavor['vcpus'], linux_client.get_number_of_vcpus())
@test.idempotent_id('ac1ad47f-984b-4441-9274-c9079b7a0666')
@@ -112,8 +115,11 @@
'Instance validation tests are disabled.')
def test_host_name_is_same_as_server_name(self):
# Verify the instance host name is the same as the server name
- linux_client = remote_client.RemoteClient(self.server, self.ssh_user,
- self.password)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(self.server),
+ self.ssh_user,
+ self.password,
+ self.validation_resources['keypair']['private_key'])
self.assertTrue(linux_client.hostname_equals_servername(self.name))
@test.idempotent_id('ed20d3fb-9d1f-4329-b160-543fbd5d9811')
@@ -202,12 +208,22 @@
disk_config = 'AUTO'
@classmethod
- def setup_clients(cls):
+ def setup_credentials(cls):
cls.prepare_instance_network()
+ super(ServersWithSpecificFlavorTestJSON, cls).setup_credentials()
+
+ @classmethod
+ def setup_clients(cls):
super(ServersWithSpecificFlavorTestJSON, cls).setup_clients()
cls.flavor_client = cls.os_adm.flavors_client
cls.client = cls.servers_client
+ @classmethod
+ def resource_setup(cls):
+ cls.set_validation_resources()
+
+ super(ServersWithSpecificFlavorTestJSON, cls).resource_setup()
+
@test.idempotent_id('b3c7bcfc-bb5b-4e22-b517-c7f686b802ca')
@testtools.skipUnless(CONF.validation.run_validation,
'Instance validation tests are disabled.')
@@ -258,24 +274,37 @@
admin_pass = self.image_ssh_password
server_no_eph_disk = (self.create_test_server(
+ validatable=True,
wait_until='ACTIVE',
adminPass=admin_pass,
flavor=flavor_no_eph_disk_id))
- server_with_eph_disk = (self.create_test_server(
- wait_until='ACTIVE',
- adminPass=admin_pass,
- flavor=flavor_with_eph_disk_id))
+
# Get partition number of server without extra specs.
server_no_eph_disk = self.client.show_server(
server_no_eph_disk['id'])
- linux_client = remote_client.RemoteClient(server_no_eph_disk,
- self.ssh_user, admin_pass)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server_no_eph_disk),
+ self.ssh_user,
+ admin_pass,
+ self.validation_resources['keypair']['private_key'])
partition_num = len(linux_client.get_partitions().split('\n'))
+ # Explicit server deletion necessary for Juno compatibility
+ self.client.delete_server(server_no_eph_disk['id'])
+
+ server_with_eph_disk = (self.create_test_server(
+ validatable=True,
+ wait_until='ACTIVE',
+ adminPass=admin_pass,
+ flavor=flavor_with_eph_disk_id))
+
server_with_eph_disk = self.client.show_server(
server_with_eph_disk['id'])
- linux_client = remote_client.RemoteClient(server_with_eph_disk,
- self.ssh_user, admin_pass)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server_with_eph_disk),
+ self.ssh_user,
+ admin_pass,
+ self.validation_resources['keypair']['private_key'])
partition_num_emph = len(linux_client.get_partitions().split('\n'))
self.assertEqual(partition_num + 1, partition_num_emph)
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index b95250a..f0f6b8c 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -46,26 +46,35 @@
self.server_id, 'ACTIVE')
except lib_exc.NotFound:
# The server was deleted by previous test, create a new one
- server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(
+ validatable=True,
+ wait_until='ACTIVE')
self.__class__.server_id = server['id']
except Exception:
# Rebuild server if something happened to it during a test
- self.__class__.server_id = self.rebuild_server(self.server_id)
+ self.__class__.server_id = self.rebuild_server(self.server_id,
+ validatable=True)
def tearDown(self):
self.server_check_teardown()
super(ServerActionsTestJSON, self).tearDown()
@classmethod
+ def setup_credentials(cls):
+ cls.prepare_instance_network()
+ super(ServerActionsTestJSON, cls).setup_credentials()
+
+ @classmethod
def setup_clients(cls):
super(ServerActionsTestJSON, cls).setup_clients()
cls.client = cls.servers_client
@classmethod
def resource_setup(cls):
- cls.prepare_instance_network()
+ cls.set_validation_resources()
+
super(ServerActionsTestJSON, cls).resource_setup()
- cls.server_id = cls.rebuild_server(None)
+ cls.server_id = cls.rebuild_server(None, validatable=True)
@test.idempotent_id('6158df09-4b82-4ab3-af6d-29cf36af858d')
@testtools.skipUnless(CONF.compute_feature_enabled.change_password,
@@ -76,28 +85,36 @@
self.client.change_password(self.server_id, new_password)
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- if self.run_ssh:
+ if CONF.validation.run_validation:
# Verify that the user can authenticate with the new password
server = self.client.show_server(self.server_id)
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- new_password)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server),
+ self.ssh_user,
+ new_password)
linux_client.validate_authentication()
def _test_reboot_server(self, reboot_type):
- if self.run_ssh:
+ if CONF.validation.run_validation:
# Get the time the server was last rebooted,
server = self.client.show_server(self.server_id)
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- self.password)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server),
+ self.ssh_user,
+ self.password,
+ self.validation_resources['keypair']['private_key'])
boot_time = linux_client.get_boot_time()
self.client.reboot(self.server_id, reboot_type)
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- if self.run_ssh:
+ if CONF.validation.run_validation:
# Log in and verify the boot time has changed
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- self.password)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server),
+ self.ssh_user,
+ self.password,
+ self.validation_resources['keypair']['private_key'])
new_boot_time = linux_client.get_boot_time()
self.assertTrue(new_boot_time > boot_time,
'%s > %s' % (new_boot_time, boot_time))
@@ -157,10 +174,13 @@
self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
self.assertEqual(new_name, server['name'])
- if self.run_ssh:
- # Verify that the user can authenticate with the provided password
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- password)
+ if CONF.validation.run_validation:
+ # TODO(jlanoux) add authentication with the provided password
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(rebuilt_server),
+ self.ssh_user,
+ self.password,
+ self.validation_resources['keypair']['private_key'])
linux_client.validate_authentication()
@test.idempotent_id('30449a88-5aff-4f9b-9866-6ee9b17f906d')
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 0496063..8e4278a 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -44,6 +44,8 @@
@classmethod
def resource_setup(cls):
+ cls.set_validation_resources()
+
super(AttachVolumeTestJSON, cls).resource_setup()
cls.device = CONF.compute.volume_device_name
@@ -62,8 +64,10 @@
def _create_and_attach(self):
# Start a server and wait for it to become ready
admin_pass = self.image_ssh_password
- self.server = self.create_test_server(wait_until='ACTIVE',
- adminPass=admin_pass)
+ self.server = self.create_test_server(
+ validatable=True,
+ wait_until='ACTIVE',
+ adminPass=admin_pass)
# Record addresses so that we can ssh later
self.server['addresses'] = (
@@ -101,9 +105,12 @@
waiters.wait_for_server_status(self.servers_client, self.server['id'],
'ACTIVE')
- linux_client = remote_client.RemoteClient(self.server,
- self.image_ssh_user,
- self.server['adminPass'])
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(self.server),
+ self.image_ssh_user,
+ self.server['adminPass'],
+ self.validation_resources['keypair']['private_key'])
+
partitions = linux_client.get_partitions()
self.assertIn(self.device, partitions)
@@ -117,9 +124,12 @@
waiters.wait_for_server_status(self.servers_client, self.server['id'],
'ACTIVE')
- linux_client = remote_client.RemoteClient(self.server,
- self.image_ssh_user,
- self.server['adminPass'])
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(self.server),
+ self.image_ssh_user,
+ self.server['adminPass'],
+ self.validation_resources['keypair']['private_key'])
+
partitions = linux_client.get_partitions()
self.assertNotIn(self.device, partitions)