Merge "tests: Move single use constants to their callers"

This commit is contained in:
Zuul 2020-07-24 09:24:35 +00:00 committed by Gerrit Code Review
commit 32114ef1ed
3 changed files with 38 additions and 40 deletions

View File

@ -19,11 +19,9 @@ Provides common functionality for integrated unit tests
import collections
import random
import six
import string
import time
import os_traits
from oslo_concurrency import lockutils
from oslo_log import log as logging
import oslo_messaging as messaging
@ -583,44 +581,6 @@ class ProviderUsageBaseTestCase(test.TestCase, InstanceHelperMixin):
microversion = 'latest'
# These must match the capabilities in
# nova.virt.libvirt.driver.LibvirtDriver.capabilities
expected_libvirt_driver_capability_traits = set([
six.u(trait) for trait in [
os_traits.COMPUTE_ACCELERATORS,
os_traits.COMPUTE_DEVICE_TAGGING,
os_traits.COMPUTE_NET_ATTACH_INTERFACE,
os_traits.COMPUTE_NET_ATTACH_INTERFACE_WITH_TAG,
os_traits.COMPUTE_VOLUME_ATTACH_WITH_TAG,
os_traits.COMPUTE_VOLUME_EXTEND,
os_traits.COMPUTE_VOLUME_MULTI_ATTACH,
os_traits.COMPUTE_TRUSTED_CERTS,
os_traits.COMPUTE_IMAGE_TYPE_AKI,
os_traits.COMPUTE_IMAGE_TYPE_AMI,
os_traits.COMPUTE_IMAGE_TYPE_ARI,
os_traits.COMPUTE_IMAGE_TYPE_ISO,
os_traits.COMPUTE_IMAGE_TYPE_QCOW2,
os_traits.COMPUTE_IMAGE_TYPE_RAW,
os_traits.COMPUTE_RESCUE_BFV,
]
])
# These must match the capabilities in
# nova.virt.fake.FakeDriver.capabilities
expected_fake_driver_capability_traits = set([
six.u(trait) for trait in [
os_traits.COMPUTE_ACCELERATORS,
os_traits.COMPUTE_IMAGE_TYPE_RAW,
os_traits.COMPUTE_DEVICE_TAGGING,
os_traits.COMPUTE_NET_ATTACH_INTERFACE,
os_traits.COMPUTE_NET_ATTACH_INTERFACE_WITH_TAG,
os_traits.COMPUTE_VOLUME_ATTACH_WITH_TAG,
os_traits.COMPUTE_VOLUME_EXTEND,
os_traits.COMPUTE_VOLUME_MULTI_ATTACH,
os_traits.COMPUTE_TRUSTED_CERTS,
]
])
def setUp(self):
self.flags(compute_driver=self.compute_driver)
super(ProviderUsageBaseTestCase, self).setUp()

View File

@ -51,6 +51,28 @@ class LibvirtReportTraitsTestBase(
class LibvirtReportTraitsTests(LibvirtReportTraitsTestBase):
# These must match the capabilities in
# nova.virt.libvirt.driver.LibvirtDriver.capabilities
expected_libvirt_driver_capability_traits = set([
trait for trait in [
ost.COMPUTE_ACCELERATORS,
ost.COMPUTE_DEVICE_TAGGING,
ost.COMPUTE_NET_ATTACH_INTERFACE,
ost.COMPUTE_NET_ATTACH_INTERFACE_WITH_TAG,
ost.COMPUTE_VOLUME_ATTACH_WITH_TAG,
ost.COMPUTE_VOLUME_EXTEND,
ost.COMPUTE_VOLUME_MULTI_ATTACH,
ost.COMPUTE_TRUSTED_CERTS,
ost.COMPUTE_IMAGE_TYPE_AKI,
ost.COMPUTE_IMAGE_TYPE_AMI,
ost.COMPUTE_IMAGE_TYPE_ARI,
ost.COMPUTE_IMAGE_TYPE_ISO,
ost.COMPUTE_IMAGE_TYPE_QCOW2,
ost.COMPUTE_IMAGE_TYPE_RAW,
ost.COMPUTE_RESCUE_BFV,
]
])
def test_report_cpu_traits(self):
self.assertEqual([], self._get_all_providers())
self.start_compute()

View File

@ -32,6 +32,22 @@ LOG = logging.getLogger(__name__)
class ProviderTreeTests(integrated_helpers.ProviderUsageBaseTestCase):
compute_driver = 'fake.MediumFakeDriver'
# These must match the capabilities in
# nova.virt.fake.FakeDriver.capabilities
expected_fake_driver_capability_traits = set([
trait for trait in [
os_traits.COMPUTE_ACCELERATORS,
os_traits.COMPUTE_IMAGE_TYPE_RAW,
os_traits.COMPUTE_DEVICE_TAGGING,
os_traits.COMPUTE_NET_ATTACH_INTERFACE,
os_traits.COMPUTE_NET_ATTACH_INTERFACE_WITH_TAG,
os_traits.COMPUTE_VOLUME_ATTACH_WITH_TAG,
os_traits.COMPUTE_VOLUME_EXTEND,
os_traits.COMPUTE_VOLUME_MULTI_ATTACH,
os_traits.COMPUTE_TRUSTED_CERTS,
]
])
def setUp(self):
super(ProviderTreeTests, self).setUp()
# Before starting compute, placement has no providers registered