Commit 2bac48c4 authored by Adeodato Simo's avatar Adeodato Simo
Browse files

Add some unit tests for ConfigWriter.AddNodeGroup()


Signed-off-by: default avatarAdeodato Simo <dato@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent f18fab7d
......@@ -204,6 +204,41 @@ class TestConfigRunner(unittest.TestCase):
cfg.Update(node, None)
self.assertEqual(cfg.GetNdParams(node), my_ndparams)
def testAddGroupFillsFieldsIfMissing(self):
cfg = self._get_object()
group = objects.NodeGroup(name="test", members=[])
cfg.AddNodeGroup(group, "my-job")
self.assert_(utils.UUID_RE.match(group.uuid))
self.assertEqual(constants.ALLOC_POLICY_PREFERRED, group.alloc_policy)
def testAddGroupPreservesFields(self):
cfg = self._get_object()
group = objects.NodeGroup(name="test", members=[],
alloc_policy=constants.ALLOC_POLICY_LAST_RESORT)
cfg.AddNodeGroup(group, "my-job")
self.assertEqual(constants.ALLOC_POLICY_LAST_RESORT, group.alloc_policy)
def testAddGroupDoesNotPreserveFields(self):
cfg = self._get_object()
group = objects.NodeGroup(name="test", members=[],
serial_no=17, ctime=123, mtime=456)
cfg.AddNodeGroup(group, "my-job")
self.assertEqual(1, group.serial_no)
self.assert_(group.ctime > 1200000000)
self.assert_(group.mtime > 1200000000)
def testAddGroupCanSkipUUIDCheck(self):
cfg = self._get_object()
uuid = cfg.GenerateUniqueID("my-job")
group = objects.NodeGroup(name="test", members=[], uuid=uuid,
serial_no=17, ctime=123, mtime=456)
self.assertRaises(errors.ConfigurationError,
cfg.AddNodeGroup, group, "my-job")
cfg.AddNodeGroup(group, "my-job", check_uuid=False) # Does not raise.
self.assertEqual(uuid, group.uuid)
class TestTRM(unittest.TestCase):
EC_ID = 1
......
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