whitebox-tempest-plugin/whitebox_tempest_plugin/plugin.py
James Parker 9a309d64c6 Add vgpu guest creation testcase
Purpose of this commit is to test basic server creation while attaching
a vGPU device as documented for KVM systems here [1].

The commit adds a new whitebox configuration group ‘whitebox-hardware’.
This group currently contains one parameters: vgpu_vendor_id. It works
as both a skip check for the new testcase and as the specific gpu vendor
id to look for when analyzing the guest.

The new test method, test_create_vgpu_instance, was added to the file
test_vgpu.py in the test class VGPUTest. The test creates the necessary
flavor to launch a guest with an attached vgpu device and creates an
instance. It then ssh’s into the guest and validates the vgpu vendor id
is present when checking /sys/bus/pci/devices/<pci_address>/vendor.

A helper method get_pci_address() was lifted from nova.pci.utils [2].
This method is used to assemble the PCI components that are pulled from
the guest instance's device xml.

[1] https://docs.openstack.org/nova/train/admin/virtual-gpu.html
[2] https://github.com/openstack/nova/blob/master/nova/pci/utils.py

Change-Id: I736c0bf59c8c9c14aa8848d59077ef51071ffbbe
2020-05-07 13:59:55 -04:00

57 lines
2.3 KiB
Python

# Copyright 2015
# All Rights Reserved.
#
# 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 tempest.test_discover import plugins
from whitebox_tempest_plugin import config as whitebox_config
class WhiteboxTempestPlugin(plugins.TempestPlugin):
def load_tests(self):
base_path = os.path.split(os.path.dirname(
os.path.abspath(__file__)))[0]
test_dir = 'whitebox_tempest_plugin/api'
full_test_dir = os.path.join(base_path, test_dir)
return full_test_dir, base_path
def register_opts(self, conf):
config.register_opt_group(conf, whitebox_config.general_group,
whitebox_config.general_opts)
config.register_opt_group(conf, whitebox_config.nova_compute_group,
whitebox_config.nova_compute_opts)
config.register_opt_group(conf, whitebox_config.database_group,
whitebox_config.database_opts)
config.register_opt_group(conf, whitebox_config.nova_libvirt_group,
whitebox_config.nova_libvirt_opts)
config.register_opt_group(conf, whitebox_config.hardware_group,
whitebox_config.hardware_opts)
def get_opt_lists(self):
return [(whitebox_config.general_group.name,
whitebox_config.general_opts),
(whitebox_config.nova_compute_group.name,
whitebox_config.nova_compute_opts),
(whitebox_config.nova_libvirt_group.name,
whitebox_config.nova_libvirt_opts),
(whitebox_config.database_group.name,
whitebox_config.database_opts),
(whitebox_config.hardware_group.name,
whitebox_config.hardware_opts)]