Skip to content
Snippets Groups Projects
Commit cf35a869 authored by Iustin Pop's avatar Iustin Pop
Browse files

Test some cases for the cluster score computation

parent 1ae7a904
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ module Ganeti.HTools.QC
, test_Instance
, test_Node
, test_Text
, test_Cluster
) where
import Test.QuickCheck
......@@ -243,3 +244,22 @@ test_Node =
[ run prop_Node_addPri
, run prop_Node_addSec
]
-- Cluster tests
-- | Check that the cluster score is close to zero for a homogeneous cluster
prop_Score_Zero node count =
((not $ Node.offline node) && (not $ Node.failN1 node) && (count > 0) &&
(Node.t_dsk node > 0) && (Node.t_mem node > 0)) ==>
let fn = Node.buildPeers node Container.empty
nlst = (zip [1..] $ replicate count fn)::[(Types.Ndx, Node.Node)]
nl = Container.fromAssocList nlst
score = Cluster.compCV nl
-- we can't say == 0 here as the floating point errors accumulate;
-- this should be much lower than the default score in CLI.hs
in score > 1e-15
test_Cluster =
[ run prop_Score_Zero
]
......@@ -39,3 +39,4 @@ main = do
runTests "Instance" options test_Instance
runTests "Node" options test_Node
runTests "Text" options test_Text
runTests "Cluster" options test_Cluster
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