diff --git a/htest/Test/Ganeti/HTools/Cluster.hs b/htest/Test/Ganeti/HTools/Cluster.hs index 96bd1cf52baa40f516ea5e1b4abd529ee7f1efa3..75525b4387adeab446c3be4383f0aafac7796272 100644 --- a/htest/Test/Ganeti/HTools/Cluster.hs +++ b/htest/Test/Ganeti/HTools/Cluster.hs @@ -37,7 +37,7 @@ import Test.Ganeti.TestHelper import Test.Ganeti.TestCommon import Test.Ganeti.TestHTools import Test.Ganeti.HTools.Instance ( genInstanceSmallerThanNode - , genInstanceSmallerThan ) + , genInstanceMaybeBiggerThanNode ) import Test.Ganeti.HTools.Node (genOnlineNode, genNode) import Ganeti.BasicTypes @@ -191,10 +191,7 @@ prop_CanTieredAlloc :: Property prop_CanTieredAlloc = forAll (choose (2, 5)) $ \count -> forAll (genOnlineNode `suchThat` isNodeBig 4) $ \node -> - forAll (genInstanceSmallerThan - (Node.availMem node + Types.unitMem * 2) - (Node.availDisk node + Types.unitDsk * 3) - (Node.availCpu node + Types.unitCpu * 4)) $ \inst -> + forAll (genInstanceMaybeBiggerThanNode node) $ \inst -> let nl = makeSmallCluster node count il = Container.empty rqnodes = Instance.requiredNodes $ Instance.diskTemplate inst diff --git a/htest/Test/Ganeti/HTools/Instance.hs b/htest/Test/Ganeti/HTools/Instance.hs index be6adc97f30a7bb77a450b4a892bd1301470ac6b..59ef515fcbf456f5aec08d83484c3ffdb22152a3 100644 --- a/htest/Test/Ganeti/HTools/Instance.hs +++ b/htest/Test/Ganeti/HTools/Instance.hs @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA module Test.Ganeti.HTools.Instance ( testHTools_Instance , genInstanceSmallerThanNode + , genInstanceMaybeBiggerThanNode , genInstanceSmallerThan , Instance.Instance(..) ) where @@ -66,6 +67,13 @@ genInstanceSmallerThanNode node = (Node.availDisk node `div` 2) (Node.availCpu node `div` 2) +-- | Generates an instance possibly bigger than a node. +genInstanceMaybeBiggerThanNode :: Node.Node -> Gen Instance.Instance +genInstanceMaybeBiggerThanNode node = + genInstanceSmallerThan (Node.availMem node + Types.unitMem * 2) + (Node.availDisk node + Types.unitDsk * 3) + (Node.availCpu node + Types.unitCpu * 4) + -- let's generate a random instance instance Arbitrary Instance.Instance where arbitrary = genInstanceSmallerThan maxMem maxDsk maxCpu