diff --git a/Ganeti/HTools/QC.hs b/Ganeti/HTools/QC.hs index 46fd430c0e505bae4ab7b72759a92085d11c6a8b..f59a92261b2ab750c50f0aaa72e02e9a8806bbf4 100644 --- a/Ganeti/HTools/QC.hs +++ b/Ganeti/HTools/QC.hs @@ -1,7 +1,12 @@ module Ganeti.HTools.QC - where + ( test_PeerMap + , test_Container + , test_Instance + , test_Node + ) where import Test.QuickCheck +import Test.QuickCheck.Batch import Data.Maybe import qualified Ganeti.HTools.CLI as CLI import qualified Ganeti.HTools.Cluster as Cluster @@ -81,6 +86,14 @@ prop_PeerMap_maxElem pmap = where _types = pmap::PeerMap.PeerMap puniq = PeerMap.accumArray const pmap +test_PeerMap = + [ run prop_PeerMap_addIdempotent + , run prop_PeerMap_removeIdempotent + , run prop_PeerMap_maxElem + , run prop_PeerMap_addFind + , run prop_PeerMap_findMissing + ] + -- Container tests prop_Container_addTwo cdata i1 i2 = @@ -91,6 +104,8 @@ prop_Container_addTwo cdata i1 i2 = cont = foldl (\c x -> Container.add x x c) Container.empty cdata fn x1 x2 = Container.addTwo x1 x1 x2 x2 +test_Container = + [ run prop_Container_addTwo ] -- Simple instance tests, we only have setter/getters @@ -115,6 +130,16 @@ prop_Instance_setBoth inst pdx sdx = where _types = (inst::Instance.Instance, pdx::Types.Ndx, sdx::Types.Ndx) si = Instance.setBoth inst pdx sdx +test_Instance = + [ run prop_Instance_setIdx + , run prop_Instance_setName + , run prop_Instance_setPri + , run prop_Instance_setSec + , run prop_Instance_setBoth + ] + +-- Node tests + -- | Check that an instance add with too high memory or disk will be rejected prop_Node_addPri node inst = (Instance.mem inst >= Node.f_mem node || Instance.dsk inst >= Node.f_dsk node) && @@ -131,3 +156,8 @@ prop_Node_addSec node inst pdx = (not $ Node.failN1 node) ==> isNothing(Node.addSec node inst pdx) where _types = (node::Node.Node, inst::Instance.Instance, pdx::Int) + +test_Node = + [ run prop_Node_addPri + , run prop_Node_addSec + ] diff --git a/test.hs b/test.hs index 14227e9a28be67f22c4b0486fa4c0c84ba113724..366f6b9ef65e43301d483d975aadfe65842d8467 100644 --- a/test.hs +++ b/test.hs @@ -13,26 +13,7 @@ options = TestOptions , debug_tests = False } main = do - runTests "PeerMap" options - [ run prop_PeerMap_addIdempotent - , run prop_PeerMap_removeIdempotent - , run prop_PeerMap_maxElem - , run prop_PeerMap_addFind - , run prop_PeerMap_findMissing - ] - - runTests "Container" options - [ run prop_Container_addTwo ] - - runTests "Instance" options - [ run prop_Instance_setIdx - , run prop_Instance_setName - , run prop_Instance_setPri - , run prop_Instance_setSec - , run prop_Instance_setBoth - ] - - runTests "Node" options - [ run prop_Node_addPri - , run prop_Node_addSec - ] + runTests "PeerMap" options test_PeerMap + runTests "Container" options test_Container + runTests "Instance" options test_Instance + runTests "Node" options test_Node