Revision 5b11f8db htest/Test/Ganeti/HTools/Cluster.hs

b/htest/Test/Ganeti/HTools/Cluster.hs
47 47
import qualified Ganeti.HTools.Node as Node
48 48
import qualified Ganeti.HTools.Types as Types
49 49

  
50
{-# ANN module "HLint: ignore Use camelCase" #-}
51

  
50 52
-- * Helpers
51 53

  
52 54
-- | Make a small cluster, both nodes and instances.
......
148 150
prop_CanTieredAlloc :: Instance.Instance -> Property
149 151
prop_CanTieredAlloc inst =
150 152
  forAll (choose (2, 5)) $ \count ->
151
  forAll (genOnlineNode `suchThat` (isNodeBig 4)) $ \node ->
153
  forAll (genOnlineNode `suchThat` isNodeBig 4) $ \node ->
152 154
  let nl = makeSmallCluster node count
153 155
      il = Container.empty
154 156
      rqnodes = Instance.requiredNodes $ Instance.diskTemplate inst
......
196 198
prop_AllocRelocate :: Property
197 199
prop_AllocRelocate =
198 200
  forAll (choose (4, 8)) $ \count ->
199
  forAll (genOnlineNode `suchThat` (isNodeBig 4)) $ \node ->
201
  forAll (genOnlineNode `suchThat` isNodeBig 4) $ \node ->
200 202
  forAll (genInstanceSmallerThanNode node `suchThat` isMirrored) $ \inst ->
201 203
  case genClusterAlloc count node inst of
202 204
    Types.Bad msg -> failTest msg
......
230 232
                                         (gdx == Group.idx grp)
231 233
           v -> failmsg  ("invalid solution: " ++ show v) False
232 234
  where failmsg :: String -> Bool -> Property
233
        failmsg = \msg -> printTestCase ("Failed to evacuate: " ++ msg)
235
        failmsg msg = printTestCase ("Failed to evacuate: " ++ msg)
234 236
        idx = Instance.idx inst
235 237

  
236 238
-- | Checks that on a 4-8 node cluster, once we allocate an instance,
......
238 240
prop_AllocEvacuate :: Property
239 241
prop_AllocEvacuate =
240 242
  forAll (choose (4, 8)) $ \count ->
241
  forAll (genOnlineNode `suchThat` (isNodeBig 4)) $ \node ->
243
  forAll (genOnlineNode `suchThat` isNodeBig 4) $ \node ->
242 244
  forAll (genInstanceSmallerThanNode node `suchThat` isMirrored) $ \inst ->
243 245
  case genClusterAlloc count node inst of
244 246
    Types.Bad msg -> failTest msg
......
255 257
prop_AllocChangeGroup :: Property
256 258
prop_AllocChangeGroup =
257 259
  forAll (choose (4, 8)) $ \count ->
258
  forAll (genOnlineNode `suchThat` (isNodeBig 4)) $ \node ->
260
  forAll (genOnlineNode `suchThat` isNodeBig 4) $ \node ->
259 261
  forAll (genInstanceSmallerThanNode node `suchThat` isMirrored) $ \inst ->
260 262
  case genClusterAlloc count node inst of
261 263
    Types.Bad msg -> failTest msg
......
327 329
canAllocOn :: Node.List -> Int -> Instance.Instance -> Bool
328 330
canAllocOn nl reqnodes inst =
329 331
  case Cluster.genAllocNodes defGroupList nl reqnodes True >>=
330
       Cluster.tryAlloc nl (Container.empty) inst of
332
       Cluster.tryAlloc nl Container.empty inst of
331 333
       Types.Bad _ -> False
332 334
       Types.Ok as ->
333 335
         case Cluster.asSolution as of
......
344 346
  -- rqn is the required nodes (1 or 2)
345 347
  forAll (choose (1, 2)) $ \rqn ->
346 348
  forAll (choose (5, 20)) $ \count ->
347
  forAll (arbitrary `suchThat` (canAllocOn (makeSmallCluster node count) rqn))
349
  forAll (arbitrary `suchThat` canAllocOn (makeSmallCluster node count) rqn)
348 350
         $ \inst ->
349 351
  forAll (arbitrary `suchThat` (isFailure .
350 352
                                Instance.instMatchesPolicy inst)) $ \ipol ->

Also available in: Unified diff