Verify vTPM creation after svc restart
Ensure that vTPM creation is still possible after restarting the nova libvirt service. Also added a new client service for virtqemud that can start/stop the service. Updated the nova waiter to allow for checking status for either nova_compute or virtqemud. Originally the nova waiter would rely on just looking at results of compute services, specifically the state field to determine if nova_compute is up or down. Extend the nova waiter to check either the state field or the status field based on the service that is calling. Change-Id: I5895602b33c78698beec363fbc00bca876b3cefa
This commit is contained in:
parent
2a09062deb
commit
6b729ca1d3
@ -18,6 +18,7 @@ from tempest.exceptions import BuildErrorException
|
||||
from tempest.lib.services import clients
|
||||
|
||||
from whitebox_tempest_plugin.api.compute import base
|
||||
from whitebox_tempest_plugin.services import clients as wb_clients
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
@ -124,3 +125,12 @@ class VTPMTest(base.BaseWhiteboxComputeTest):
|
||||
self.create_test_server,
|
||||
flavor=vtpm_flavor['id'],
|
||||
wait_until='ACTIVE')
|
||||
|
||||
def test_vtpm_creation_after_virtqemud_restart(self):
|
||||
# Test validates vTPM instance creation after libvirt service restart
|
||||
hosts = self.list_compute_hosts()
|
||||
for host in hosts:
|
||||
host_svc = wb_clients.VirtQEMUdManager(
|
||||
host, 'libvirt', self.os_admin.services_client)
|
||||
host_svc.restart()
|
||||
self._vptm_server_creation_check('tpm-crb', '2.0')
|
||||
|
@ -19,14 +19,14 @@ from tempest.lib import exceptions as lib_exc
|
||||
from whitebox_tempest_plugin.exceptions import MigrationException
|
||||
|
||||
|
||||
def wait_for_nova_service_state(client, host, binary, state):
|
||||
def wait_for_nova_service_state(client, host, binary, status_field, state):
|
||||
timeout = client.build_timeout
|
||||
start_time = int(time.time())
|
||||
# NOTE(artom) Assumes that the (host, binary) combination will yield a
|
||||
# unique service. There is no service in Nova that can run multiple copies
|
||||
# on the same host.
|
||||
service = client.list_services(host=host, binary=binary)['services'][0]
|
||||
while service['state'] != state:
|
||||
while service[status_field] != state:
|
||||
time.sleep(client.build_interval)
|
||||
timed_out = int(time.time()) - start_time >= timeout
|
||||
if timed_out:
|
||||
|
@ -232,12 +232,14 @@ class NovaServiceManager(ServiceManager):
|
||||
super(NovaServiceManager, self).__init__(host, service)
|
||||
self.services_client = services_client
|
||||
self.host = host
|
||||
self.status_field = 'state'
|
||||
|
||||
def start(self):
|
||||
result = self.execute(self.start_command, sudo=True)
|
||||
waiters.wait_for_nova_service_state(self.services_client,
|
||||
self.host,
|
||||
self.service,
|
||||
self.status_field,
|
||||
'up')
|
||||
return result
|
||||
|
||||
@ -246,6 +248,7 @@ class NovaServiceManager(ServiceManager):
|
||||
waiters.wait_for_nova_service_state(self.services_client,
|
||||
self.host,
|
||||
self.service,
|
||||
self.status_field,
|
||||
'down')
|
||||
return result
|
||||
|
||||
@ -264,6 +267,37 @@ class NovaServiceManager(ServiceManager):
|
||||
return hardware.parse_cpu_spec(dedicated_set)
|
||||
|
||||
|
||||
class VirtQEMUdManager(ServiceManager):
|
||||
"""A services manager for Nova services that uses Nova's service API to be
|
||||
smarter about stopping and restarting services.
|
||||
"""
|
||||
|
||||
def __init__(self, host, service, services_client):
|
||||
super(VirtQEMUdManager, self).__init__(host, service)
|
||||
self.services_client = services_client
|
||||
self.binary = 'nova-compute'
|
||||
self.host = host
|
||||
self.status_field = 'status'
|
||||
|
||||
def start(self):
|
||||
result = self.execute(self.start_command, sudo=True)
|
||||
waiters.wait_for_nova_service_state(self.services_client,
|
||||
self.host,
|
||||
self.binary,
|
||||
self.status_field,
|
||||
'enabled')
|
||||
return result
|
||||
|
||||
def stop(self):
|
||||
result = self.execute(self.stop_command, sudo=True)
|
||||
waiters.wait_for_nova_service_state(self.services_client,
|
||||
self.host,
|
||||
self.binary,
|
||||
self.status_field,
|
||||
'disabled')
|
||||
return result
|
||||
|
||||
|
||||
class NUMAClient(SSHClient):
|
||||
"""A client to get host NUMA information. `numactl` needs to be installed
|
||||
in the environment or container(s).
|
||||
|
Loading…
Reference in New Issue
Block a user