On Wed, May 15, 2013 at 4:29 PM, Klaus Aehlig <[email protected]> wrote:
> On Wed, May 15, 2013 at 03:39:10PM +0200, Helga Velroyen wrote: > > This patch introduces and enhances generators for > > instances: > > - 'genInstWithNets' is split into the generation of an > > arbitrary instance and enhancing an instance with nets > > - 'genInst' calls 'genInstWithNets' with an empty set > > of initial networks to provide a reasonable default > > - the Arbitrary instance of 'Instance' uses now 'genDisks' > > to create instances with a reasonable set of disks > > > > Signed-off-by: Helga Velroyen <[email protected]> > > --- > > test/hs/Test/Ganeti/Objects.hs | 15 +++++++++++++-- > > 1 file changed, 13 insertions(+), 2 deletions(-) > > > > diff --git a/test/hs/Test/Ganeti/Objects.hs > b/test/hs/Test/Ganeti/Objects.hs > > index da4a89d..46b31b9 100644 > > --- a/test/hs/Test/Ganeti/Objects.hs > > +++ b/test/hs/Test/Ganeti/Objects.hs > > @@ -34,6 +34,7 @@ module Test.Ganeti.Objects > > , genDisk > > , genDiskWithChildren > > , genEmptyCluster > > + , genInst > > , genInstWithNets > > , genValidNetwork > > , genBitStringMaxLen > > @@ -127,7 +128,7 @@ instance Arbitrary Instance where > > -- nics > > <*> arbitrary > > -- disks > > - <*> arbitrary > > + <*> vectorOf 5 genDisk > > Here we have another magic constant, and, as opposed to the > 3 in the first patch, it is not even mentioned in the commit > message where it comes from. Do we need an "arbitrary small number"? > It is certainly personal preference, but since we are just talking about tests, I thought we were okay with that. When picking a number, I generally consider this: - what is a realistic number in this case? (for example 300 disks is fairly rare ...) - what does still generate enough test data to make the test useful - what does not slow down the whole test run in general - what is a good trade-off between making the test code easy to understand and yet effective in testing the actual code I think since we are just talking about tests, we don't have to explain every piece of test data that we choose. I agree if you want to make it perfect, we would need a "small number" generator. Cheers, Helga
