diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-03-12 11:45:59 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-03-12 11:45:59 +0000 |
| commit | 562b0787421b145c4a91ccbbcacfc74c340cead8 (patch) | |
| tree | 96024250aa2184f86135e2fdf45ade64121d0925 /nova/tests | |
| parent | ae251b99a3fb6aa99ec8898152d79dfa2c026a92 (diff) | |
| parent | f97f6214dac7951cb4d91bf24e9ceb3a43e65938 (diff) | |
Merge "Handle vcpu counting failures gracefully"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_libvirt.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 55b6aaec4..3e379a292 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -3532,6 +3532,35 @@ class LibvirtConnTestCase(test.TestCase): } self.assertEqual(actual, expect) + def test_failing_vcpu_count(self): + """Domain can fail to return the vcpu description in case it's + just starting up or shutting down. Make sure None is handled + gracefully. + """ + + class DiagFakeDomain(object): + def __init__(self, vcpus): + self._vcpus = vcpus + + def vcpus(self): + if self._vcpus is None: + return None + else: + return ([1] * self._vcpus, [True] * self._vcpus) + + driver = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) + conn = driver._conn + self.mox.StubOutWithMock(driver, 'list_instance_ids') + self.mox.StubOutWithMock(conn, 'lookupByID') + + driver.list_instance_ids().AndReturn([1, 2]) + conn.lookupByID(1).AndReturn(DiagFakeDomain(None)) + conn.lookupByID(2).AndReturn(DiagFakeDomain(5)) + + self.mox.ReplayAll() + + self.assertEqual(5, driver.get_vcpu_used()) + def test_get_instance_capabilities(self): conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) |
