1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
| | Fix ordering of Arbitrary definitions for GHC 9 compatibility.
Taken from upstream:
https://github.com/ganeti/ganeti/commit/feab8faa8fe055c89205497e4f277ae4c7b8caad
diff --git a/test/hs/Test/Ganeti/Objects.hs b/test/hs/Test/Ganeti/Objects.hs
index 97ceb36dca..8d80be9e80 100644
--- a/test/hs/Test/Ganeti/Objects.hs
+++ b/test/hs/Test/Ganeti/Objects.hs
@@ -93,8 +93,14 @@ instance Arbitrary (Container DataCollectorConfig) where
instance Arbitrary BS.ByteString where
arbitrary = genPrintableByteString
+instance Arbitrary a => Arbitrary (Private a) where
+ arbitrary = Private <$> arbitrary
+
$(genArbitrary ''PartialNDParams)
+instance Arbitrary (Container J.JSValue) where
+ arbitrary = return $ GenericContainer Map.empty
+
instance Arbitrary Node where
arbitrary = Node <$> genFQDN <*> genFQDN <*> genFQDN
<*> arbitrary <*> arbitrary <*> arbitrary <*> genFQDN
@@ -297,10 +303,6 @@ genDisk = genDiskWithChildren 3
-- validation rules.
$(genArbitrary ''PartialISpecParams)
--- | FIXME: This generates completely random data, without normal
--- validation rules.
-$(genArbitrary ''PartialIPolicy)
-
$(genArbitrary ''FilledISpecParams)
$(genArbitrary ''MinMaxISpecs)
$(genArbitrary ''FilledIPolicy)
@@ -309,6 +311,10 @@ $(genArbitrary ''FilledNDParams)
$(genArbitrary ''FilledNicParams)
$(genArbitrary ''FilledBeParams)
+-- | FIXME: This generates completely random data, without normal
+-- validation rules.
+$(genArbitrary ''PartialIPolicy)
+
-- | No real arbitrary instance for 'ClusterHvParams' yet.
instance Arbitrary ClusterHvParams where
arbitrary = return $ GenericContainer Map.empty
@@ -331,18 +337,12 @@ instance Arbitrary OsParams where
instance Arbitrary Objects.ClusterOsParamsPrivate where
arbitrary = (GenericContainer . Map.fromList) <$> arbitrary
-instance Arbitrary a => Arbitrary (Private a) where
- arbitrary = Private <$> arbitrary
-
instance Arbitrary ClusterOsParams where
arbitrary = (GenericContainer . Map.fromList) <$> arbitrary
instance Arbitrary ClusterBeParams where
arbitrary = (GenericContainer . Map.fromList) <$> arbitrary
-instance Arbitrary IAllocatorParams where
- arbitrary = return $ GenericContainer Map.empty
-
$(genArbitrary ''Cluster)
instance Arbitrary ConfigData where
diff --git a/test/hs/Test/Ganeti/Query/Language.hs b/test/hs/Test/Ganeti/Query/Language.hs
index 04fb8c3898..fa50196f00 100644
--- a/test/hs/Test/Ganeti/Query/Language.hs
+++ b/test/hs/Test/Ganeti/Query/Language.hs
@@ -59,6 +59,9 @@ import Ganeti.Query.Language
instance Arbitrary (Filter FilterField) where
arbitrary = genFilter
+instance Arbitrary FilterRegex where
+ arbitrary = genName >>= mkRegex -- a name should be a good regex
+
-- | Custom 'Filter' generator (top-level), which enforces a
-- (sane) limit on the depth of the generated filters.
genFilter :: Gen (Filter FilterField)
@@ -97,9 +100,6 @@ $(genArbitrary ''QueryTypeLuxi)
$(genArbitrary ''ItemType)
-instance Arbitrary FilterRegex where
- arbitrary = genName >>= mkRegex -- a name should be a good regex
-
$(genArbitrary ''ResultStatus)
$(genArbitrary ''FieldType)
|