Commit 38bbeb5f authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

Fix unit tests



Fix unit tests according to changes to the instance class.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent 6de333e7
......@@ -1849,9 +1849,10 @@ class TestLUClusterVerifyGroupVerifyNodeOs(TestLUClusterVerifyGroupMethods):
ndata = {
constants.NV_OSLIST: [
["mock_OS", "/mocked/path", True, "", ["default"], [],
[constants.OS_API_V20]],
[constants.OS_API_V20], True],
["Another_Mock", "/random", True, "", ["var1", "var2"],
[{"param1": "val1"}, {"param2": "val2"}], constants.OS_API_VERSIONS]
[{"param1": "val1"}, {"param2": "val2"}], constants.OS_API_VERSIONS,
True]
]
}
nimage = cluster.LUClusterVerifyGroup.NodeImage(uuid=self.master_uuid)
......@@ -1867,27 +1868,29 @@ class TestLUClusterVerifyGroupVerifyNodeOs(TestLUClusterVerifyGroupMethods):
nimg_root.os_fail = False
nimg_root.oslist = {
"mock_os": [("/mocked/path", True, "", set(["default"]), set(),
set([constants.OS_API_V20]))],
set([constants.OS_API_V20]), True)],
"broken_base_os": [("/broken", False, "", set(), set(),
set([constants.OS_API_V20]))],
"only_on_root": [("/random", True, "", set(), set(), set())],
set([constants.OS_API_V20]), True)],
"only_on_root": [("/random", True, "", set(), set(), set(), True)],
"diffing_os": [("/pinky", True, "", set(["var1", "var2"]),
set([("param1", "val1"), ("param2", "val2")]),
set([constants.OS_API_V20]))]
set([constants.OS_API_V20]), True)],
"trust_os": [("/trust/mismatch", True, "", set(), set(), set(), True)],
}
nimg.os_fail = False
nimg.oslist = {
"mock_os": [("/mocked/path", True, "", set(["default"]), set(),
set([constants.OS_API_V20]))],
"only_on_test": [("/random", True, "", set(), set(), set())],
set([constants.OS_API_V20]), True)],
"only_on_test": [("/random", True, "", set(), set(), set(), True)],
"diffing_os": [("/bunny", True, "", set(["var1", "var3"]),
set([("param1", "val1"), ("param3", "val3")]),
set([constants.OS_API_V15]))],
set([constants.OS_API_V15]), True)],
"broken_os": [("/broken", False, "", set(), set(),
set([constants.OS_API_V20]))],
set([constants.OS_API_V20]), True)],
"multi_entries": [
("/multi1", True, "", set(), set(), set([constants.OS_API_V20])),
("/multi2", True, "", set(), set(), set([constants.OS_API_V20]))]
("/multi1", True, "", set(), set(), set([constants.OS_API_V20]), True),
("/multi2", True, "", set(), set(), set([constants.OS_API_V20]), True)],
"trust_os": [("/trust/mismatch", True, "", set(), set(), set(), False)],
}
lu._VerifyNodeOS(node, nimg, nimg_root)
......@@ -1902,7 +1905,8 @@ class TestLUClusterVerifyGroupVerifyNodeOs(TestLUClusterVerifyGroupMethods):
"Invalid OS broken_os",
"Extra OS broken_os not present on reference node",
"OS 'multi_entries' has multiple entries",
"Extra OS multi_entries not present on reference node"
"Extra OS multi_entries not present on reference node",
"OS trusted for trust_os differs from reference node "
]
self.assertEqual(len(expected_msgs), len(self.mcpu.GetLogMessages()))
......
......@@ -69,6 +69,22 @@ class TestComputeIPolicyInstanceSpecViolation(unittest.TestCase):
class TestLUInstanceCreate(CmdlibTestCase):
def _setupOSDiagnose(self):
os_result = [(self.os.name,
self.os.path,
True,
"",
self.os.supported_variants,
self.os.supported_parameters,
self.os.api_versions,
True)]
self.rpc.call_os_diagnose.return_value = \
self.RpcResultsBuilder() \
.AddSuccessfulNode(self.master, os_result) \
.AddSuccessfulNode(self.node1, os_result) \
.AddSuccessfulNode(self.node2, os_result) \
.Build()
def setUp(self):
super(TestLUInstanceCreate, self).setUp()
......@@ -91,6 +107,8 @@ class TestLUInstanceCreate(CmdlibTestCase):
.AddSuccessfulNode(self.node2, hv_info) \
.Build()
self._setupOSDiagnose()
self.rpc.call_blockdev_getmirrorstatus.side_effect = \
lambda node, _: self.RpcResultsBuilder() \
.CreateSuccessfulNodeResult(node, [])
......@@ -622,10 +640,10 @@ class TestLUInstanceCreate(CmdlibTestCase):
exp_info = """
[export]
version=0
os=mock_os
os=%s
[instance]
name=old_name.example.com
"""
""" % self.os.name
self.rpc.call_export_info.return_value = \
self.RpcResultsBuilder() \
......@@ -645,10 +663,10 @@ name=old_name.example.com
exp_info = """
[export]
version=0
os=mock_os
os=%s
[instance]
name=old_name.example.com
"""
""" % self.os.name
self.rpc.call_export_list.return_value = \
self.RpcResultsBuilder() \
......@@ -691,7 +709,7 @@ version=1
exp_info = """
[export]
version=0
os=mock_os
os=%s
[instance]
name=old_name.example.com
disk0_size=1024
......@@ -710,7 +728,7 @@ memory=1024
vcpus=8
[os]
param1=val1
"""
""" % self.os.name
self.rpc.call_export_info.return_value = \
self.RpcResultsBuilder() \
......
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