From 752635d3111ce6fe89a50584c75d1126239620c8 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 20 Jun 2011 15:29:52 +0200 Subject: [PATCH] htools: fix prop_Node_rMem corner case This patch fixes a bug in the test specification where we allowed nodes with zero free memory (hence no instance can be added, at all) and adds a simple labeling of the way this test can fail. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- htools/Ganeti/HTools/QC.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htools/Ganeti/HTools/QC.hs b/htools/Ganeti/HTools/QC.hs index c3f4d4aa8..475144716 100644 --- a/htools/Ganeti/HTools/QC.hs +++ b/htools/Ganeti/HTools/QC.hs @@ -624,7 +624,8 @@ prop_Node_addSec node inst pdx = where _types = (node::Node.Node, inst::Instance.Instance, pdx::Int) -- | Checks for memory reservation changes -prop_Node_rMem node inst = +prop_Node_rMem inst = + forAll (arbitrary `suchThat` ((> 0) . Node.fMem)) $ \node -> -- ab = auto_balance, nb = non-auto_balance -- we use -1 as the primary node of the instance let inst' = inst { Instance.pNode = -1, Instance.auto_balance = True } @@ -641,6 +642,7 @@ prop_Node_rMem node inst = in case (node_add_ab, node_add_nb, node_del_ab, node_del_nb) of (Types.OpGood a_ab, Types.OpGood a_nb, Types.OpGood d_ab, Types.OpGood d_nb) -> + printTestCase "Consistency checks failed" $ Node.rMem a_ab > orig_rmem && Node.rMem a_ab - orig_rmem == Instance.mem inst_ab && Node.rMem a_nb == orig_rmem && @@ -650,7 +652,8 @@ prop_Node_rMem node inst = -- test as any inst_idx `elem` Node.sList a_ab && not (inst_idx `elem` Node.sList d_ab) - _ -> False + x -> printTestCase ("Failed to add/remove instances: " ++ show x) + False newtype SmallRatio = SmallRatio Double deriving Show instance Arbitrary SmallRatio where -- GitLab