@@ -372,6 +372,51 @@ def test_obj_from_db_obj(self):
372
372
self .assertEqual (set (), obj_cell .cpuset )
373
373
self .assertEqual (topo_cell .cpuset , obj_cell .pcpuset )
374
374
375
+ def test_obj_from_db_obj_no_pinning (self ):
376
+ """Test of creating 'InstanceNUMATopology' OVO object from the
377
+ database primitives, which has an old version 'InstanceNUMACell'
378
+ primitives.
379
+
380
+ Prior to version 1.5, 'InstanceNUMACell' saves the instance CPUs in
381
+ the 'cpuset' field, for both the pinned CPUs of a dedicated and the
382
+ un-pinned CPUs of a shared instances, after version 1.5, any pinned
383
+ CPUs of dedicated instance are moved to 'pcpuset'. this test verifies
384
+ the CPU movement for instance with a 'dedicated' allocation policy.
385
+
386
+ This test is for the case where the instance has no pinned CPUs but
387
+ the instance has a numa topology such as when hugepages are used.
388
+ See bug: https://bugs.launchpad.net/nova/+bug/2080556 for more details.
389
+ """
390
+ fake_topo_obj_w_cell_v1_4 = objects .InstanceNUMATopology (
391
+ instance_uuid = fake_instance_uuid ,
392
+ cells = [
393
+ objects .InstanceNUMACell (
394
+ id = 0 , cpuset = set ([1 , 2 ]), memory = 512 ,
395
+ pagesize = 2048 ),
396
+ objects .InstanceNUMACell (
397
+ id = 1 , cpuset = set ([3 , 4 ]), memory = 512 ,
398
+ pagesize = 2048 ),
399
+ ])
400
+
401
+ fake_topo_obj = copy .deepcopy (fake_topo_obj_w_cell_v1_4 )
402
+ for cell in fake_topo_obj .cells :
403
+ cell .cpu_policy = objects .fields .CPUAllocationPolicy .SHARED
404
+
405
+ numa_topology = objects .InstanceNUMATopology .obj_from_db_obj (
406
+ self .context , fake_instance_uuid , fake_topo_obj ._to_json ())
407
+
408
+ for obj_cell , topo_cell in zip (
409
+ numa_topology .cells ,
410
+ fake_topo_obj_w_cell_v1_4 ['cells' ]):
411
+ self .assertEqual (topo_cell .cpuset , obj_cell .cpuset )
412
+ # 'pcpuset' should be an empty set however
413
+ # obj_from_db_obj() or more specifically
414
+ # _migrate_legacy_dedicated_instance_cpuset() does not set
415
+ # 'pcpuset' to an empty set when it is not in the json data.
416
+ # self.assertEqual(set(), obj_cell.pcpuset)
417
+ self .assertRaises (
418
+ NotImplementedError , getattr , obj_cell , 'pcpuset' )
419
+
375
420
376
421
class TestInstanceNUMATopology (
377
422
test_objects ._LocalTest , _TestInstanceNUMATopology ,
0 commit comments