@@ -9254,6 +9254,34 @@ def test_get_pcpu_available__cpu_dedicated_set_invalid(self,
9254
9254
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
9255
9255
self.assertRaises(exception.Invalid, drvr._get_pcpu_available)
9256
9256
9257
+ @mock.patch('nova.virt.libvirt.host.Host.get_available_cpus',
9258
+ return_value=set([0, 1, 2, 3]))
9259
+ def test_get_pcpu_available_for_power_mgmt(self, get_available_cpus):
9260
+ """Test what happens when the '[compute] cpu_dedicated_set' config
9261
+ option is set and power management is defined.
9262
+ """
9263
+ self.flags(vcpu_pin_set=None)
9264
+ self.flags(cpu_dedicated_set='2-3', cpu_shared_set=None,
9265
+ group='compute')
9266
+ self.flags(cpu_power_management=True, group='libvirt')
9267
+ drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
9268
+ pcpus = drvr._get_pcpu_available()
9269
+ self.assertEqual(set([2, 3]), pcpus)
9270
+
9271
+ @mock.patch('nova.virt.libvirt.host.Host.get_available_cpus',
9272
+ return_value=set([4, 5]))
9273
+ def test_get_pcpu_available__cpu_dedicated_set_invalid_for_pm(self,
9274
+ get_available_cpus):
9275
+ """Test what happens when the '[compute] cpu_dedicated_set' config
9276
+ option is set but it's invalid with power management set.
9277
+ """
9278
+ self.flags(vcpu_pin_set=None)
9279
+ self.flags(cpu_dedicated_set='4-6', cpu_shared_set=None,
9280
+ group='compute')
9281
+ self.flags(cpu_power_management=True, group='libvirt')
9282
+ drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
9283
+ self.assertRaises(exception.Invalid, drvr._get_pcpu_available)
9284
+
9257
9285
@mock.patch('nova.virt.libvirt.host.Host.get_online_cpus',
9258
9286
return_value=set([0, 1, 2, 3]))
9259
9287
def test_get_vcpu_available(self, get_online_cpus):
0 commit comments