Move calling pylxd.client after Tempest tests initialized

This commit moves calling pylxd.client.Client into resource_setup(). If
we have this in __init__(), the test list command `tempest run -l` is
failed without lxd client settings. It's not desirable. And this commit
also renamed variables for lxd client in the code to avoid confusion
with the other clients.

Change-Id: I5498789b2b1e4be6727b6520fc80ce3bace25cf3
This commit is contained in:
Masayuki Igawa 2019-02-21 13:22:40 +09:00
parent 0ea07af2a2
commit 046f58dc1f
No known key found for this signature in database
GPG Key ID: 290F53EDC899BF89
2 changed files with 11 additions and 14 deletions

View File

@ -25,10 +25,6 @@ CONF = config.CONF
class LXDServersTestJSON(base.BaseV2ComputeAdminTest):
disk_config = 'AUTO'
def __init__(self, *args, **kwargs):
super(LXDServersTestJSON, self).__init__(*args, **kwargs)
self.client = client.Client()
@classmethod
def setup_credentials(cls):
cls.prepare_instance_network()
@ -37,6 +33,7 @@ class LXDServersTestJSON(base.BaseV2ComputeAdminTest):
@classmethod
def setup_clients(cls):
super(LXDServersTestJSON, cls).setup_clients()
cls.lxd = client.Client()
cls.client = cls.os_admin.servers_client
cls.flavors_client = cls.os_admin.flavors_client
@ -64,7 +61,7 @@ class LXDServersTestJSON(base.BaseV2ComputeAdminTest):
def test_profile_configuration(self):
# Verify that the profile was created
profile = self.client.profiles.get(
profile = self.lxd.profiles.get(
self.server['OS-EXT-SRV-ATTR:instance_name'])
self.assertEqual(
@ -82,7 +79,7 @@ class LXDServersTestJSON(base.BaseV2ComputeAdminTest):
# the amount stated by the flavor
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
profile = self.client.profiles.get(
profile = self.lxd.profiles.get(
self.server['OS-EXT-SRV-ATTR:instance_name'])
self.assertEqual(
'%s' % flavor['vcpus'], profile.config['limits.cpu'])
@ -92,7 +89,7 @@ class LXDServersTestJSON(base.BaseV2ComputeAdminTest):
# the amount stated by the flavor
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
profile = self.client.profiles.get(
profile = self.lxd.profiles.get(
self.server['OS-EXT-SRV-ATTR:instance_name'])
self.assertEqual(
'%sMB' % flavor['ram'], profile.config['limits.memory'])
@ -100,20 +97,20 @@ class LXDServersTestJSON(base.BaseV2ComputeAdminTest):
def test_verify_server_root_size(self):
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
profile = self.client.profiles.get(
profile = self.lxd.profiles.get(
self.server['OS-EXT-SRV-ATTR:instance_name'])
self.assertEqual(
'%sGB' % flavor['disk'], profile.devices['root']['size'])
def test_verify_console_log(self):
# Verify that the console log for the container exists
profile = self.client.profiles.get(
profile = self.lxd.profiles.get(
self.server['OS-EXT-SRV-ATTR:instance_name'])
self.assertIn('lxc.console.logfile', profile.config['raw.lxc'])
def test_verify_network_configuration(self):
# Verify network is configured for the instance
profile = self.client.profiles.get(
profile = self.lxd.profiles.get(
self.server['OS-EXT-SRV-ATTR:instance_name'])
for device in profile.devices:
if 'root' not in device:
@ -125,9 +122,9 @@ class LXDServersTestJSON(base.BaseV2ComputeAdminTest):
def test_container_configuration_valid(self):
# Verify container configuration is correct
profile = self.client.profiles.get(
profile = self.lxd.profiles.get(
self.server['OS-EXT-SRV-ATTR:instance_name'])
container = self.client.containers.get(
container = self.lxd.containers.get(
self.server['OS-EXT-SRV-ATTR:instance_name'])
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']

View File

@ -30,7 +30,6 @@ class LXDVolumeTests(base.BaseV2ComputeAdminTest):
def __init__(self, *args, **kwargs):
super(LXDVolumeTests, self).__init__(*args, **kwargs)
self.attachment = None
self.client = client.Client()
@classmethod
def setup_credentials(cls):
@ -40,6 +39,7 @@ class LXDVolumeTests(base.BaseV2ComputeAdminTest):
@classmethod
def setup_clients(cls):
super(LXDVolumeTests, cls).setup_clients()
cls.lxd = client.Client()
cls.client = cls.os_admin.servers_client
cls.flavors_client = cls.os_admin.flavors_client
@ -97,7 +97,7 @@ class LXDVolumeTests(base.BaseV2ComputeAdminTest):
# for volumes
volume = self._create_and_attach_volume(self.server)
profile = self.client.profiles.get(
profile = self.lxd.profiles.get(
self.server['OS-EXT-SRV-ATTR:instance_name'])
self.assertIn(volume['id'], [device for device in profile.devices])