Safe Haskell | None |
---|
Test.Ganeti.Objects
Description
Unittests for ganeti-htools.
Synopsis
- genInstWithNets :: [String] -> Gen Instance
- genInst :: Gen Instance
- enhanceInstWithNets :: Instance -> [String] -> Gen Instance
- genDiskWithChildren :: Int -> Gen Disk
- genDisk :: Gen Disk
- genValidNetwork :: Gen Network
- genBitString :: Int -> Gen AddressPool
- genBitStringMaxLen :: Int -> Gen AddressPool
- genEmptyCluster :: Int -> Gen ConfigData
- genConfigDataWithNetworks :: ConfigData -> Gen ConfigData
- prop_fillDict :: [(Int, Int)] -> [(Int, Int)] -> Property
- prop_LogicalVolume_serialisation :: LogicalVolume -> Property
- prop_LogicalVolume_deserialisationFail :: Property
- prop_Disk_serialisation :: Disk -> Property
- prop_Disk_array_serialisation :: Disk -> Property
- prop_Node_serialisation :: Node -> Property
- prop_Inst_serialisation :: Instance -> Property
- prop_AddressPool_serialisation :: AddressPool -> Property
- prop_Network_serialisation :: Network -> Property
- prop_FilterAction_serialisation :: FilterAction -> Property
- prop_FilterPredicate_serialisation :: FilterPredicate -> Property
- prop_Config_serialisation :: Property
- casePyCompatNetworks :: Assertion
- getNetworkProperties :: Network -> (Int, Int, Network)
- casePyCompatNodegroups :: Assertion
- genNodeGroup :: Gen NodeGroup
- prop_ip4AddressAsNum :: Ip4Address -> Property
- prop_ip4AddressToNumber :: Word32 -> Property
- caseNextIp4Address :: Assertion
- casePyCompatInstances :: Assertion
- mkLIDPlain :: String -> String -> DiskLogicalId
- caseIncludeLogicalIdPlain :: Assertion
- caseIncludeLogicalIdDrbd :: Assertion
- caseNotIncludeLogicalIdPlain :: Assertion
- testObjects :: Test
Arbitrary instances
genInstWithNets :: [String] -> Gen Instance Source #
Generates an instance that is connected to the given networks and possibly some other networks
enhanceInstWithNets :: Instance -> [String] -> Gen Instance Source #
Enhances a given instance with network information, by connecting it to the given networks and possibly some other networks
genDiskWithChildren :: Int -> Gen Disk Source #
genValidNetwork :: Gen Network Source #
Generates a network instance with minimum netmasks of /24. Generating bigger networks slows down the tests, because long bit strings are generated for the reservations.
genBitString :: Int -> Gen AddressPool Source #
Generate an arbitrary string consisting of '0' and '1' of the given length.
genBitStringMaxLen :: Int -> Gen AddressPool Source #
Generate an arbitrary string consisting of '0' and '1' of the maximum given length.
genEmptyCluster :: Int -> Gen ConfigData Source #
Generator for config data with an empty cluster (no instances), with N defined nodes.
genConfigDataWithNetworks :: ConfigData -> Gen ConfigData Source #
FIXME: make an even simpler base version of creating a cluster.
Generates config data with a couple of networks.
Test properties
prop_fillDict :: [(Int, Int)] -> [(Int, Int)] -> Property Source #
Tests that fillDict behaves correctly
prop_LogicalVolume_serialisation :: LogicalVolume -> Property Source #
prop_LogicalVolume_deserialisationFail :: Property Source #
prop_Disk_serialisation :: Disk -> Property Source #
Test that the serialisation of DiskLogicalId
, which is
implemented manually, is idempotent. Since we don't have a
standalone JSON instance for DiskLogicalId (it's a data type that
expands over two fields in a JSObject), we test this by actially
testing entire Disk serialisations. So this tests two things at
once, basically.
prop_Disk_array_serialisation :: Disk -> Property Source #
prop_Node_serialisation :: Node -> Property Source #
Check that node serialisation is idempotent.
prop_Inst_serialisation :: Instance -> Property Source #
Check that instance serialisation is idempotent.
prop_AddressPool_serialisation :: AddressPool -> Property Source #
Check that address pool serialisation is idempotent.
prop_Network_serialisation :: Network -> Property Source #
Check that network serialisation is idempotent.
prop_FilterAction_serialisation :: FilterAction -> Property Source #
Check that filter action serialisation is idempotent.
prop_FilterPredicate_serialisation :: FilterPredicate -> Property Source #
Check that filter predicate serialisation is idempotent.
prop_Config_serialisation :: Property Source #
Check config serialisation.
casePyCompatNetworks :: Assertion Source #
Custom HUnit test to check the correspondence between Haskell-generated networks and their Python decoded, validated and re-encoded version. For the technical background of this unit test, check the documentation of "case_py_compat_types" of testhsTestGanetiOpcodes.hs
getNetworkProperties :: Network -> (Int, Int, Network) Source #
Creates a tuple of the given network combined with some of its properties to be compared against the same properties generated by the python code.
casePyCompatNodegroups :: Assertion Source #
Tests the compatibility between Haskell-serialized node groups and their python-decoded and encoded version.
genNodeGroup :: Gen NodeGroup Source #
Generates a node group with up to 3 networks. | FIXME: This generates still somewhat completely random data, without normal validation rules.
prop_ip4AddressAsNum :: Ip4Address -> Property Source #
Tests conversions of ip addresses from/to numbers.
prop_ip4AddressToNumber :: Word32 -> Property Source #
Tests that the number produced by ip4AddressToNumber
has the correct
order of bytes.
caseNextIp4Address :: Assertion Source #
Tests a few simple cases of IPv4 next address.
casePyCompatInstances :: Assertion Source #
Tests the compatibility between Haskell-serialized instances and their python-decoded and encoded version. Note: this can be enhanced with logical validations on the decoded objects
mkLIDPlain :: String -> String -> DiskLogicalId Source #
A helper function for creating LIDPlain
values.
caseIncludeLogicalIdPlain :: Assertion Source #
Tests that the logical ID is correctly found in a plain disk
caseIncludeLogicalIdDrbd :: Assertion Source #
Tests that the logical ID is correctly found in a DRBD disk
caseNotIncludeLogicalIdPlain :: Assertion Source #
Tests that the logical ID is correctly NOT found in a plain disk
testObjects :: Test Source #
Orphan instances
IsString Ip4Address # | IsString instance for |
Methods fromString :: String -> Ip4Address | |
Arbitrary ByteString # | |
Arbitrary DiskMode # | |
Arbitrary BlockDriver # | |
Arbitrary AdminState # | |
Arbitrary AdminStateSource # | |
Arbitrary SshKeyType # | |
Arbitrary OsParams # | |
Arbitrary PartialNicParams # | |
Arbitrary FilledNicParams # | |
Arbitrary PartialNic # | |
Arbitrary PartialBeParams # | |
Arbitrary FilledBeParams # | |
Arbitrary Instance # | |
Arbitrary ForthcomingInstanceData # | |
Methods arbitrary :: Gen ForthcomingInstanceData shrink :: ForthcomingInstanceData -> [ForthcomingInstanceData] | |
Arbitrary RealInstanceData # | |
Arbitrary DiskLogicalId # | |
Arbitrary LogicalVolume # | |
Arbitrary Disk # |
|
Arbitrary AddressPool # | |
Arbitrary Ip4Network # | |
Arbitrary Ip4Address # | |
Arbitrary Network # | |
Arbitrary PartialISpecParams # | FIXME: This generates completely random data, without normal validation rules. |
Arbitrary FilledISpecParams # | |
Arbitrary MinMaxISpecs # | |
Arbitrary PartialIPolicy # | FIXME: This generates completely random data, without normal validation rules. |
Arbitrary FilledIPolicy # | |
Arbitrary PartialNDParams # | |
Arbitrary FilledNDParams # | |
Arbitrary GroupDiskParams # | No real arbitrary instance for |
Arbitrary Node # | |
Arbitrary FilterPredicate # | |
Arbitrary FilterAction # | |
Arbitrary NodeGroup # | |
Arbitrary FilterRule # | |
Arbitrary IpFamily # | |
Arbitrary IAllocatorParams # | |
Arbitrary ClusterNicParams # | |
Arbitrary ClusterOsParamsPrivate # | |
Methods arbitrary :: Gen ClusterOsParamsPrivate shrink :: ClusterOsParamsPrivate -> [ClusterOsParamsPrivate] | |
Arbitrary ClusterOsParams # | |
Arbitrary ClusterBeParams # | |
Arbitrary OsHvParams # | No real arbitrary instance for |
Arbitrary ClusterHvParams # | No real arbitrary instance for |
Arbitrary Cluster # | |
Arbitrary ConfigData # | |
Arbitrary (Container DataCollectorConfig) # | |
Methods arbitrary :: Gen (Container DataCollectorConfig) shrink :: Container DataCollectorConfig -> [Container DataCollectorConfig] | |
Arbitrary a => Arbitrary (Private a) # | |