Revision c14ba680 test/hs/Test/Ganeti/Rpc.hs
b/test/hs/Test/Ganeti/Rpc.hs | ||
---|---|---|
44 | 44 |
import qualified Ganeti.JSON as JSON |
45 | 45 |
import Ganeti.Types |
46 | 46 |
|
47 |
instance Arbitrary Rpc.RpcCallAllInstancesInfo where |
|
48 |
arbitrary = Rpc.RpcCallAllInstancesInfo <$> arbitrary |
|
49 |
|
|
50 |
instance Arbitrary Rpc.RpcCallInstanceList where |
|
51 |
arbitrary = Rpc.RpcCallInstanceList <$> arbitrary |
|
52 |
|
|
53 |
instance Arbitrary Rpc.RpcCallNodeInfo where |
|
54 |
arbitrary = Rpc.RpcCallNodeInfo <$> genStorageUnitMap <*> genHvSpecs |
|
55 |
|
|
56 | 47 |
genStorageUnit :: Gen StorageUnit |
57 | 48 |
genStorageUnit = do |
58 | 49 |
storage_type <- arbitrary |
... | ... | |
72 | 63 |
storage_units_list <- vectorOf num_nodes genStorageUnits |
73 | 64 |
return $ Map.fromList (zip node_uuids storage_units_list) |
74 | 65 |
|
66 |
-- FIXME: Generate more interesting hvparams |
|
67 |
-- | Generate Hvparams |
|
68 |
genHvParams :: Gen Objects.HvParams |
|
69 |
genHvParams = return $ JSON.GenericContainer Map.empty |
|
70 |
|
|
75 | 71 |
-- | Generate hypervisor specifications to be used for the NodeInfo call |
76 |
genHvSpecs :: Gen [ (Types.Hypervisor, Objects.HvParams) ]
|
|
72 |
genHvSpecs :: Gen [(Types.Hypervisor, Objects.HvParams)]
|
|
77 | 73 |
genHvSpecs = do |
78 | 74 |
numhv <- choose (0, 5) |
79 | 75 |
hvs <- vectorOf numhv arbitrary |
... | ... | |
81 | 77 |
let specs = zip hvs hvparams |
82 | 78 |
return specs |
83 | 79 |
|
84 |
-- FIXME: Generate more interesting hvparams |
|
85 |
-- | Generate Hvparams |
|
86 |
genHvParams :: Gen Objects.HvParams |
|
87 |
genHvParams = return $ JSON.GenericContainer Map.empty |
|
80 |
instance Arbitrary Rpc.RpcCallAllInstancesInfo where |
|
81 |
arbitrary = Rpc.RpcCallAllInstancesInfo <$> genHvSpecs |
|
82 |
|
|
83 |
instance Arbitrary Rpc.RpcCallInstanceList where |
|
84 |
arbitrary = Rpc.RpcCallInstanceList <$> arbitrary |
|
85 |
|
|
86 |
instance Arbitrary Rpc.RpcCallNodeInfo where |
|
87 |
arbitrary = Rpc.RpcCallNodeInfo <$> genStorageUnitMap <*> genHvSpecs |
|
88 | 88 |
|
89 | 89 |
-- | Monadic check that, for an offline node and a call that does not |
90 | 90 |
-- offline nodes, we get a OfflineNodeError response. |
Also available in: Unified diff