From bd86fab09de776dab953f41cc4ccfc2cc26d50a1 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Tue, 19 Dec 2023 10:39:40 +0100 Subject: [PATCH] Test coverage for stable compute UUID This only covers that happy path of the feature. We agreed that the error paths are hard to cover here and we rely on the nova functional test instead. There are two new config options: * [compute_feature_enable]stable_compute_uuid_supported defaulted to False to skip the tests for old deployments not having the feature. * [whitebox-nova-compute]state_path defaulted to /var/lib/nova, to allow running the tests in deployments that are using a non default nova state path configuration (like devstack) The devstack plugin is modified to set [whitebox-nova-compute]state_path according to the devstack nova configuration. Change-Id: I520bd61b6ab479a36098586f7296822703a24fb0 --- .zuul.yaml | 1 + devstack/plugin.sh | 5 ++ .../api/compute/test_compute_id.py | 52 +++++++++++++++++++ whitebox_tempest_plugin/config.py | 19 +++++-- 4 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 whitebox_tempest_plugin/api/compute/test_compute_id.py diff --git a/.zuul.yaml b/.zuul.yaml index db01a080..39ba9813 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -64,6 +64,7 @@ $TEMPEST_CONFIG: compute-feature-enabled: volume_backed_live_migration: true + stable_compute_uuid_supported: true auth: tempest_roles: creator post-config: diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 90990c97..57e80ea5 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -33,6 +33,11 @@ function configure { iniset $TEMPEST_CONFIG compute-feature-enabled uefi_secure_boot "$COMPUTE_FEATURE_UEFI_SECURE_BOOT" iniset $TEMPEST_CONFIG compute-feature-enabled vtpm_device_supported "$COMPUTE_FEATURE_VTPM_ENABLED" iniset $TEMPEST_CONFIG compute-feature-enabled live_migrate_back_and_forth "$COMPUTE_FEATURE_LIVE_MIGRATE_BACK_AND_FORTH" + + # matching devstack/lib/nova + # https://github.com/openstack/devstack/blob/6b0f055b4ed407f8a190f768d0e654235ac015dd/lib/nova#L46C36-L46C50 + iniset $TEMPEST_CONFIG whitebox-nova-compute state_path $DATA_DIR/nova + } if [[ "$1" == "stack" ]]; then diff --git a/whitebox_tempest_plugin/api/compute/test_compute_id.py b/whitebox_tempest_plugin/api/compute/test_compute_id.py new file mode 100644 index 00000000..b59e14a5 --- /dev/null +++ b/whitebox_tempest_plugin/api/compute/test_compute_id.py @@ -0,0 +1,52 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os + +from tempest import config + +from whitebox_tempest_plugin.api.compute import base +from whitebox_tempest_plugin.services import clients + +CONF = config.CONF + + +class TestStableCpuId(base.BaseWhiteboxComputeTest): + """Test nova-compute generates a proper compute_id at startup. + """ + min_microversion = '2.53' + + @classmethod + def skip_checks(cls): + super(TestStableCpuId, cls).skip_checks() + if not CONF.compute_feature_enabled.stable_compute_uuid_supported: + raise cls.skipException( + 'Deployment requires support for stable compute UUID feature. ' + 'Set [compute-feature-enabled]stable_compute_uuid_supported ' + 'to True to enable these tests.') + + def test_compute_id_file_match_db_state(self): + compute_id_path = os.path.join( + CONF.whitebox_nova_compute.state_path, "compute_id") + hypervisors = self.os_admin.hypervisor_client.list_hypervisors( + )["hypervisors"] + for hypervisor in hypervisors: + name = hypervisor['hypervisor_hostname'] + ssh_client = clients.SSHClient(name) + uuid_on_disk = ssh_client.execute(f'cat {compute_id_path}') + self.assertEqual( + hypervisor['id'], + uuid_on_disk, + f"Compute UUID does not match on {name}: " + f"on disk: {uuid_on_disk}, in DB: {hypervisor['id']}", + ) diff --git a/whitebox_tempest_plugin/config.py b/whitebox_tempest_plugin/config.py index 73d36f21..761fab1c 100644 --- a/whitebox_tempest_plugin/config.py +++ b/whitebox_tempest_plugin/config.py @@ -128,7 +128,7 @@ general_opts = [ cfg.IntOpt( 'max_disk_devices_to_attach', default=None, - help='Maximum number of disks allowed to attach to a singler server') + help='Maximum number of disks allowed to attach to a singler server'), ] nova_compute_group = cfg.OptGroup( @@ -142,7 +142,12 @@ nova_compute_opts = [ choices=["journalctl", "zgrep"], help="Name of the utility to run LogParserClient commands. " "Currently, supported values are 'journalctl' (default) " - "for devstack and 'zgrep' for TripleO") + "for devstack and 'zgrep' for TripleO"), + cfg.StrOpt( + 'state_path', + default="/var/lib/nova", + help='The [DEFAULT]state_path passed to nova-compute. ' + 'Defaults to the default of nova'), ] database_group = cfg.OptGroup( @@ -308,5 +313,13 @@ compute_features_group_opts = [ cfg.BoolOpt('vgpu_cold_migration_supported', default=False, help='Cold migration and resize supported for guest instances ' - 'with vGPU devices') + 'with vGPU devices'), + cfg.BoolOpt('stable_compute_uuid_supported', + default=False, + help='Stable compute UUID feature is supported for the ' + 'deployment. This feature is available since 2023.1 ' + '(Antelope) upstream. If the deployment does not use the ' + 'default value of [DEFAULT]state_path in the nova-compute' + 'config, then [whitebox-nova-compute]state_path also ' + 'needs to be configured'), ]