Revision 2edc1c79
b/test/py/ganeti.hypervisor.hv_xen_unittest.py | ||
---|---|---|
393 | 393 |
self.assertFalse(os.path.exists(autocfgfile)) |
394 | 394 |
self.assertEqual(utils.ReadFile(cfgfile), "content") |
395 | 395 |
|
396 |
def _XenList(self, cmd): |
|
397 |
self.assertEqual(cmd, [self.CMD, "list"]) |
|
398 |
|
|
399 |
# TODO: Use actual data from "xl" command |
|
400 |
output = testutils.ReadTestData("xen-xm-list-4.0.1-four-instances.txt") |
|
401 |
|
|
402 |
return self._SuccessCommand(output, cmd) |
|
403 |
|
|
404 |
def testGetInstanceInfo(self): |
|
405 |
hv = self._GetHv(run_cmd=self._XenList) |
|
406 |
|
|
407 |
(name, instid, memory, vcpus, state, runtime) = \ |
|
408 |
hv.GetInstanceInfo("server01.example.com") |
|
409 |
|
|
410 |
self.assertEqual(name, "server01.example.com") |
|
411 |
self.assertEqual(instid, 1) |
|
412 |
self.assertEqual(memory, 1024) |
|
413 |
self.assertEqual(vcpus, 1) |
|
414 |
self.assertEqual(state, "-b----") |
|
415 |
self.assertAlmostEqual(runtime, 167643.2) |
|
416 |
|
|
417 |
def testGetInstanceInfoDom0(self): |
|
418 |
hv = self._GetHv(run_cmd=self._XenList) |
|
419 |
|
|
420 |
# TODO: Not sure if this is actually used anywhere (can't find it), but the |
|
421 |
# code supports querying for Dom0 |
|
422 |
(name, instid, memory, vcpus, state, runtime) = \ |
|
423 |
hv.GetInstanceInfo(hv_xen._DOM0_NAME) |
|
424 |
|
|
425 |
self.assertEqual(name, "Domain-0") |
|
426 |
self.assertEqual(instid, 0) |
|
427 |
self.assertEqual(memory, 1023) |
|
428 |
self.assertEqual(vcpus, 1) |
|
429 |
self.assertEqual(state, "r-----") |
|
430 |
self.assertAlmostEqual(runtime, 154706.1) |
|
431 |
|
|
432 |
def testGetInstanceInfoUnknown(self): |
|
433 |
hv = self._GetHv(run_cmd=self._XenList) |
|
434 |
|
|
435 |
result = hv.GetInstanceInfo("unknown.example.com") |
|
436 |
self.assertTrue(result is None) |
|
437 |
|
|
438 |
def testGetAllInstancesInfo(self): |
|
439 |
hv = self._GetHv(run_cmd=self._XenList) |
|
440 |
|
|
441 |
result = hv.GetAllInstancesInfo() |
|
442 |
|
|
443 |
self.assertEqual(map(compat.fst, result), [ |
|
444 |
"server01.example.com", |
|
445 |
"web3106215069.example.com", |
|
446 |
"testinstance.example.com", |
|
447 |
]) |
|
448 |
|
|
449 |
def testListInstances(self): |
|
450 |
hv = self._GetHv(run_cmd=self._XenList) |
|
451 |
|
|
452 |
self.assertEqual(hv.ListInstances(), [ |
|
453 |
"server01.example.com", |
|
454 |
"web3106215069.example.com", |
|
455 |
"testinstance.example.com", |
|
456 |
]) |
|
457 |
|
|
396 | 458 |
def testVerify(self): |
397 | 459 |
output = testutils.ReadTestData("xen-xm-info-4.0.1.txt") |
398 | 460 |
hv = self._GetHv(run_cmd=compat.partial(self._SuccessCommand, |
Also available in: Unified diff