From 2b296ad40cf06ac5ae97076372001020cf820635 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 23 May 2014 13:12:11 +0200 Subject: [PATCH] Relax test requirements Instead of insisting on perfect equality of score allow for numerical inaccuracies and consider everything all differences in the cluster score smaller than 1e-12 negligible. Given that, by default, a cluster with a score of less than 1e-9 is considered perfectly balanced, this relaxation is on the save side. Signed-off-by: Klaus Aehlig Reviewed-by: Petr Pudlak --- test/hs/Test/Ganeti/HTools/Cluster.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/hs/Test/Ganeti/HTools/Cluster.hs b/test/hs/Test/Ganeti/HTools/Cluster.hs index 089d797cc..8d0f55aa9 100644 --- a/test/hs/Test/Ganeti/HTools/Cluster.hs +++ b/test/hs/Test/Ganeti/HTools/Cluster.hs @@ -68,7 +68,9 @@ isNodeBig size node = Node.availDisk node > size * Types.unitDsk && Node.availCpu node > size * Types.unitCpu canBalance :: Cluster.Table -> Bool -> Bool -> Bool -> Bool -canBalance tbl dm im evac = isJust $ Cluster.tryBalance tbl dm im evac False 0 0 +canBalance tbl@(Cluster.Table _ _ ini_cv _) dm im evac = + maybe False (\(Cluster.Table _ _ fin_cv _) -> ini_cv - fin_cv > 1e-12) + $ Cluster.tryBalance tbl dm im evac False 0 0 -- | Assigns a new fresh instance to a cluster; this is not -- allocation, so no resource checks are done. @@ -147,8 +149,8 @@ prop_Alloc_sane inst = tbl = Cluster.Table xnl il' cv [] in printTestCase "Cluster can be balanced after allocation" (not (canBalance tbl True True False)) .&&. - printTestCase "Solution score differs from actual node list:" - (Cluster.compCV xnl ==? cv) + printTestCase "Solution score differs from actual node list" + (abs (Cluster.compCV xnl - cv) < 1e-12) -- | Checks that on a 2-5 node cluster, we can allocate a random -- instance spec via tiered allocation (whatever the original instance -- GitLab