Commit 50811e2c authored by Iustin Pop's avatar Iustin Pop
Browse files

Add unittest for Node text serialization

This checks that the Node text serialization and deserialization
operations are idempotent when combined other.
parent a070c426
......@@ -6,7 +6,7 @@
{-
Copyright (C) 2009 Google Inc.
Copyright (C) 2009, 2010 Google Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -119,7 +119,7 @@ data Node = Node
, utilPool :: T.DynUtil -- ^ Total utilisation capacity
, utilLoad :: T.DynUtil -- ^ Sum of instance utilisation
, pTags :: TagMap -- ^ Map of primary instance tags and their count
} deriving (Show)
} deriving (Show, Eq)
instance T.Element Node where
nameOf = name
......
......@@ -456,11 +456,19 @@ prop_Text_Load_Node name tm nm fm td fd tc fo =
prop_Text_Load_NodeFail fields =
length fields /= 8 ==> isNothing $ Text.loadNode fields
prop_Text_NodeLSIdempotent node =
(Text.loadNode .
Utils.sepSplit '|' . Text.serializeNode) n ==
Just (Node.name n, n)
-- override failN1 to what loadNode returns by default
where n = node { Node.failN1 = True, Node.offline = False }
testText =
[ run prop_Text_Load_Instance
, run prop_Text_Load_InstanceFail
, run prop_Text_Load_Node
, run prop_Text_Load_NodeFail
, run prop_Text_NodeLSIdempotent
]
-- Node tests
......
......@@ -32,6 +32,7 @@ module Ganeti.HTools.Text
, loadInst
, loadNode
, serializeInstances
, serializeNode
, serializeNodes
) where
......
......@@ -4,7 +4,7 @@
{-
Copyright (C) 2009 Google Inc.
Copyright (C) 2009, 2010 Google Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -83,7 +83,7 @@ data DynUtil = DynUtil
, memWeight :: Weight -- ^ Standardised memory load
, dskWeight :: Weight -- ^ Standardised disk I\/O usage
, netWeight :: Weight -- ^ Standardised network usage
} deriving (Show)
} deriving (Show, Eq)
-- | Initial empty utilisation
zeroUtil :: DynUtil
......
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