Revision 10ef6b4e Ganeti/HTools/QC.hs
b/Ganeti/HTools/QC.hs | ||
---|---|---|
56 | 56 |
import qualified Ganeti.HTools.Loader as Loader |
57 | 57 |
import qualified Ganeti.HTools.Luxi |
58 | 58 |
import qualified Ganeti.HTools.Node as Node |
59 |
import qualified Ganeti.HTools.Group as Group |
|
59 | 60 |
import qualified Ganeti.HTools.PeerMap as PeerMap |
60 | 61 |
import qualified Ganeti.HTools.Rapi |
61 | 62 |
import qualified Ganeti.HTools.Simu |
... | ... | |
78 | 79 |
maxCpu :: Int |
79 | 80 |
maxCpu = 1024 |
80 | 81 |
|
82 |
defGroup :: Group.Group |
|
83 |
defGroup = flip Group.setIdx 0 $ |
|
84 |
Group.create "default" Utils.defaultGroupID |
|
85 |
Types.AllocPreferred |
|
86 |
|
|
87 |
defGroupList :: Group.List |
|
88 |
defGroupList = Container.fromAssocList [(Group.idx defGroup, defGroup)] |
|
89 |
|
|
90 |
defGroupAssoc :: Data.Map.Map String Types.Gdx |
|
91 |
defGroupAssoc = Data.Map.singleton (Group.uuid defGroup) (Group.idx defGroup) |
|
92 |
|
|
81 | 93 |
-- * Helper functions |
82 | 94 |
|
83 | 95 |
-- | Simple checker for whether OpResult is fail or pass |
... | ... | |
187 | 199 |
offl <- arbitrary |
188 | 200 |
let n = Node.create name (fromIntegral mem_t) mem_n mem_f |
189 | 201 |
(fromIntegral dsk_t) dsk_f (fromIntegral cpu_t) offl |
190 |
Utils.defaultGroupID
|
|
202 |
0
|
|
191 | 203 |
n' = Node.buildPeers n Container.empty |
192 | 204 |
return n' |
193 | 205 |
|
... | ... | |
483 | 495 |
then "Y" |
484 | 496 |
else "N" |
485 | 497 |
any_broken = any (< 0) [tm, nm, fm, td, fd, tc] |
486 |
in case Text.loadNode [name, tm_s, nm_s, fm_s, td_s, fd_s, tc_s, fo_s] of |
|
498 |
gid = Group.uuid defGroup |
|
499 |
in case Text.loadNode defGroupAssoc |
|
500 |
[name, tm_s, nm_s, fm_s, td_s, fd_s, tc_s, fo_s, gid] of |
|
487 | 501 |
Nothing -> False |
488 | 502 |
Just (name', node) -> |
489 | 503 |
if fo || any_broken |
... | ... | |
498 | 512 |
Node.tCpu node == fromIntegral tc |
499 | 513 |
|
500 | 514 |
prop_Text_Load_NodeFail fields = |
501 |
length fields /= 8 ==> isNothing $ Text.loadNode fields |
|
515 |
length fields /= 8 ==> isNothing $ Text.loadNode Data.Map.empty fields
|
|
502 | 516 |
|
503 | 517 |
prop_Text_NodeLSIdempotent node = |
504 |
(Text.loadNode . |
|
505 |
Utils.sepSplit '|' . Text.serializeNode) n == |
|
518 |
(Text.loadNode defGroupAssoc.
|
|
519 |
Utils.sepSplit '|' . Text.serializeNode defGroupList) n ==
|
|
506 | 520 |
Just (Node.name n, n) |
507 | 521 |
-- override failN1 to what loadNode returns by default |
508 | 522 |
where n = node { Node.failN1 = True, Node.offline = False } |
... | ... | |
750 | 764 |
prop_ClusterCheckConsistency node inst = |
751 | 765 |
let nl = makeSmallCluster node 3 |
752 | 766 |
[node1, node2, node3] = Container.elems nl |
753 |
node3' = node3 { Node.group = "other-uuid" }
|
|
767 |
node3' = node3 { Node.group = 1 }
|
|
754 | 768 |
nl' = Container.add (Node.idx node3') node3' nl |
755 | 769 |
inst1 = Instance.setBoth inst (Node.idx node1) (Node.idx node2) |
756 | 770 |
inst2 = Instance.setBoth inst (Node.idx node1) Node.noSecondary |
Also available in: Unified diff