Revision 20bc5360 htest/Test/Ganeti/HTools/Instance.hs
b/htest/Test/Ganeti/HTools/Instance.hs | ||
---|---|---|
72 | 72 |
|
73 | 73 |
-- Simple instance tests, we only have setter/getters |
74 | 74 |
|
75 |
prop_Instance_creat :: Instance.Instance -> Property
|
|
76 |
prop_Instance_creat inst =
|
|
75 |
prop_creat :: Instance.Instance -> Property |
|
76 |
prop_creat inst = |
|
77 | 77 |
Instance.name inst ==? Instance.alias inst |
78 | 78 |
|
79 |
prop_Instance_setIdx :: Instance.Instance -> Types.Idx -> Property
|
|
80 |
prop_Instance_setIdx inst idx =
|
|
79 |
prop_setIdx :: Instance.Instance -> Types.Idx -> Property |
|
80 |
prop_setIdx inst idx = |
|
81 | 81 |
Instance.idx (Instance.setIdx inst idx) ==? idx |
82 | 82 |
|
83 |
prop_Instance_setName :: Instance.Instance -> String -> Bool
|
|
84 |
prop_Instance_setName inst name =
|
|
83 |
prop_setName :: Instance.Instance -> String -> Bool |
|
84 |
prop_setName inst name = |
|
85 | 85 |
Instance.name newinst == name && |
86 | 86 |
Instance.alias newinst == name |
87 | 87 |
where newinst = Instance.setName inst name |
88 | 88 |
|
89 |
prop_Instance_setAlias :: Instance.Instance -> String -> Bool
|
|
90 |
prop_Instance_setAlias inst name =
|
|
89 |
prop_setAlias :: Instance.Instance -> String -> Bool |
|
90 |
prop_setAlias inst name = |
|
91 | 91 |
Instance.name newinst == Instance.name inst && |
92 | 92 |
Instance.alias newinst == name |
93 | 93 |
where newinst = Instance.setAlias inst name |
94 | 94 |
|
95 |
prop_Instance_setPri :: Instance.Instance -> Types.Ndx -> Property
|
|
96 |
prop_Instance_setPri inst pdx =
|
|
95 |
prop_setPri :: Instance.Instance -> Types.Ndx -> Property |
|
96 |
prop_setPri inst pdx = |
|
97 | 97 |
Instance.pNode (Instance.setPri inst pdx) ==? pdx |
98 | 98 |
|
99 |
prop_Instance_setSec :: Instance.Instance -> Types.Ndx -> Property
|
|
100 |
prop_Instance_setSec inst sdx =
|
|
99 |
prop_setSec :: Instance.Instance -> Types.Ndx -> Property |
|
100 |
prop_setSec inst sdx = |
|
101 | 101 |
Instance.sNode (Instance.setSec inst sdx) ==? sdx |
102 | 102 |
|
103 |
prop_Instance_setBoth :: Instance.Instance -> Types.Ndx -> Types.Ndx -> Bool
|
|
104 |
prop_Instance_setBoth inst pdx sdx =
|
|
103 |
prop_setBoth :: Instance.Instance -> Types.Ndx -> Types.Ndx -> Bool |
|
104 |
prop_setBoth inst pdx sdx = |
|
105 | 105 |
Instance.pNode si == pdx && Instance.sNode si == sdx |
106 | 106 |
where si = Instance.setBoth inst pdx sdx |
107 | 107 |
|
108 |
prop_Instance_shrinkMG :: Instance.Instance -> Property
|
|
109 |
prop_Instance_shrinkMG inst =
|
|
108 |
prop_shrinkMG :: Instance.Instance -> Property |
|
109 |
prop_shrinkMG inst = |
|
110 | 110 |
Instance.mem inst >= 2 * Types.unitMem ==> |
111 | 111 |
case Instance.shrinkByType inst Types.FailMem of |
112 | 112 |
Types.Ok inst' -> Instance.mem inst' == Instance.mem inst - Types.unitMem |
113 | 113 |
_ -> False |
114 | 114 |
|
115 |
prop_Instance_shrinkMF :: Instance.Instance -> Property
|
|
116 |
prop_Instance_shrinkMF inst =
|
|
115 |
prop_shrinkMF :: Instance.Instance -> Property |
|
116 |
prop_shrinkMF inst = |
|
117 | 117 |
forAll (choose (0, 2 * Types.unitMem - 1)) $ \mem -> |
118 | 118 |
let inst' = inst { Instance.mem = mem} |
119 | 119 |
in Types.isBad $ Instance.shrinkByType inst' Types.FailMem |
120 | 120 |
|
121 |
prop_Instance_shrinkCG :: Instance.Instance -> Property
|
|
122 |
prop_Instance_shrinkCG inst =
|
|
121 |
prop_shrinkCG :: Instance.Instance -> Property |
|
122 |
prop_shrinkCG inst = |
|
123 | 123 |
Instance.vcpus inst >= 2 * Types.unitCpu ==> |
124 | 124 |
case Instance.shrinkByType inst Types.FailCPU of |
125 | 125 |
Types.Ok inst' -> |
126 | 126 |
Instance.vcpus inst' == Instance.vcpus inst - Types.unitCpu |
127 | 127 |
_ -> False |
128 | 128 |
|
129 |
prop_Instance_shrinkCF :: Instance.Instance -> Property
|
|
130 |
prop_Instance_shrinkCF inst =
|
|
129 |
prop_shrinkCF :: Instance.Instance -> Property |
|
130 |
prop_shrinkCF inst = |
|
131 | 131 |
forAll (choose (0, 2 * Types.unitCpu - 1)) $ \vcpus -> |
132 | 132 |
let inst' = inst { Instance.vcpus = vcpus } |
133 | 133 |
in Types.isBad $ Instance.shrinkByType inst' Types.FailCPU |
134 | 134 |
|
135 |
prop_Instance_shrinkDG :: Instance.Instance -> Property
|
|
136 |
prop_Instance_shrinkDG inst =
|
|
135 |
prop_shrinkDG :: Instance.Instance -> Property |
|
136 |
prop_shrinkDG inst = |
|
137 | 137 |
Instance.dsk inst >= 2 * Types.unitDsk ==> |
138 | 138 |
case Instance.shrinkByType inst Types.FailDisk of |
139 | 139 |
Types.Ok inst' -> |
140 | 140 |
Instance.dsk inst' == Instance.dsk inst - Types.unitDsk |
141 | 141 |
_ -> False |
142 | 142 |
|
143 |
prop_Instance_shrinkDF :: Instance.Instance -> Property
|
|
144 |
prop_Instance_shrinkDF inst =
|
|
143 |
prop_shrinkDF :: Instance.Instance -> Property |
|
144 |
prop_shrinkDF inst = |
|
145 | 145 |
forAll (choose (0, 2 * Types.unitDsk - 1)) $ \dsk -> |
146 | 146 |
let inst' = inst { Instance.dsk = dsk } |
147 | 147 |
in Types.isBad $ Instance.shrinkByType inst' Types.FailDisk |
148 | 148 |
|
149 |
prop_Instance_setMovable :: Instance.Instance -> Bool -> Property
|
|
150 |
prop_Instance_setMovable inst m =
|
|
149 |
prop_setMovable :: Instance.Instance -> Bool -> Property |
|
150 |
prop_setMovable inst m = |
|
151 | 151 |
Instance.movable inst' ==? m |
152 | 152 |
where inst' = Instance.setMovable inst m |
153 | 153 |
|
154 | 154 |
testSuite "Instance" |
155 |
[ 'prop_Instance_creat
|
|
156 |
, 'prop_Instance_setIdx
|
|
157 |
, 'prop_Instance_setName
|
|
158 |
, 'prop_Instance_setAlias
|
|
159 |
, 'prop_Instance_setPri
|
|
160 |
, 'prop_Instance_setSec
|
|
161 |
, 'prop_Instance_setBoth
|
|
162 |
, 'prop_Instance_shrinkMG
|
|
163 |
, 'prop_Instance_shrinkMF
|
|
164 |
, 'prop_Instance_shrinkCG
|
|
165 |
, 'prop_Instance_shrinkCF
|
|
166 |
, 'prop_Instance_shrinkDG
|
|
167 |
, 'prop_Instance_shrinkDF
|
|
168 |
, 'prop_Instance_setMovable
|
|
155 |
[ 'prop_creat |
|
156 |
, 'prop_setIdx |
|
157 |
, 'prop_setName |
|
158 |
, 'prop_setAlias |
|
159 |
, 'prop_setPri |
|
160 |
, 'prop_setSec |
|
161 |
, 'prop_setBoth |
|
162 |
, 'prop_shrinkMG |
|
163 |
, 'prop_shrinkMF |
|
164 |
, 'prop_shrinkCG |
|
165 |
, 'prop_shrinkCF |
|
166 |
, 'prop_shrinkDG |
|
167 |
, 'prop_shrinkDF |
|
168 |
, 'prop_setMovable |
|
169 | 169 |
] |
Also available in: Unified diff