Commit eae69eee authored by Iustin Pop's avatar Iustin Pop
Browse files

Add two more unittests for Node add/remove



These just test that add/remove are idempotent. This is not perfect,
as we use unsorted lists for some values (instead of sets), so when
using non-empty nodes this would break (but for empty nodes, a
1-element list is sorted, so it's fine).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 084565ac
......@@ -1077,6 +1077,23 @@ prop_Node_computeGroups nodes =
length (nub onlyuuid) == length onlyuuid &&
(null nodes || not (null ng))
-- Check idempotence of add/remove operations
prop_Node_addPri_idempotent =
forAll genOnlineNode $ \node ->
forAll (genInstanceSmallerThanNode node) $ \inst ->
case Node.addPri node inst of
Types.OpGood node' -> Node.removePri node' inst ==? node
_ -> failTest "Can't add instance"
prop_Node_addSec_idempotent =
forAll genOnlineNode $ \node ->
forAll (genInstanceSmallerThanNode node) $ \inst ->
let pdx = Node.idx node + 1
inst' = Instance.setPri inst pdx
in case Node.addSec node inst' pdx of
Types.OpGood node' -> Node.removeSec node' inst' ==? node
_ -> failTest "Can't add instance"
testSuite "Node"
[ 'prop_Node_setAlias
, 'prop_Node_setOffline
......@@ -1093,6 +1110,8 @@ testSuite "Node"
, 'prop_Node_tagMaps_reject
, 'prop_Node_showField
, 'prop_Node_computeGroups
, 'prop_Node_addPri_idempotent
, 'prop_Node_addSec_idempotent
]
-- ** Cluster tests
......
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