Revision 2e0bb81d
b/htest/Test/Ganeti/HTools/CLI.hs | ||
---|---|---|
56 | 56 |
let str = intercalate "," $ map show (values::[Int]) |
57 | 57 |
in case CLI.parseISpecString descr str of |
58 | 58 |
Types.Ok v -> failTest $ "Expected failure, got " ++ show v |
59 |
_ -> property True
|
|
59 |
_ -> passTest
|
|
60 | 60 |
|
61 | 61 |
-- | Test parseYesNo. |
62 | 62 |
prop_parseYesNo :: Bool -> Bool -> [Char] -> Property |
... | ... | |
99 | 99 |
checkEarlyExit :: String -> [CLI.OptType] -> String -> Property |
100 | 100 |
checkEarlyExit name options param = |
101 | 101 |
case CLI.parseOptsInner [param] name options of |
102 |
Left (code, _) -> if code == 0 |
|
103 |
then property True |
|
104 |
else failTest $ "Program " ++ name ++ |
|
105 |
" returns invalid code " ++ show code ++ |
|
106 |
" for option " ++ param |
|
102 |
Left (code, _) -> |
|
103 |
printTestCase ("Program " ++ name ++ |
|
104 |
" returns invalid code " ++ show code ++ |
|
105 |
" for option " ++ param) (code == 0) |
|
107 | 106 |
_ -> failTest $ "Program " ++ name ++ " doesn't consider option " ++ |
108 | 107 |
param ++ " as early exit one" |
109 | 108 |
|
b/htest/Test/Ganeti/HTools/Cluster.hs | ||
---|---|---|
206 | 206 |
[(if Instance.diskTemplate inst' == Types.DTDrbd8 |
207 | 207 |
then Instance.sNode |
208 | 208 |
else Instance.pNode) inst'] of |
209 |
Types.Ok _ -> property True
|
|
209 |
Types.Ok _ -> passTest
|
|
210 | 210 |
Types.Bad msg -> failTest $ "Failed to relocate: " ++ msg |
211 | 211 |
|
212 | 212 |
-- | Helper property checker for the result of a nodeEvac or |
b/htest/Test/Ganeti/HTools/Node.hs | ||
---|---|---|
154 | 154 |
let inst' = setInstanceSmallerThanNode node inst |
155 | 155 |
inst'' = inst' { Instance.vcpus = Node.availCpu node + extra } |
156 | 156 |
in case Node.addPri node inst'' of |
157 |
Types.OpFail Types.FailCPU -> property True
|
|
157 |
Types.OpFail Types.FailCPU -> passTest
|
|
158 | 158 |
v -> failTest $ "Expected OpFail FailCPU, but got " ++ show v |
159 | 159 |
|
160 | 160 |
-- | Check that an instance add with too high memory or disk will be |
... | ... | |
177 | 177 |
, Instance.mem = Node.availMem node + extra_mem |
178 | 178 |
, Instance.vcpus = Node.availCpu node + extra_cpu } |
179 | 179 |
in case Node.addPri node inst' of |
180 |
Types.OpGood _ -> property True
|
|
180 |
Types.OpGood _ -> passTest
|
|
181 | 181 |
v -> failTest $ "Expected OpGood, but got: " ++ show v |
182 | 182 |
|
183 | 183 |
-- | Check that an offline instance with reasonable disk size but |
... | ... | |
192 | 192 |
, Instance.vcpus = Node.availCpu node + extra_cpu |
193 | 193 |
, Instance.diskTemplate = Types.DTDrbd8 } |
194 | 194 |
in case Node.addSec node inst' pdx of |
195 |
Types.OpGood _ -> property True
|
|
195 |
Types.OpGood _ -> passTest
|
|
196 | 196 |
v -> failTest $ "Expected OpGood/OpGood, but got: " ++ show v |
197 | 197 |
|
198 | 198 |
-- | Checks for memory reservation changes. |
b/htest/Test/Ganeti/JSON.hs | ||
---|---|---|
50 | 50 |
-- poor man's instance Arbitrary JSValue |
51 | 51 |
forAll (elements [J.showJSON i, J.showJSON s, J.showJSON b]) $ \item -> |
52 | 52 |
case JSON.toArray item of |
53 |
BasicTypes.Bad _ -> property True
|
|
53 |
BasicTypes.Bad _ -> passTest
|
|
54 | 54 |
BasicTypes.Ok result -> failTest $ "Unexpected parse, got " ++ show result |
55 | 55 |
|
56 | 56 |
testSuite "JSON" |
b/htest/Test/Ganeti/TestCommon.hs | ||
---|---|---|
81 | 81 |
failTest :: String -> Property |
82 | 82 |
failTest msg = printTestCase msg False |
83 | 83 |
|
84 |
-- | A 'True' property. |
|
85 |
passTest :: Property |
|
86 |
passTest = property True |
|
87 |
|
|
84 | 88 |
-- | Return the python binary to use. If the PYTHON environment |
85 | 89 |
-- variable is defined, use its value, otherwise use just \"python\". |
86 | 90 |
pythonCmd :: IO String |
Also available in: Unified diff