@@ -1307,6 +1307,7 @@ def test_topology_constraints(self):
13071307 extra_specs = {
13081308 "hw:cpu_policy" : fields .CPUAllocationPolicy .SHARED ,
13091309 "hw:cpu_realtime" : "yes" ,
1310+ "hw:cpu_realtime_mask" : "0-3,^0" ,
13101311 }),
13111312 "image" : {
13121313 "properties" : {}
@@ -3603,74 +3604,113 @@ def test_reserved_exceeded(self):
36033604
36043605class CPURealtimeTestCase (test .NoDBTestCase ):
36053606 def test_success_flavor (self ):
3606- flavor = objects .Flavor (vcpus = 3 , memory_mb = 2048 ,
3607- extra_specs = {"hw:cpu_realtime_mask" : "^1" })
3607+ flavor = objects .Flavor (
3608+ vcpus = 3 , memory_mb = 2048 ,
3609+ extra_specs = {
3610+ 'hw:cpu_realtime' : 'true' ,
3611+ 'hw:cpu_realtime_mask' : '^1' ,
3612+ }
3613+ )
36083614 image = objects .ImageMeta .from_dict ({})
3609- rt = hw .vcpus_realtime_topology (flavor , image )
3615+ rt = hw .get_realtime_cpu_constraint (flavor , image )
36103616 self .assertEqual (set ([0 , 2 ]), rt )
36113617
36123618 def test_success_image (self ):
3613- flavor = objects .Flavor (vcpus = 3 , memory_mb = 2048 ,
3614- extra_specs = {"hw:cpu_realtime_mask" : "^1" })
3619+ flavor = objects .Flavor (
3620+ vcpus = 3 , memory_mb = 2048 ,
3621+ extra_specs = {
3622+ 'hw:cpu_realtime' : 'true' ,
3623+ 'hw:cpu_realtime_mask' : '^1' ,
3624+ },
3625+ )
36153626 image = objects .ImageMeta .from_dict (
36163627 {"properties" : {"hw_cpu_realtime_mask" : "^0-1" }})
3617- rt = hw .vcpus_realtime_topology (flavor , image )
3628+ rt = hw .get_realtime_cpu_constraint (flavor , image )
36183629 self .assertEqual (set ([2 ]), rt )
36193630
36203631 def test_no_mask_configured (self ):
3621- flavor = objects .Flavor (vcpus = 3 , memory_mb = 2048 ,
3622- extra_specs = {})
3632+ flavor = objects .Flavor (
3633+ vcpus = 3 , memory_mb = 2048 ,
3634+ extra_specs = {
3635+ 'hw:cpu_realtime' : 'true' ,
3636+ },
3637+ )
36233638 image = objects .ImageMeta .from_dict ({"properties" : {}})
36243639 self .assertRaises (
36253640 exception .RealtimeMaskNotFoundOrInvalid ,
3626- hw .vcpus_realtime_topology , flavor , image )
3641+ hw .get_realtime_cpu_constraint , flavor , image )
36273642
36283643 def test_invalid_mask_no_rt_cpus (self ):
36293644 # The mask excludes all vCPUs from being RT
3630- flavor = objects .Flavor (vcpus = 3 , memory_mb = 2048 ,
3631- extra_specs = {"hw:cpu_realtime_mask" : "^0-2" })
3645+ flavor = objects .Flavor (
3646+ vcpus = 3 , memory_mb = 2048 ,
3647+ extra_specs = {
3648+ 'hw:cpu_realtime' : 'true' ,
3649+ 'hw:cpu_realtime_mask' : '^0-2' ,
3650+ },
3651+ )
36323652 image = objects .ImageMeta .from_dict ({"properties" : {}})
36333653 self .assertRaises (
36343654 exception .RealtimeMaskNotFoundOrInvalid ,
3635- hw .vcpus_realtime_topology , flavor , image )
3655+ hw .get_realtime_cpu_constraint , flavor , image )
36363656
36373657 def test_invalid_mask_exclude_out_of_range (self ):
36383658 # The mask excludes an invalidly high vCPU number.
3639- flavor = objects .Flavor (vcpus = 3 , memory_mb = 2048 ,
3640- extra_specs = {"hw:cpu_realtime_mask" : "^3" })
3659+ flavor = objects .Flavor (
3660+ vcpus = 3 , memory_mb = 2048 ,
3661+ extra_specs = {
3662+ 'hw:cpu_realtime' : 'true' ,
3663+ 'hw:cpu_realtime_mask' : '^3' ,
3664+ },
3665+ )
36413666 image = objects .ImageMeta .from_dict ({"properties" : {}})
36423667 self .assertRaises (
36433668 exception .RealtimeMaskNotFoundOrInvalid ,
3644- hw .vcpus_realtime_topology , flavor , image )
3669+ hw .get_realtime_cpu_constraint , flavor , image )
36453670
36463671 def test_explicit_range (self ):
36473672 # The mask is not just an exclusion mask. This is unexpected but
36483673 # the code doesn't prevent it.
3649- flavor = objects .Flavor (vcpus = 3 , memory_mb = 2048 ,
3650- extra_specs = {"hw:cpu_realtime_mask" : "0-2,^0" })
3674+ flavor = objects .Flavor (
3675+ vcpus = 3 , memory_mb = 2048 ,
3676+ extra_specs = {
3677+ 'hw:cpu_realtime' : 'true' ,
3678+ 'hw:cpu_realtime_mask' : '0-2,^0' ,
3679+ },
3680+ )
36513681 image = objects .ImageMeta .from_dict ({"properties" : {}})
3652- rt = hw .vcpus_realtime_topology (flavor , image )
3682+ rt = hw .get_realtime_cpu_constraint (flavor , image )
36533683 self .assertEqual ({1 , 2 }, rt )
36543684
36553685 def test_invalid_mask_no_exclusion_wo_emulator_policy (self ):
36563686 # The mask has no exclusion and there's no emulator thread policy
36573687 # configured
3658- flavor = objects .Flavor (vcpus = 3 , memory_mb = 2048 ,
3659- extra_specs = {"hw:cpu_realtime_mask" : "0-2" })
3688+ flavor = objects .Flavor (
3689+ vcpus = 3 , memory_mb = 2048 ,
3690+ extra_specs = {
3691+ 'hw:cpu_realtime' : 'true' ,
3692+ 'hw:cpu_realtime_mask' : '0-2' ,
3693+ },
3694+ )
36603695 image = objects .ImageMeta .from_dict ({"properties" : {}})
36613696 self .assertRaises (
36623697 exception .RealtimeMaskNotFoundOrInvalid ,
3663- hw .vcpus_realtime_topology , flavor , image )
3698+ hw .get_realtime_cpu_constraint , flavor , image )
36643699
36653700 def test_invalid_mask_rt_cpus_out_of_range (self ):
36663701 # The mask is not just an exclusion mask, and the RT range specifies
36673702 # an invalid vCPU number.
3668- flavor = objects .Flavor (vcpus = 3 , memory_mb = 2048 ,
3669- extra_specs = {"hw:cpu_realtime_mask" : "0-3,^0" })
3703+ flavor = objects .Flavor (
3704+ vcpus = 3 , memory_mb = 2048 ,
3705+ extra_specs = {
3706+ 'hw:cpu_realtime' : 'true' ,
3707+ 'hw:cpu_realtime_mask' : '0-3,^0' ,
3708+ },
3709+ )
36703710 image = objects .ImageMeta .from_dict ({"properties" : {}})
36713711 self .assertRaises (
36723712 exception .RealtimeMaskNotFoundOrInvalid ,
3673- hw .vcpus_realtime_topology , flavor , image )
3713+ hw .get_realtime_cpu_constraint , flavor , image )
36743714
36753715
36763716class EmulatorThreadsTestCase (test .NoDBTestCase ):
0 commit comments