Skip to content
Snippets Groups Projects
Commit d9b681ea authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Generators for disks


This patch adds generators for Disk instances to the Haskell
test code. It uses somewhat more reasonable generators to
fill the fields instead of just arbitrary values.
'genDiskWithChildren' is a generator that generates a disk
with a specified number of disk children. To avoid shooting
ourselves in the foot we do not generate further (grand)
child disks for the child disks. 'genDisk' calls
'genDiskWithChildren' by requesting three children as a
resonable default.

Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 9598b71f
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,8 @@ module Test.Ganeti.Objects ...@@ -31,6 +31,8 @@ module Test.Ganeti.Objects
( testObjects ( testObjects
, Node(..) , Node(..)
, genConfigDataWithNetworks , genConfigDataWithNetworks
, genDisk
, genDiskWithChildren
, genEmptyCluster , genEmptyCluster
, genInstWithNets , genInstWithNets
, genValidNetwork , genValidNetwork
...@@ -140,6 +142,21 @@ genInstWithNets nets = do ...@@ -140,6 +142,21 @@ genInstWithNets nets = do
new_inst = plain_inst { instNics = partial_nics } new_inst = plain_inst { instNics = partial_nics }
return new_inst return new_inst
genDiskWithChildren :: Int -> Gen Disk
genDiskWithChildren num_children = do
logicalid <- arbitrary
children <- vectorOf num_children (genDiskWithChildren 0)
ivname <- genName
size <- arbitrary
mode <- arbitrary
name <- genMaybe genName
uuid <- genName
let disk = Disk logicalid children ivname size mode name uuid
return disk
genDisk :: Gen Disk
genDisk = genDiskWithChildren 3
-- | FIXME: This generates completely random data, without normal -- | FIXME: This generates completely random data, without normal
-- validation rules. -- validation rules.
$(genArbitrary ''PartialISpecParams) $(genArbitrary ''PartialISpecParams)
......
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