Skip to content
Snippets Groups Projects
Commit ac1c0a07 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix up Cluster nodeEvac unittests for shared storage

Currently, these presume that the instance being generated always is
DRBD/relocatable (but won't be in the future), and also presume that
all relocation modes can be used (hint: not ☺️

).

So we add a couple of helper functions to restrict the used disk
templates/relocation modes, and these two tests are ready for shared
storage.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent a593113c
No related branches found
No related tags found
No related merge requests found
......@@ -232,6 +232,17 @@ genUniquesList cnt =
newelem <- arbitrary `suchThat` (`notElem` lst)
return (newelem:lst)) [] [1..cnt]
-- | Checks if an instance is mirrored.
isMirrored :: Instance.Instance -> Bool
isMirrored =
(/= Types.MirrorNone) . Types.templateMirrorType . Instance.diskTemplate
-- | Returns the possible change node types for a disk template.
evacModeOptions :: Types.MirrorType -> [Types.EvacMode]
evacModeOptions Types.MirrorNone = []
evacModeOptions Types.MirrorInternal = [minBound..maxBound] -- DRBD can do all
evacModeOptions Types.MirrorExternal = [Types.ChangePrimary, Types.ChangeAll]
-- * Arbitrary instances
-- | Defines a DNS name.
......@@ -1260,13 +1271,15 @@ check_EvacMode grp inst result =
prop_ClusterAllocEvacuate =
forAll (choose (4, 8)) $ \count ->
forAll (genOnlineNode `suchThat` (isNodeBig 4)) $ \node ->
forAll (genInstanceSmallerThanNode node) $ \inst ->
forAll (genInstanceSmallerThanNode node `suchThat` isMirrored) $ \inst ->
case genClusterAlloc count node inst of
Types.Bad msg -> failTest msg
Types.Ok (nl, il, inst') ->
conjoin $ map (\mode -> check_EvacMode defGroup inst' $
Cluster.tryNodeEvac defGroupList nl il mode
[Instance.idx inst']) [minBound..maxBound]
[Instance.idx inst']) .
evacModeOptions . Types.templateMirrorType .
Instance.diskTemplate $ inst'
-- | Checks that on a 4-8 node cluster with two node groups, once we
-- allocate an instance on the first node group, we can also change
......@@ -1274,7 +1287,7 @@ prop_ClusterAllocEvacuate =
prop_ClusterAllocChangeGroup =
forAll (choose (4, 8)) $ \count ->
forAll (genOnlineNode `suchThat` (isNodeBig 4)) $ \node ->
forAll (genInstanceSmallerThanNode node) $ \inst ->
forAll (genInstanceSmallerThanNode node `suchThat` isMirrored) $ \inst ->
case genClusterAlloc count node inst of
Types.Bad msg -> failTest msg
Types.Ok (nl, il, inst') ->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment