diff --git a/htest/Test/Ganeti/HTools/Instance.hs b/htest/Test/Ganeti/HTools/Instance.hs index 59ef515fcbf456f5aec08d83484c3ffdb22152a3..2b046720b426d02e527b92c50958fb172df1bd98 100644 --- a/htest/Test/Ganeti/HTools/Instance.hs +++ b/htest/Test/Ganeti/HTools/Instance.hs @@ -31,6 +31,7 @@ module Test.Ganeti.HTools.Instance , genInstanceSmallerThanNode , genInstanceMaybeBiggerThanNode , genInstanceSmallerThan + , genInstanceList , Instance.Instance(..) ) where @@ -43,6 +44,7 @@ import Test.Ganeti.HTools.Types () import Ganeti.BasicTypes import qualified Ganeti.HTools.Instance as Instance import qualified Ganeti.HTools.Node as Node +import qualified Ganeti.HTools.Loader as Loader import qualified Ganeti.HTools.Types as Types -- * Arbitrary instances @@ -74,6 +76,12 @@ genInstanceMaybeBiggerThanNode node = (Node.availDisk node + Types.unitDsk * 3) (Node.availCpu node + Types.unitCpu * 4) +-- | Generates an instance list given an instance generator. +genInstanceList :: Gen Instance.Instance -> Gen Instance.List +genInstanceList igen = fmap (snd . Loader.assignIndices) names_instances + where names_instances = + (fmap . map) (\n -> (Instance.name n, n)) $ listOf igen + -- let's generate a random instance instance Arbitrary Instance.Instance where arbitrary = genInstanceSmallerThan maxMem maxDsk maxCpu