Commit 232fc505 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix corner case in quick-check generated tests



Thanks to Agata Murawska, a random seed that generates bad test cases
was found ("seed was 1768143307 2118231514, test size 74"). This is
due to the fact that some nodes were generated with tMem=0, fMem=0,
which means that pMem was NaN and thus the node was not comparing
equal to itself.

Worked around by limiting the test case generation to nodes with
positive values; a better fix would be to compare nodes differently
(subset of properties or ignore NaN values).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 15618b63
......@@ -666,7 +666,8 @@ prop_Container_nameOf node =
-- | We test that in a cluster, given a random node, we can find it by
-- its name and alias, as long as all names and aliases are unique,
-- and that we fail to find a non-existing name.
prop_Container_findByName node =
prop_Container_findByName =
forAll (genNode (Just 1) Nothing) $ \node ->
forAll (choose (1, 20)) $ \ cnt ->
forAll (choose (0, cnt - 1)) $ \ fidx ->
forAll (genUniquesList (cnt * 2)) $ \ allnames ->
......@@ -680,9 +681,10 @@ prop_Container_findByName node =
$ zip names nodes
nl' = Container.fromList nodes'
target = snd (nodes' !! fidx)
in Container.findByName nl' (Node.name target) == Just target &&
Container.findByName nl' (Node.alias target) == Just target &&
isNothing (Container.findByName nl' othername)
in Container.findByName nl' (Node.name target) ==? Just target .&&.
Container.findByName nl' (Node.alias target) ==? Just target .&&.
printTestCase "Found non-existing name"
(isNothing (Container.findByName nl' othername))
testSuite "Container"
[ 'prop_Container_addTwo
......@@ -870,13 +872,15 @@ prop_Text_Load_Node name tm nm fm td fd tc fo =
prop_Text_Load_NodeFail fields =
length fields /= 8 ==> isNothing $ Text.loadNode Data.Map.empty fields
prop_Text_NodeLSIdempotent node =
(Text.loadNode defGroupAssoc.
Utils.sepSplit '|' . Text.serializeNode defGroupList) n ==?
Just (Node.name n, n)
-- override failN1 to what loadNode returns by default
where n = Node.setPolicy Types.defIPolicy $
node { Node.failN1 = True, Node.offline = False }
prop_Text_NodeLSIdempotent =
forAll (genNode (Just 1) Nothing) $ \node ->
-- override failN1 to what loadNode returns by default
let n = Node.setPolicy Types.defIPolicy $
node { Node.failN1 = True, Node.offline = False }
in
(Text.loadNode defGroupAssoc.
Utils.sepSplit '|' . Text.serializeNode defGroupList) n ==?
Just (Node.name n, n)
prop_Text_ISpecIdempotent ispec =
case Text.loadISpec "dummy" . Utils.sepSplit ',' .
......
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