Revision 37483aa5 htools/Ganeti/HTools/QC.hs

b/htools/Ganeti/HTools/QC.hs
1128 1128

  
1129 1129
-- | Checks that on a 2-5 node cluster, we can allocate a random
1130 1130
-- instance spec via tiered allocation (whatever the original instance
1131
-- spec), on either one or two nodes.
1131
-- spec), on either one or two nodes. Furthermore, we test that
1132
-- computed allocation statistics are correct.
1132 1133
prop_ClusterCanTieredAlloc inst =
1133 1134
  forAll (choose (2, 5)) $ \count ->
1134 1135
  forAll (choose (1, 2)) $ \rqnodes ->
......
1138 1139
      allocnodes = Cluster.genAllocNodes defGroupList nl rqnodes True
1139 1140
  in case allocnodes >>= \allocnodes' ->
1140 1141
    Cluster.tieredAlloc nl il (Just 1) inst allocnodes' [] [] of
1141
       Types.Bad _ -> False
1142
       Types.Ok (_, _, il', ixes, cstats) -> not (null ixes) &&
1143
                                             IntMap.size il' == length ixes &&
1144
                                             length ixes == length cstats
1142
       Types.Bad msg -> failTest $ "Failed to tiered alloc: " ++ msg
1143
       Types.Ok (_, nl', il', ixes, cstats) ->
1144
         let (ai_alloc, ai_pool, ai_unav) =
1145
               Cluster.computeAllocationDelta
1146
                (Cluster.totalResources nl)
1147
                (Cluster.totalResources nl')
1148
             all_nodes = Container.elems nl
1149
         in property (not (null ixes)) .&&.
1150
            IntMap.size il' ==? length ixes .&&.
1151
            length ixes ==? length cstats .&&.
1152
            sum (map Types.allocInfoVCpus [ai_alloc, ai_pool, ai_unav]) ==?
1153
              sum (map Node.hiCpu all_nodes) .&&.
1154
            sum (map Types.allocInfoNCpus [ai_alloc, ai_pool, ai_unav]) ==?
1155
              sum (map Node.tCpu all_nodes) .&&.
1156
            sum (map Types.allocInfoMem [ai_alloc, ai_pool, ai_unav]) ==?
1157
              truncate (sum (map Node.tMem all_nodes)) .&&.
1158
            sum (map Types.allocInfoDisk [ai_alloc, ai_pool, ai_unav]) ==?
1159
              truncate (sum (map Node.tDsk all_nodes))
1145 1160

  
1146 1161
-- | Helper function to create a cluster with the given range of nodes
1147 1162
-- and allocate an instance on it.

Also available in: Unified diff