Sync STANDARDS with placement/nova rc_fields
Two new standard resource classes were added in the time between when os-resource-classes was first created and now. This change adds the missing classes and adds a rather tedious sanity check to make sure that tests are updated when adding new classes. Change-Id: I00158c3167430e180040c71cd6e2d646f64372fa
This commit is contained in:
parent
df251458bf
commit
3d038f5ccc
|
@ -53,6 +53,12 @@ STANDARDS = [
|
|||
'IPV4_ADDRESS',
|
||||
'VGPU',
|
||||
'VGPU_DISPLAY_HEAD',
|
||||
# Standard resource class for network bandwidth egress measured in
|
||||
# kilobits per second.
|
||||
'NET_BW_EGR_KILOBIT_PER_SEC',
|
||||
# Standard resource class for network bandwidth ingress measured in
|
||||
# kilobits per second.
|
||||
'NET_BW_IGR_KILOBIT_PER_SEC',
|
||||
]
|
||||
|
||||
# Namespace used for custom resource classes
|
||||
|
|
|
@ -30,3 +30,21 @@ class TestOs_resource_classes(base.TestCase):
|
|||
def test_id_mapping_symbols(self):
|
||||
self.assertEqual(rc.VCPU, rc.STANDARDS[0])
|
||||
self.assertEqual(rc.DISK_GB, rc.STANDARDS[2])
|
||||
|
||||
def test_standards_tail(self):
|
||||
"""A sanity check that developers are paying attention.
|
||||
|
||||
When one or more standard classes are added, change the expected
|
||||
last class to the last one added and the length to the new length
|
||||
of rc.STANDARDS.
|
||||
|
||||
If you arrive here because you've run the tests and they've failed
|
||||
it's possible you've added some standard classes and not thought
|
||||
about their order. You _must_ add new standard classs at the end
|
||||
of the STANDARDS list, otherwise database ids will get confused
|
||||
in the placement service.
|
||||
"""
|
||||
expected_last_class = rc.NET_BW_IGR_KILOBIT_PER_SEC
|
||||
expected_length = 14
|
||||
self.assertEqual(expected_last_class, rc.STANDARDS[-1])
|
||||
self.assertEqual(expected_length, len(rc.STANDARDS))
|
||||
|
|
Loading…
Reference in New Issue