Commit 736ba160 authored by Guido Trotter's avatar Guido Trotter
Browse files

Add generator for list of arbitrary nodes



This generates a minimum of one node, because legal clusters never have
zero nodes.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 5a736782
......@@ -32,6 +32,7 @@ module Test.Ganeti.HTools.Node
, setInstanceSmallerThanNode
, genNode
, genOnlineNode
, genNodeList
) where
import Test.QuickCheck
......@@ -46,6 +47,7 @@ import Test.Ganeti.TestHTools
import Test.Ganeti.HTools.Instance (genInstanceSmallerThanNode)
import Ganeti.BasicTypes
import qualified Ganeti.HTools.Loader as Loader
import qualified Ganeti.HTools.Container as Container
import qualified Ganeti.HTools.Instance as Instance
import qualified Ganeti.HTools.Node as Node
......@@ -97,6 +99,14 @@ genOnlineNode =
instance Arbitrary Node.Node where
arbitrary = genNode Nothing Nothing
-- | Node list generator.
-- Given a node generator, create a random length node list. Note that "real"
-- clusters always have at least one node, so we don't generate empty node
-- lists here.
genNodeList :: Gen Node.Node -> Gen Node.List
genNodeList ngen = fmap (snd . Loader.assignIndices) names_nodes
where names_nodes = (fmap . map) (\n -> (Node.name n, n)) $ listOf1 ngen
-- * Test cases
prop_setAlias :: Node.Node -> String -> Bool
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment