Browse Source

Add test so we remember why CUSTOM_ prefix added

While it is tempting as an ironic operator to have CUSTOM_FOO in
placement, nova flavors and ironic resource class attributes,
allow that makes for a more complicated mapping between ironic
resource classes and the resource classes in the general case,
and could cause confusion when there is a typo of CUSTOM vs CUSTM
that could get mapped very differently into placement.

Adding this test so it is clear this is a deliberate choice, and
git blame will find this git commit message.

Related-Bug: #1724524

Change-Id: Ie38baea53e41ca7ba8875fd113cd777810f17db7
tags/17.0.0.0b2
John Garbutt 1 year ago
parent
commit
f73d6eb1dc
1 changed files with 11 additions and 0 deletions
  1. 11
    0
      nova/tests/unit/objects/test_fields.py

+ 11
- 0
nova/tests/unit/objects/test_fields.py View File

@@ -351,6 +351,17 @@ class TestResourceClass(TestString):
351 351
         self.to_primitive_values = self.coerce_good_values[0:1]
352 352
         self.from_primitive_values = self.coerce_good_values[0:1]
353 353
 
354
+    def test_normalize_name(self):
355
+        values = [
356
+            ("foo", "CUSTOM_FOO"),
357
+            ("VCPU", "CUSTOM_VCPU"),
358
+            ("CUSTOM_BOB", "CUSTOM_CUSTOM_BOB"),
359
+            ("CUSTM_BOB", "CUSTOM_CUSTM_BOB"),
360
+        ]
361
+        for test_value, expected in values:
362
+            result = fields.ResourceClass.normalize_name(test_value)
363
+            self.assertEqual(expected, result)
364
+
354 365
 
355 366
 class TestInteger(TestField):
356 367
     def setUp(self):

Loading…
Cancel
Save