Commit c026664a authored by Petr Pudlak's avatar Petr Pudlak
Browse files

Remove VerifyConfig tests



These tests don't work with WConfd, because the configuration is
verified automatically before each operation and it's not possible to
modify the configuration state directly.

It'll be necessary to re-create these tests for WConfd once
configuration verification is implemented there.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent c28d15f7
......@@ -439,163 +439,6 @@ class TestConfigRunner(unittest.TestCase):
self.assertFalse(grp1.members)
self.assertEqual(set(grp2.members), set(["node1-uuid", "node2-uuid"]))
def _TestVerifyConfigIPolicy(self, ipolicy, ipowner, cfg, isgroup):
INVALID_KEY = "this_key_cannot_exist"
ipolicy[INVALID_KEY] = None
# A call to cluster.SimpleFillIPolicy causes different kinds of error
# depending on the owner (cluster or group)
if isgroup:
errs = cfg.VerifyConfig()
self.assertTrue(len(errs) >= 1)
errstr = "%s has invalid instance policy" % ipowner
self.assertTrue(_IsErrorInList(errstr, errs))
else:
self.assertRaises(AssertionError, cfg.VerifyConfig)
del ipolicy[INVALID_KEY]
errs = cfg.VerifyConfig()
self.assertFalse(errs)
key = list(constants.IPOLICY_PARAMETERS)[0]
hasoldv = (key in ipolicy)
if hasoldv:
oldv = ipolicy[key]
ipolicy[key] = "blah"
errs = cfg.VerifyConfig()
self.assertTrue(len(errs) >= 1)
self.assertTrue(_IsErrorInList("%s has invalid instance policy" % ipowner,
errs))
if hasoldv:
ipolicy[key] = oldv
else:
del ipolicy[key]
ispeclist = []
if constants.ISPECS_MINMAX in ipolicy:
for k in range(len(ipolicy[constants.ISPECS_MINMAX])):
ispeclist.extend([
(ipolicy[constants.ISPECS_MINMAX][k][constants.ISPECS_MIN],
"%s[%s]/%s" % (constants.ISPECS_MINMAX, k, constants.ISPECS_MIN)),
(ipolicy[constants.ISPECS_MINMAX][k][constants.ISPECS_MAX],
"%s[%s]/%s" % (constants.ISPECS_MINMAX, k, constants.ISPECS_MAX)),
])
if constants.ISPECS_STD in ipolicy:
ispeclist.append((ipolicy[constants.ISPECS_STD], constants.ISPECS_STD))
for (ispec, ispecpath) in ispeclist:
ispec[INVALID_KEY] = None
errs = cfg.VerifyConfig()
self.assertTrue(len(errs) >= 1)
self.assertTrue(_IsErrorInList(("%s has invalid ipolicy/%s" %
(ipowner, ispecpath)), errs))
del ispec[INVALID_KEY]
errs = cfg.VerifyConfig()
self.assertFalse(errs)
for par in constants.ISPECS_PARAMETERS:
hasoldv = par in ispec
if hasoldv:
oldv = ispec[par]
ispec[par] = "blah"
errs = cfg.VerifyConfig()
self.assertTrue(len(errs) >= 1)
self.assertTrue(_IsErrorInList(("%s has invalid ipolicy/%s" %
(ipowner, ispecpath)), errs))
if hasoldv:
ispec[par] = oldv
else:
del ispec[par]
errs = cfg.VerifyConfig()
self.assertFalse(errs)
if constants.ISPECS_MINMAX in ipolicy:
# Test partial minmax specs
for minmax in ipolicy[constants.ISPECS_MINMAX]:
for key in constants.ISPECS_MINMAX_KEYS:
self.assertTrue(key in minmax)
ispec = minmax[key]
del minmax[key]
errs = cfg.VerifyConfig()
self.assertTrue(len(errs) >= 1)
self.assertTrue(_IsErrorInList("Missing instance specification",
errs))
minmax[key] = ispec
for par in constants.ISPECS_PARAMETERS:
oldv = ispec[par]
del ispec[par]
errs = cfg.VerifyConfig()
self.assertTrue(len(errs) >= 1)
self.assertTrue(_IsErrorInList("Missing instance specs parameters",
errs))
ispec[par] = oldv
errs = cfg.VerifyConfig()
self.assertFalse(errs)
def _TestVerifyConfigGroupIPolicy(self, groupinfo, cfg):
old_ipolicy = groupinfo.ipolicy
ipolicy = cfg.GetClusterInfo().SimpleFillIPolicy({})
groupinfo.ipolicy = ipolicy
# Test partial policies
for key in constants.IPOLICY_ALL_KEYS:
self.assertTrue(key in ipolicy)
oldv = ipolicy[key]
del ipolicy[key]
errs = cfg.VerifyConfig()
self.assertFalse(errs)
ipolicy[key] = oldv
groupinfo.ipolicy = old_ipolicy
def _TestVerifyConfigClusterIPolicy(self, ipolicy, cfg):
# Test partial policies
for key in constants.IPOLICY_ALL_KEYS:
self.assertTrue(key in ipolicy)
oldv = ipolicy[key]
del ipolicy[key]
self.assertRaises(AssertionError, cfg.VerifyConfig)
ipolicy[key] = oldv
errs = cfg.VerifyConfig()
self.assertFalse(errs)
# Partial standard specs
ispec = ipolicy[constants.ISPECS_STD]
for par in constants.ISPECS_PARAMETERS:
oldv = ispec[par]
del ispec[par]
errs = cfg.VerifyConfig()
self.assertTrue(len(errs) >= 1)
self.assertTrue(_IsErrorInList("Missing instance specs parameters",
errs))
ispec[par] = oldv
errs = cfg.VerifyConfig()
self.assertFalse(errs)
def testVerifyConfig(self):
cfg = self._get_object()
errs = cfg.VerifyConfig()
self.assertFalse(errs)
node = cfg.GetNodeInfo(cfg.GetNodeList()[0])
key = list(constants.NDC_GLOBALS)[0]
node.ndparams[key] = constants.NDC_DEFAULTS[key]
cfg.Update(node, None)
errs = cfg.VerifyConfig()
self.assertTrue(len(errs) >= 1)
self.assertTrue(_IsErrorInList("has some global parameters set", errs))
del node.ndparams[key]
cfg.Update(node, None)
errs = cfg.VerifyConfig()
self.assertFalse(errs)
cluster = cfg.GetClusterInfo()
nodegroup = cfg.GetNodeGroup(cfg.GetNodeGroupList()[0])
self._TestVerifyConfigIPolicy(cluster.ipolicy, "cluster", cfg, False)
self._TestVerifyConfigClusterIPolicy(cluster.ipolicy, cfg)
self._TestVerifyConfigIPolicy(nodegroup.ipolicy, nodegroup.name, cfg, True)
self._TestVerifyConfigGroupIPolicy(nodegroup, cfg)
nodegroup.ipolicy = cluster.SimpleFillIPolicy(nodegroup.ipolicy)
self._TestVerifyConfigIPolicy(nodegroup.ipolicy, nodegroup.name, cfg, True)
# Tests for Ssconf helper functions
def testUnlockedGetHvparamsString(self):
hvparams = {"a": "A", "b": "B", "c": "C"}
......
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