Revision 232fc505 htools/Ganeti/HTools/QC.hs
b/htools/Ganeti/HTools/QC.hs | ||
---|---|---|
666 | 666 |
-- | We test that in a cluster, given a random node, we can find it by |
667 | 667 |
-- its name and alias, as long as all names and aliases are unique, |
668 | 668 |
-- and that we fail to find a non-existing name. |
669 |
prop_Container_findByName node = |
|
669 |
prop_Container_findByName = |
|
670 |
forAll (genNode (Just 1) Nothing) $ \node -> |
|
670 | 671 |
forAll (choose (1, 20)) $ \ cnt -> |
671 | 672 |
forAll (choose (0, cnt - 1)) $ \ fidx -> |
672 | 673 |
forAll (genUniquesList (cnt * 2)) $ \ allnames -> |
... | ... | |
680 | 681 |
$ zip names nodes |
681 | 682 |
nl' = Container.fromList nodes' |
682 | 683 |
target = snd (nodes' !! fidx) |
683 |
in Container.findByName nl' (Node.name target) == Just target && |
|
684 |
Container.findByName nl' (Node.alias target) == Just target && |
|
685 |
isNothing (Container.findByName nl' othername) |
|
684 |
in Container.findByName nl' (Node.name target) ==? Just target .&&. |
|
685 |
Container.findByName nl' (Node.alias target) ==? Just target .&&. |
|
686 |
printTestCase "Found non-existing name" |
|
687 |
(isNothing (Container.findByName nl' othername)) |
|
686 | 688 |
|
687 | 689 |
testSuite "Container" |
688 | 690 |
[ 'prop_Container_addTwo |
... | ... | |
870 | 872 |
prop_Text_Load_NodeFail fields = |
871 | 873 |
length fields /= 8 ==> isNothing $ Text.loadNode Data.Map.empty fields |
872 | 874 |
|
873 |
prop_Text_NodeLSIdempotent node = |
|
874 |
(Text.loadNode defGroupAssoc. |
|
875 |
Utils.sepSplit '|' . Text.serializeNode defGroupList) n ==? |
|
876 |
Just (Node.name n, n) |
|
877 |
-- override failN1 to what loadNode returns by default |
|
878 |
where n = Node.setPolicy Types.defIPolicy $ |
|
879 |
node { Node.failN1 = True, Node.offline = False } |
|
875 |
prop_Text_NodeLSIdempotent = |
|
876 |
forAll (genNode (Just 1) Nothing) $ \node -> |
|
877 |
-- override failN1 to what loadNode returns by default |
|
878 |
let n = Node.setPolicy Types.defIPolicy $ |
|
879 |
node { Node.failN1 = True, Node.offline = False } |
|
880 |
in |
|
881 |
(Text.loadNode defGroupAssoc. |
|
882 |
Utils.sepSplit '|' . Text.serializeNode defGroupList) n ==? |
|
883 |
Just (Node.name n, n) |
|
880 | 884 |
|
881 | 885 |
prop_Text_ISpecIdempotent ispec = |
882 | 886 |
case Text.loadISpec "dummy" . Utils.sepSplit ',' . |
Also available in: Unified diff