Merge "Update accessing nova compute logs for RBD check"

This commit is contained in:
Zuul 2024-10-08 02:03:38 +00:00 committed by Gerrit Code Review
commit 8e2eef0dde
4 changed files with 49 additions and 35 deletions

View File

@ -168,6 +168,7 @@
whitebox-tempest-plugin: https://opendev.org/openstack/whitebox-tempest-plugin.git whitebox-tempest-plugin: https://opendev.org/openstack/whitebox-tempest-plugin.git
tempest_test_regex: '^whitebox_tempest_plugin.api.compute.test_rbd_direct_download' tempest_test_regex: '^whitebox_tempest_plugin.api.compute.test_rbd_direct_download'
devstack_localrc: devstack_localrc:
NOVA_SERVICE_REPORT_INTERVAL: 10
COMPUTE_FEATURE_RBD_DOWNLOAD: True COMPUTE_FEATURE_RBD_DOWNLOAD: True
TEMPEST_PLUGINS: /opt/stack/whitebox-tempest-plugin TEMPEST_PLUGINS: /opt/stack/whitebox-tempest-plugin
WHITEBOX_PRIVKEY_PATH: /home/tempest/.ssh/id_rsa WHITEBOX_PRIVKEY_PATH: /home/tempest/.ssh/id_rsa

View File

@ -38,37 +38,42 @@ class TestRBDDirectDownload(base.BaseWhiteboxComputeTest):
raise cls.skipException(skip_msg) raise cls.skipException(skip_msg)
def test_rbd_logs_and_conf(self): def test_rbd_logs_and_conf(self):
base_server = self.create_test_server(wait_until='ACTIVE') with self.config_all_computes(
image = self.create_image_from_server( ('libvirt', 'images_type', 'default'),
base_server['id'], ):
name='base-server-img',
wait_until='ACTIVE'
)
# Creating a server from above image ensures a fresh
# attempt is made to download an image from the rbd
# pool to the local compute
server = self.create_test_server(wait_until='ACTIVE',
image_id=image['id'])
# Grab image id from newly created server base_server = self.create_test_server(wait_until='ACTIVE')
detailed_server_data = \ image = self.create_image_from_server(
self.os_admin.servers_client.show_server(server['id'])['server'] base_server['id'],
image_id = detailed_server_data['image']['id'] name='base-server-img',
wait_until='ACTIVE'
)
# Creating a server from above image ensures a fresh
# attempt is made to download an image from the rbd
# pool to the local compute
server = self.create_test_server(wait_until='ACTIVE',
image_id=image['id'])
host = self.get_host_for_server(server['id']) # Grab image id from newly created server
host_sm = clients.NovaServiceManager(host, 'nova-compute', detailed_server_data = \
self.os_admin.services_client) self.os_admin.servers_client.show_server(server['id'])
rbd_pool = host_sm.get_conf_opt('glance', 'rbd_pool') image_id = detailed_server_data['server']['image']['id']
# Assert RBD direct download conf options
self.assertEqual('images', rbd_pool) host = self.get_host_for_server(server['id'])
self.assertTrue(host_sm.get_conf_opt('glance', 'enable_rbd_download')) host_sm = clients.NovaServiceManager(
log_query_string = f"Attempting to export RBD image: " \ host, 'nova-compute', self.os_admin.services_client)
f"[[]pool_name: {rbd_pool}[]] [[]image_uuid: " \ rbd_pool = host_sm.get_conf_opt('glance', 'rbd_pool')
f"{image_id}[]]" # Assert RBD direct download conf options
logs_client = clients.LogParserClient(host) self.assertEqual('images', rbd_pool)
# Assert if log with specified image is found self.assertTrue(host_sm.get_conf_opt('glance',
self.assertTrue(len(logs_client.parse(log_query_string))) 'enable_rbd_download'))
path = self.get_server_blockdevice_path(server['id'], 'vda') log_query_string = f"Attempting to export RBD image: " \
# Assert image disk is present in ephemeral f"[[]pool_name: {rbd_pool}[]] [[]image_uuid: " \
# instances_path and not in rbd f"{image_id}[]]"
self.assertIsNotNone(path) and self.assertNotIn('rbd', path) logs_client = clients.LogParserClient(host)
# Assert if log with specified image is found
self.assertTrue(len(logs_client.parse(log_query_string)))
path = self.get_server_blockdevice_path(server['id'], 'vda')
# Assert image disk is present in ephemeral
# instances_path and not in rbd
self.assertIsNotNone(path) and self.assertNotIn('rbd', path)

View File

@ -153,6 +153,10 @@ nova_compute_opts = [
help="Name of the utility to run LogParserClient commands. " help="Name of the utility to run LogParserClient commands. "
"Currently, supported values are 'journalctl' (default) " "Currently, supported values are 'journalctl' (default) "
"for devstack and 'zgrep' for TripleO"), "for devstack and 'zgrep' for TripleO"),
cfg.StrOpt(
'journalctl_unit',
default="devstack@n-cpu",
help="Unit to access when doing log query via journalctl"),
cfg.StrOpt( cfg.StrOpt(
'state_path', 'state_path',
default="/var/lib/nova", default="/var/lib/nova",

View File

@ -89,10 +89,14 @@ class LogParserClient(SSHClient):
def parse(self, query_string): def parse(self, query_string):
log_query_command = CONF.whitebox_nova_compute.log_query_command log_query_command = CONF.whitebox_nova_compute.log_query_command
if log_query_command == 'zgrep': if log_query_command == 'zgrep':
command = 'sh -c "zgrep \'%s\' /var/log/nova/*"' % query_string command = f'sh -c "zgrep \'{query_string}\' /var/log/nova/*"'
else: else:
command = 'journalctl -u devstack@n-cpu -g \'%s\'' % query_string unit = CONF.whitebox_nova_compute.journalctl_unit
return self.execute(command, container_name='nova_compute', sudo=True) command = f'journalctl -u {unit} -g \'{query_string}\''
services_dict = self.host_parameters.get('services', {})
nova_compute_srvc = services_dict.get('nova-compute')
container_name = nova_compute_srvc.get('container_name')
return self.execute(command, container_name=container_name, sudo=True)
class QEMUImgClient(SSHClient): class QEMUImgClient(SSHClient):