Skip to content

Commit

Permalink
bug 929462: compile_diagnostics in xenapi erronously catch XenAPI.Fai…
Browse files Browse the repository at this point in the history
…lure

ensure we catch the right exception. Plus turn test_diagnostics into a
more thorough unit test.

Change-Id: I1aae28b9b3b942f08e419cd9cfa48dea003e96d9
  • Loading branch information
Armando Migliaccio committed Feb 17, 2012
1 parent 2471629 commit 8297a1b
Show file tree
Hide file tree
Showing 5 changed files with 11,320 additions and 5 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Expand Up @@ -38,6 +38,7 @@ include nova/tests/api/ec2/public_key/*
include nova/tests/db/nova.austin.sqlite
include nova/tests/image/*.tar.gz
include nova/tests/policy.json
include nova/tests/xenapi/vm_rrd.xml
include plugins/xenapi/README
include plugins/xenapi/etc/xapi.d/plugins/objectstore
include plugins/xenapi/etc/xapi.d/plugins/pluginlib_nova.py
Expand Down
19 changes: 18 additions & 1 deletion nova/tests/test_xenapi.py
Expand Up @@ -243,8 +243,25 @@ def test_get_rrd_server(self):
self.assertEqual(server_info[1], 'myaddress')

def test_get_diagnostics(self):
def fake_get_rrd(host, vm_uuid):
with open('xenapi/vm_rrd.xml') as f:
return re.sub(r'\s', '', f.read())
self.stubs.Set(vm_utils, 'get_rrd', fake_get_rrd)

fake_diagnostics = {
'vbd_xvdb_write': '0.0',
'memory_target': '10961792000.0000',
'memory_internal_free': '3612860.6020',
'memory': '10961792000.0000',
'vbd_xvda_write': '0.0',
'cpu0': '0.0110',
'vif_0_tx': '752.4007',
'vbd_xvda_read': '0.0',
'vif_0_rx': '4837.8805'
}
instance = self._create_instance()
self.conn.get_diagnostics(instance)
expected = self.conn.get_diagnostics(instance)
self.assertDictMatch(fake_diagnostics, expected)

def test_instance_snapshot_fails_with_no_primary_vdi(self):
def create_bad_vbd(vm_ref, vdi_ref):
Expand Down

0 comments on commit 8297a1b

Please sign in to comment.