Skip to content
Snippets Groups Projects
Commit bdb7dbbb authored by Guido Trotter's avatar Guido Trotter
Browse files

Add generator for list of arbitrary instances


This takes an instance generator and produces a possibly empty list of
instances.

Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 736ba160
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
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