Revision 7022db83
b/htest/Test/Ganeti/Confd/Utils.hs | ||
---|---|---|
41 | 41 |
import qualified Ganeti.Constants as C |
42 | 42 |
import qualified Ganeti.Hash as Hash |
43 | 43 |
|
44 |
instance Arbitrary Confd.ConfdRequestType where |
|
45 |
arbitrary = elements [minBound..maxBound] |
|
44 |
$(genArbitrary ''Confd.ConfdRequestType) |
|
46 | 45 |
|
47 |
instance Arbitrary Confd.ConfdReqField where |
|
48 |
arbitrary = elements [minBound..maxBound] |
|
46 |
$(genArbitrary ''Confd.ConfdReqField) |
|
49 | 47 |
|
50 |
instance Arbitrary Confd.ConfdReqQ where |
|
51 |
arbitrary = Confd.ConfdReqQ <$> arbitrary <*> arbitrary <*> |
|
52 |
arbitrary <*> arbitrary |
|
48 |
$(genArbitrary ''Confd.ConfdReqQ) |
|
53 | 49 |
|
54 | 50 |
instance Arbitrary Confd.ConfdQuery where |
55 | 51 |
arbitrary = oneof [ pure Confd.EmptyQuery |
... | ... | |
57 | 53 |
, Confd.DictQuery <$> arbitrary |
58 | 54 |
] |
59 | 55 |
|
60 |
instance Arbitrary Confd.ConfdRequest where |
|
61 |
arbitrary = Confd.ConfdRequest <$> arbitrary <*> arbitrary <*> arbitrary |
|
62 |
<*> arbitrary |
|
56 |
$(genArbitrary ''Confd.ConfdRequest) |
|
63 | 57 |
|
64 | 58 |
-- | Test that signing messages and checking signatures is correct. It |
65 | 59 |
-- also tests, indirectly the serialisation of messages so we don't |
b/htest/Test/Ganeti/HTools/Types.hs | ||
---|---|---|
56 | 56 |
|
57 | 57 |
-- * Arbitrary instance |
58 | 58 |
|
59 |
instance Arbitrary Types.AllocPolicy where |
|
60 |
arbitrary = elements [minBound..maxBound] |
|
59 |
$(genArbitrary ''Types.AllocPolicy) |
|
61 | 60 |
|
62 |
instance Arbitrary Types.DiskTemplate where |
|
63 |
arbitrary = elements [minBound..maxBound] |
|
61 |
$(genArbitrary ''Types.DiskTemplate) |
|
64 | 62 |
|
65 |
instance Arbitrary Types.FailMode where |
|
66 |
arbitrary = elements [minBound..maxBound] |
|
63 |
$(genArbitrary ''Types.FailMode) |
|
67 | 64 |
|
68 |
instance Arbitrary Types.EvacMode where |
|
69 |
arbitrary = elements [minBound..maxBound] |
|
65 |
$(genArbitrary ''Types.EvacMode) |
|
70 | 66 |
|
71 | 67 |
instance Arbitrary a => Arbitrary (Types.OpResult a) where |
72 | 68 |
arbitrary = arbitrary >>= \c -> |
b/htest/Test/Ganeti/Jobs.hs | ||
---|---|---|
37 | 37 |
|
38 | 38 |
-- * Arbitrary instances |
39 | 39 |
|
40 |
instance Arbitrary Jobs.OpStatus where |
|
41 |
arbitrary = elements [minBound..maxBound] |
|
40 |
$(genArbitrary ''Jobs.OpStatus) |
|
42 | 41 |
|
43 |
instance Arbitrary Jobs.JobStatus where |
|
44 |
arbitrary = elements [minBound..maxBound] |
|
42 |
$(genArbitrary ''Jobs.JobStatus) |
|
45 | 43 |
|
46 | 44 |
-- * Test cases |
47 | 45 |
|
b/htest/Test/Ganeti/Luxi.hs | ||
---|---|---|
48 | 48 |
|
49 | 49 |
-- * Luxi tests |
50 | 50 |
|
51 |
instance Arbitrary Luxi.TagObject where |
|
52 |
arbitrary = elements [minBound..maxBound] |
|
51 |
$(genArbitrary ''Luxi.TagObject) |
|
53 | 52 |
|
54 |
instance Arbitrary Luxi.LuxiReq where |
|
55 |
arbitrary = elements [minBound..maxBound] |
|
53 |
$(genArbitrary ''Luxi.LuxiReq) |
|
56 | 54 |
|
57 | 55 |
instance Arbitrary Luxi.LuxiOp where |
58 | 56 |
arbitrary = do |
b/htest/Test/Ganeti/Objects.hs | ||
---|---|---|
45 | 45 |
|
46 | 46 |
-- * Arbitrary instances |
47 | 47 |
|
48 |
instance Arbitrary Hypervisor where |
|
49 |
arbitrary = elements [minBound..maxBound] |
|
48 |
$(genArbitrary ''Hypervisor) |
|
50 | 49 |
|
51 |
instance Arbitrary PartialNDParams where |
|
52 |
arbitrary = PartialNDParams <$> arbitrary <*> arbitrary |
|
50 |
$(genArbitrary ''PartialNDParams) |
|
53 | 51 |
|
54 | 52 |
instance Arbitrary Node where |
55 | 53 |
arbitrary = Node <$> getFQDN <*> getFQDN <*> getFQDN |
... | ... | |
58 | 56 |
<*> arbitrary <*> arbitrary <*> getFQDN <*> arbitrary |
59 | 57 |
<*> (Set.fromList <$> genTags) |
60 | 58 |
|
61 |
instance Arbitrary FileDriver where |
|
62 |
arbitrary = elements [minBound..maxBound] |
|
59 |
$(genArbitrary ''FileDriver) |
|
63 | 60 |
|
64 |
instance Arbitrary BlockDriver where |
|
65 |
arbitrary = elements [minBound..maxBound] |
|
61 |
$(genArbitrary ''BlockDriver) |
|
66 | 62 |
|
67 |
instance Arbitrary DiskMode where |
|
68 |
arbitrary = elements [minBound..maxBound] |
|
63 |
$(genArbitrary ''DiskMode) |
|
69 | 64 |
|
70 | 65 |
instance Arbitrary DiskLogicalId where |
71 | 66 |
arbitrary = oneof [ LIDPlain <$> arbitrary <*> arbitrary |
... | ... | |
83 | 78 |
arbitrary = Disk <$> arbitrary <*> (pure []) <*> arbitrary |
84 | 79 |
<*> arbitrary <*> arbitrary |
85 | 80 |
|
86 |
instance Arbitrary PartialBeParams where |
|
87 |
-- FIXME: we should generate proper values, >=0, etc., but this is |
|
88 |
-- hard for partial ones, where all must be wrapped in a 'Maybe' |
|
89 |
arbitrary = PartialBeParams <$> arbitrary <*> arbitrary |
|
90 |
<*> arbitrary <*> arbitrary |
|
81 |
-- FIXME: we should generate proper values, >=0, etc., but this is |
|
82 |
-- hard for partial ones, where all must be wrapped in a 'Maybe' |
|
83 |
$(genArbitrary ''PartialBeParams) |
|
91 | 84 |
|
92 |
instance Arbitrary DiskTemplate where |
|
93 |
arbitrary = elements [minBound..maxBound] |
|
85 |
$(genArbitrary ''DiskTemplate) |
|
94 | 86 |
|
95 |
instance Arbitrary AdminState where |
|
96 |
arbitrary = elements [minBound..maxBound] |
|
87 |
$(genArbitrary ''AdminState) |
|
97 | 88 |
|
98 |
instance Arbitrary NICMode where |
|
99 |
arbitrary = elements [minBound..maxBound] |
|
89 |
$(genArbitrary ''NICMode) |
|
100 | 90 |
|
101 |
instance Arbitrary PartialNicParams where |
|
102 |
arbitrary = PartialNicParams <$> arbitrary <*> arbitrary |
|
91 |
$(genArbitrary ''PartialNicParams) |
|
103 | 92 |
|
104 |
instance Arbitrary PartialNic where |
|
105 |
arbitrary = PartialNic <$> arbitrary <*> arbitrary <*> arbitrary |
|
93 |
$(genArbitrary ''PartialNic) |
|
106 | 94 |
|
107 | 95 |
instance Arbitrary Instance where |
108 | 96 |
arbitrary = |
b/htest/Test/Ganeti/OpCodes.hs | ||
---|---|---|
46 | 46 |
|
47 | 47 |
-- * Arbitrary instances |
48 | 48 |
|
49 |
instance Arbitrary OpCodes.ReplaceDisksMode where |
|
50 |
arbitrary = elements [minBound..maxBound] |
|
49 |
$(genArbitrary ''OpCodes.ReplaceDisksMode) |
|
51 | 50 |
|
52 | 51 |
instance Arbitrary OpCodes.DiskIndex where |
53 | 52 |
arbitrary = choose (0, C.maxDisks - 1) >>= OpCodes.mkDiskIndex |
b/htest/Test/Ganeti/Query/Language.hs | ||
---|---|---|
72 | 72 |
n'' = max n' 2 -- but we don't want empty or 1-element lists, |
73 | 73 |
-- so use this for and/or filter list length |
74 | 74 |
|
75 |
instance Arbitrary Qlang.ItemType where |
|
76 |
arbitrary = elements [minBound..maxBound] |
|
75 |
$(genArbitrary ''Qlang.ItemType) |
|
77 | 76 |
|
78 | 77 |
instance Arbitrary Qlang.FilterRegex where |
79 | 78 |
arbitrary = getName >>= Qlang.mkRegex -- a name should be a good regex |
... | ... | |
81 | 80 |
-- | Tests that serialisation/deserialisation of filters is |
82 | 81 |
-- idempotent. |
83 | 82 |
prop_Serialisation :: Property |
84 |
prop_Serialisation = |
|
85 |
forAll genFilter testSerialisation |
|
83 |
prop_Serialisation = forAll genFilter testSerialisation |
|
86 | 84 |
|
87 | 85 |
prop_FilterRegex_instances :: Qlang.FilterRegex -> Property |
88 | 86 |
prop_FilterRegex_instances rex = |
b/htest/Test/Ganeti/Ssconf.hs | ||
---|---|---|
38 | 38 |
|
39 | 39 |
-- * Ssconf tests |
40 | 40 |
|
41 |
instance Arbitrary Ssconf.SSKey where |
|
42 |
arbitrary = elements [minBound..maxBound] |
|
41 |
$(genArbitrary ''Ssconf.SSKey) |
|
43 | 42 |
|
44 | 43 |
prop_filename :: Ssconf.SSKey -> Property |
45 | 44 |
prop_filename key = |
b/htest/Test/Ganeti/TestHTools.hs | ||
---|---|---|
28 | 28 |
|
29 | 29 |
module Test.Ganeti.TestHTools where |
30 | 30 |
|
31 |
import Test.QuickCheck |
|
32 |
|
|
33 | 31 |
import qualified Data.Map as Map |
34 | 32 |
|
33 |
import Test.Ganeti.TestHelper |
|
35 | 34 |
import Test.Ganeti.TestCommon |
36 | 35 |
|
37 | 36 |
import qualified Ganeti.Constants as C |
... | ... | |
120 | 119 |
|
121 | 120 |
-- * Arbitrary instances |
122 | 121 |
|
123 |
instance Arbitrary Types.InstanceStatus where |
|
124 |
arbitrary = elements [minBound..maxBound] |
|
122 |
$(genArbitrary ''Types.InstanceStatus) |
Also available in: Unified diff