Commit c6e8fb9c authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix a few tests that hard-coded the number of nodes



Instead of randomly generating the number of required nodes or
hard-coding it, compute it from the disk template of the
instance. Otherwise tests will fail when the disk template is not
DRBD8 and we ask for allocation on 2 nodes.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 90669369
...@@ -848,12 +848,12 @@ prop_Text_IPolicyIdempotent ipol = ...@@ -848,12 +848,12 @@ prop_Text_IPolicyIdempotent ipol =
-- small cluster sizes. -- small cluster sizes.
prop_Text_CreateSerialise = prop_Text_CreateSerialise =
forAll genTags $ \ctags -> forAll genTags $ \ctags ->
forAll (choose (1, 2)) $ \reqnodes ->
forAll (choose (1, 20)) $ \maxiter -> forAll (choose (1, 20)) $ \maxiter ->
forAll (choose (2, 10)) $ \count -> forAll (choose (2, 10)) $ \count ->
forAll genOnlineNode $ \node -> forAll genOnlineNode $ \node ->
forAll (genInstanceSmallerThanNode node) $ \inst -> forAll (genInstanceSmallerThanNode node) $ \inst ->
let nl = makeSmallCluster node count let nl = makeSmallCluster node count
reqnodes = Instance.requiredNodes $ Instance.diskTemplate inst
in case Cluster.genAllocNodes defGroupList nl reqnodes True >>= \allocn -> in case Cluster.genAllocNodes defGroupList nl reqnodes True >>= \allocn ->
Cluster.iterateAlloc nl Container.empty (Just maxiter) inst allocn [] [] Cluster.iterateAlloc nl Container.empty (Just maxiter) inst allocn [] []
of of
...@@ -1161,7 +1161,8 @@ prop_ClusterAlloc_sane inst = ...@@ -1161,7 +1161,8 @@ prop_ClusterAlloc_sane inst =
forAll (choose (5, 20)) $ \count -> forAll (choose (5, 20)) $ \count ->
forAll genOnlineNode $ \node -> forAll genOnlineNode $ \node ->
let (nl, il, inst') = makeSmallEmptyCluster node count inst let (nl, il, inst') = makeSmallEmptyCluster node count inst
in case Cluster.genAllocNodes defGroupList nl 2 True >>= reqnodes = Instance.requiredNodes $ Instance.diskTemplate inst
in case Cluster.genAllocNodes defGroupList nl reqnodes True >>=
Cluster.tryAlloc nl il inst' of Cluster.tryAlloc nl il inst' of
Types.Bad _ -> False Types.Bad _ -> False
Types.Ok as -> Types.Ok as ->
...@@ -1178,10 +1179,10 @@ prop_ClusterAlloc_sane inst = ...@@ -1178,10 +1179,10 @@ prop_ClusterAlloc_sane inst =
-- computed allocation statistics are correct. -- computed allocation statistics are correct.
prop_ClusterCanTieredAlloc inst = prop_ClusterCanTieredAlloc inst =
forAll (choose (2, 5)) $ \count -> forAll (choose (2, 5)) $ \count ->
forAll (choose (1, 2)) $ \rqnodes ->
forAll (genOnlineNode `suchThat` (isNodeBig 4)) $ \node -> forAll (genOnlineNode `suchThat` (isNodeBig 4)) $ \node ->
let nl = makeSmallCluster node count let nl = makeSmallCluster node count
il = Container.empty il = Container.empty
rqnodes = Instance.requiredNodes $ Instance.diskTemplate inst
allocnodes = Cluster.genAllocNodes defGroupList nl rqnodes True allocnodes = Cluster.genAllocNodes defGroupList nl rqnodes True
in case allocnodes >>= \allocnodes' -> in case allocnodes >>= \allocnodes' ->
Cluster.tieredAlloc nl il (Just 1) inst allocnodes' [] [] of Cluster.tieredAlloc nl il (Just 1) inst allocnodes' [] [] of
...@@ -1208,7 +1209,8 @@ prop_ClusterCanTieredAlloc inst = ...@@ -1208,7 +1209,8 @@ prop_ClusterCanTieredAlloc inst =
-- and allocate an instance on it. -- and allocate an instance on it.
genClusterAlloc count node inst = genClusterAlloc count node inst =
let nl = makeSmallCluster node count let nl = makeSmallCluster node count
in case Cluster.genAllocNodes defGroupList nl 2 True >>= reqnodes = Instance.requiredNodes $ Instance.diskTemplate inst
in case Cluster.genAllocNodes defGroupList nl reqnodes True >>=
Cluster.tryAlloc nl Container.empty inst of Cluster.tryAlloc nl Container.empty inst of
Types.Bad _ -> Types.Bad "Can't allocate" Types.Bad _ -> Types.Bad "Can't allocate"
Types.Ok as -> Types.Ok as ->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment