Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -666,7 +666,8 @@ prop_Container_nameOf node = ...@@ -666,7 +666,8 @@ prop_Container_nameOf node =
-- | We test that in a cluster, given a random node, we can find it by -- | 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, -- its name and alias, as long as all names and aliases are unique,
-- and that we fail to find a non-existing name. -- 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 (1, 20)) $ \ cnt ->
forAll (choose (0, cnt - 1)) $ \ fidx -> forAll (choose (0, cnt - 1)) $ \ fidx ->
forAll (genUniquesList (cnt * 2)) $ \ allnames -> forAll (genUniquesList (cnt * 2)) $ \ allnames ->
...@@ -680,9 +681,10 @@ prop_Container_findByName node = ...@@ -680,9 +681,10 @@ prop_Container_findByName node =
$ zip names nodes $ zip names nodes
nl' = Container.fromList nodes' nl' = Container.fromList nodes'
target = snd (nodes' !! fidx) target = snd (nodes' !! fidx)
in Container.findByName nl' (Node.name target) == Just target && in Container.findByName nl' (Node.name target) ==? Just target .&&.
Container.findByName nl' (Node.alias target) == Just target && Container.findByName nl' (Node.alias target) ==? Just target .&&.
isNothing (Container.findByName nl' othername) printTestCase "Found non-existing name"
(isNothing (Container.findByName nl' othername))
testSuite "Container" testSuite "Container"
[ 'prop_Container_addTwo [ 'prop_Container_addTwo
...@@ -870,13 +872,15 @@ prop_Text_Load_Node name tm nm fm td fd tc fo = ...@@ -870,13 +872,15 @@ prop_Text_Load_Node name tm nm fm td fd tc fo =
prop_Text_Load_NodeFail fields = prop_Text_Load_NodeFail fields =
length fields /= 8 ==> isNothing $ Text.loadNode Data.Map.empty fields length fields /= 8 ==> isNothing $ Text.loadNode Data.Map.empty fields
prop_Text_NodeLSIdempotent node = prop_Text_NodeLSIdempotent =
(Text.loadNode defGroupAssoc. forAll (genNode (Just 1) Nothing) $ \node ->
Utils.sepSplit '|' . Text.serializeNode defGroupList) n ==? -- override failN1 to what loadNode returns by default
Just (Node.name n, n) let n = Node.setPolicy Types.defIPolicy $
-- override failN1 to what loadNode returns by default node { Node.failN1 = True, Node.offline = False }
where n = Node.setPolicy Types.defIPolicy $ in
node { Node.failN1 = True, Node.offline = False } (Text.loadNode defGroupAssoc.
Utils.sepSplit '|' . Text.serializeNode defGroupList) n ==?
Just (Node.name n, n)
prop_Text_ISpecIdempotent ispec = prop_Text_ISpecIdempotent ispec =
case Text.loadISpec "dummy" . Utils.sepSplit ',' . case Text.loadISpec "dummy" . Utils.sepSplit ',' .
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment