Commit be352629 authored by Hrvoje Ribicic's avatar Hrvoje Ribicic

Add tests exercising the "crashed" state handling

This patch adds a few tests that make sure the state is handled
properly, using examples taken from a running cluster.
Signed-off-by: default avatarHrvoje Ribicic <riba@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 6611a81a
......@@ -1698,6 +1698,7 @@ TEST_FILES = \
test/data/vgreduce-removemissing-2.02.66-ok.txt \
test/data/vgs-missing-pvs-2.02.02.txt \
test/data/vgs-missing-pvs-2.02.66.txt \
test/data/xen-xl-list-4.4-crashed-instances.txt \
test/data/xen-xm-info-4.0.1.txt \
test/data/xen-xm-list-4.0.1-dom0-only.txt \
test/data/xen-xm-list-4.0.1-four-instances.txt \
......
Name ID Mem VCPUs State Time(s)
Domain-0 0 1023 1 r----- 154706.1
server01.example.com 1 1024 1 -b---- 167643.2
(null) 28441 789 1 --psc- 1.2
alsodying.example.com 28448 1024 1 --psc- 1.4
......@@ -198,6 +198,19 @@ class TestInstanceStateParsing(unittest.TestCase):
self.assertEqual(hv_xen._XenToHypervisorInstanceState(state),
hv_base.HvInstanceState.SHUTDOWN)
def testCrashingStates(self):
states = [
"--psc-",
"---sc-",
"---scd",
"--p-c-",
"----c-",
"----cd",
]
for state in states:
self.assertRaises(hv_xen._InstanceCrashed,
hv_xen._XenToHypervisorInstanceState, state)
class TestGetInstanceList(testutils.GanetiTestCase):
def _Fail(self):
......@@ -241,6 +254,23 @@ class TestGetInstanceList(testutils.GanetiTestCase):
self.assertEqual(fn.Count(), 1)
def testOmitCrashed(self):
data = testutils.ReadTestData("xen-xl-list-4.4-crashed-instances.txt")
fn = testutils.CallCounter(compat.partial(self._Success, data))
result = hv_xen._GetAllInstanceList(fn, True, delays=(0.02, 1.0, 0.03),
timeout=0.1)
self.assertEqual(len(result), 2)
self.assertEqual(map(compat.fst, result), [
"Domain-0",
"server01.example.com",
])
self.assertEqual(fn.Count(), 1)
class TestParseNodeInfo(testutils.GanetiTestCase):
def testEmpty(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment