diff --git a/.zuul.yaml b/.zuul.yaml index f7a80632..bd72ab28 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -168,6 +168,7 @@ whitebox-tempest-plugin: https://opendev.org/openstack/whitebox-tempest-plugin.git tempest_test_regex: '^whitebox_tempest_plugin.api.compute.test_rbd_direct_download' devstack_localrc: + NOVA_SERVICE_REPORT_INTERVAL: 10 COMPUTE_FEATURE_RBD_DOWNLOAD: True TEMPEST_PLUGINS: /opt/stack/whitebox-tempest-plugin WHITEBOX_PRIVKEY_PATH: /home/tempest/.ssh/id_rsa diff --git a/whitebox_tempest_plugin/api/compute/test_rbd_direct_download.py b/whitebox_tempest_plugin/api/compute/test_rbd_direct_download.py index 722f688a..d1928f52 100644 --- a/whitebox_tempest_plugin/api/compute/test_rbd_direct_download.py +++ b/whitebox_tempest_plugin/api/compute/test_rbd_direct_download.py @@ -38,37 +38,42 @@ class TestRBDDirectDownload(base.BaseWhiteboxComputeTest): raise cls.skipException(skip_msg) def test_rbd_logs_and_conf(self): - base_server = self.create_test_server(wait_until='ACTIVE') - image = self.create_image_from_server( - 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']) + with self.config_all_computes( + ('libvirt', 'images_type', 'default'), + ): - # Grab image id from newly created server - detailed_server_data = \ - self.os_admin.servers_client.show_server(server['id'])['server'] - image_id = detailed_server_data['image']['id'] + base_server = self.create_test_server(wait_until='ACTIVE') + image = self.create_image_from_server( + 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']) - host = self.get_host_for_server(server['id']) - host_sm = clients.NovaServiceManager(host, 'nova-compute', - self.os_admin.services_client) - rbd_pool = host_sm.get_conf_opt('glance', 'rbd_pool') - # Assert RBD direct download conf options - self.assertEqual('images', rbd_pool) - self.assertTrue(host_sm.get_conf_opt('glance', 'enable_rbd_download')) - log_query_string = f"Attempting to export RBD image: " \ - f"[[]pool_name: {rbd_pool}[]] [[]image_uuid: " \ - f"{image_id}[]]" - 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) + # Grab image id from newly created server + detailed_server_data = \ + self.os_admin.servers_client.show_server(server['id']) + image_id = detailed_server_data['server']['image']['id'] + + host = self.get_host_for_server(server['id']) + host_sm = clients.NovaServiceManager( + host, 'nova-compute', self.os_admin.services_client) + rbd_pool = host_sm.get_conf_opt('glance', 'rbd_pool') + # Assert RBD direct download conf options + self.assertEqual('images', rbd_pool) + self.assertTrue(host_sm.get_conf_opt('glance', + 'enable_rbd_download')) + log_query_string = f"Attempting to export RBD image: " \ + f"[[]pool_name: {rbd_pool}[]] [[]image_uuid: " \ + f"{image_id}[]]" + 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) diff --git a/whitebox_tempest_plugin/config.py b/whitebox_tempest_plugin/config.py index 033aeb4d..2516b4cf 100644 --- a/whitebox_tempest_plugin/config.py +++ b/whitebox_tempest_plugin/config.py @@ -153,6 +153,10 @@ nova_compute_opts = [ help="Name of the utility to run LogParserClient commands. " "Currently, supported values are 'journalctl' (default) " "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( 'state_path', default="/var/lib/nova", diff --git a/whitebox_tempest_plugin/services/clients.py b/whitebox_tempest_plugin/services/clients.py index a414815f..2c7a2f9a 100644 --- a/whitebox_tempest_plugin/services/clients.py +++ b/whitebox_tempest_plugin/services/clients.py @@ -89,10 +89,14 @@ class LogParserClient(SSHClient): def parse(self, query_string): log_query_command = CONF.whitebox_nova_compute.log_query_command 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: - command = 'journalctl -u devstack@n-cpu -g \'%s\'' % query_string - return self.execute(command, container_name='nova_compute', sudo=True) + unit = CONF.whitebox_nova_compute.journalctl_unit + 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):