Commit 8520f4b9 authored by Thomas Thrainer's avatar Thomas Thrainer

Add unit test for drbdsetup show parsing

This unit test checks for proper parsing of the output from `drbdsetup
show` when re-attaching the local disk. In this case, disk parameters
are not (yet) set, so the corresponding dict is empty.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent e4889779
......@@ -1117,6 +1117,7 @@ TEST_FILES = \
test/data/bdev-drbd-8.0.txt \
test/data/bdev-drbd-8.3.txt \
test/data/bdev-drbd-8.4.txt \
test/data/bdev-drbd-8.4-no-disk-params.txt \
test/data/bdev-drbd-disk.txt \
test/data/bdev-drbd-net-ip4.txt \
test/data/bdev-drbd-net-ip6.txt \
......
resource resource0 {
options {
}
net {
cram-hmac-alg "md5";
shared-secret "shared_secret_123";
after-sb-0pri discard-zero-changes;
after-sb-1pri consensus;
}
_remote_host {
address ipv4 192.0.2.2:11000;
}
_this_host {
address ipv4 192.0.2.1:11000;
volume 0 {
device minor 0;
disk "/dev/xenvg/test.data";
meta-disk "/dev/xenvg/test.meta";
disk {
}
}
}
}
......@@ -85,15 +85,18 @@ class TestDRBD8Runner(testutils.GanetiTestCase):
"""Testing case for drbd.DRBD8Dev"""
@staticmethod
def _has_disk(data, dname, mname):
def _has_disk(data, dname, mname, meta_index=0):
"""Check local disk corectness"""
retval = (
"local_dev" in data and
data["local_dev"] == dname and
"meta_dev" in data and
data["meta_dev"] == mname and
"meta_index" in data and
data["meta_index"] == 0
((meta_index is None and
"meta_index" not in data) or
("meta_index" in data and
data["meta_index"] == meta_index)
)
)
return retval
......@@ -149,6 +152,22 @@ class TestDRBD8Runner(testutils.GanetiTestCase):
("192.0.2.2", 11000)),
"Wrong network info (8.4.x)")
def testParser84NoDiskParams(self):
"""Test drbdsetup show parser for 8.4 without disk params
The missing disk parameters occur after re-attaching a local disk but
before setting the disk params.
"""
data = testutils.ReadTestData("bdev-drbd-8.4-no-disk-params.txt")
result = drbd_info.DRBD84ShowInfo.GetDevInfo(data)
self.failUnless(self._has_disk(result, "/dev/xenvg/test.data",
"/dev/xenvg/test.meta", meta_index=None),
"Wrong local disk info")
self.failUnless(self._has_net(result, ("192.0.2.1", 11000),
("192.0.2.2", 11000)),
"Wrong network info (8.4.x)")
def testParserNetIP4(self):
"""Test drbdsetup show parser for IPv4 network"""
data = testutils.ReadTestData("bdev-drbd-net-ip4.txt")
......
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