ganeti-htoolsSource codeContentsIndex
Ganeti.HTools.QC
Contents
Constants
Helper functions
Arbitrary instances
Actual tests
Utils tests
PeerMap tests
Container tests
Instance tests
Backends
Text backend tests
Simu backend
Node tests
Cluster tests
OpCodes tests
Jobs tests
Loader tests
Types tests
CLI tests
JSON tests
Luxi tests
Ssconf tests
Description
Unittests for ganeti-htools.
Synopsis
maxMem :: Int
maxDsk :: Int
maxCpu :: Int
maxVcpuRatio :: Double
maxSpindleRatio :: Double
maxNodes :: Int
maxOpCodes :: Int
allDiskTemplates :: [DiskTemplate]
defGroup :: Group
defGroupList :: List
defGroupAssoc :: Map String Gdx
isFailure :: OpResult a -> Bool
(==?) :: (Show a, Eq a) => a -> a -> Property
failTest :: String -> Property
makeSmallCluster :: Node -> Int -> List
makeSmallEmptyCluster :: Node -> Int -> Instance -> (List, List, Instance)
isNodeBig :: Int -> Node -> Bool
canBalance :: Table -> Bool -> Bool -> Bool -> Bool
assignInstance :: List -> List -> Instance -> Idx -> Idx -> (List, List)
genUniquesList :: (Eq a, Arbitrary a) => Int -> Gen [a]
isMirrored :: Instance -> Bool
evacModeOptions :: MirrorType -> [EvacMode]
newtype DNSChar = DNSChar {
dnsGetChar :: Char
}
getName :: Gen String
getFQDN :: Gen String
getMaybe :: Gen a -> Gen (Maybe a)
getFields :: Gen [String]
newtype TagChar = TagChar {
tagGetChar :: Char
}
tagChar :: [Char]
genTag :: Gen [TagChar]
genTags :: Gen [String]
genInstanceSmallerThan :: Int -> Int -> Int -> Gen Instance
genInstanceSmallerThanNode :: Node -> Gen Instance
genNode :: Maybe Int -> Maybe Int -> Gen Node
genOnlineNode :: Gen Node
newtype SmallRatio = SmallRatio Double
genBiggerISpec :: ISpec -> Gen ISpec
prop_Utils_if'if :: Bool -> Int -> Int -> Gen Prop
prop_Utils_select :: Int -> [Int] -> [Int] -> Gen Prop
prop_Utils_select_undefd :: [Int] -> NonEmptyList Int -> Gen Prop
prop_Utils_select_undefv :: [Int] -> NonEmptyList Int -> Gen Prop
testUtils :: (String, [(Args -> IO Result, String)])
testPeerMap :: (String, [(Args -> IO Result, String)])
testContainer :: (String, [(Args -> IO Result, String)])
testInstance :: (String, [(Args -> IO Result, String)])
testText :: (String, [(Args -> IO Result, String)])
genSimuSpec :: Gen (String, Int, Int, Int, Int)
testSimu :: (String, [(Args -> IO Result, String)])
testNode :: (String, [(Args -> IO Result, String)])
canAllocOn :: List -> Int -> Instance -> Bool
testCluster :: (String, [(Args -> IO Result, String)])
testOpCodes :: (String, [(Args -> IO Result, String)])
testJobs :: (String, [(Args -> IO Result, String)])
prop_Loader_compareNameComponent_equal :: String -> Bool
prop_Loader_compareNameComponent_prefix :: NonEmptyList Char -> String -> Bool
testLoader :: (String, [(Args -> IO Result, String)])
testTypes :: (String, [(Args -> IO Result, String)])
testCLI :: (String, [(Args -> IO Result, String)])
prop_JSON_toArray :: [Int] -> Property
prop_JSON_toArrayFail :: Int -> String -> Bool -> Property
testJSON :: (String, [(Args -> IO Result, String)])
prop_Luxi_CallEncoding :: LuxiOp -> Property
testLUXI :: (String, [(Args -> IO Result, String)])
testSsconf :: (String, [(Args -> IO Result, String)])
Constants
maxMem :: IntSource
Maximum memory (1TiB, somewhat random value).
maxDsk :: IntSource
Maximum disk (8TiB, somewhat random value).
maxCpu :: IntSource
Max CPUs (1024, somewhat random value).
maxVcpuRatio :: DoubleSource
Max vcpu ratio (random value).
maxSpindleRatio :: DoubleSource
Max spindle ratio (random value).
maxNodes :: IntSource
Max nodes, used just to limit arbitrary instances for smaller opcode definitions (e.g. list of nodes in OpTestDelay).
maxOpCodes :: IntSource
Max opcodes or jobs in a submit job and submit many jobs.
allDiskTemplates :: [DiskTemplate]Source
All disk templates (used later)
defGroup :: GroupSource
Null iPolicy, and by null we mean very liberal.
defGroupList :: ListSource
defGroupAssoc :: Map String GdxSource
Helper functions
isFailure :: OpResult a -> BoolSource
Simple checker for whether OpResult is fail or pass.
(==?) :: (Show a, Eq a) => a -> a -> PropertySource
Checks for equality with proper annotation.
failTest :: String -> PropertySource
Show a message and fail the test.
makeSmallCluster :: Node -> Int -> ListSource

Update an instance to be smaller than a node.

Create an instance given its spec.

Create a small cluster by repeating a node spec.

makeSmallEmptyCluster :: Node -> Int -> Instance -> (List, List, Instance)Source
Make a small cluster, both nodes and instances.
isNodeBig :: Int -> Node -> BoolSource
Checks if a node is big enough.
canBalance :: Table -> Bool -> Bool -> Bool -> BoolSource
assignInstance :: List -> List -> Instance -> Idx -> Idx -> (List, List)Source
Assigns a new fresh instance to a cluster; this is not allocation, so no resource checks are done.
genUniquesList :: (Eq a, Arbitrary a) => Int -> Gen [a]Source
Generates a list of a given size with non-duplicate elements.
isMirrored :: Instance -> BoolSource
Checks if an instance is mirrored.
evacModeOptions :: MirrorType -> [EvacMode]Source
Returns the possible change node types for a disk template.
Arbitrary instances
newtype DNSChar Source
Defines a DNS name.
Constructors
DNSChar
dnsGetChar :: Char
getName :: Gen StringSource
Generates a single name component.
getFQDN :: Gen StringSource
Generates an entire FQDN.
getMaybe :: Gen a -> Gen (Maybe a)Source
Combinator that generates a Maybe using a sub-combinator.
getFields :: Gen [String]Source
Generates a fields list. This uses the same character set as a DNS name (just for simplicity).
newtype TagChar Source
Defines a tag type.
Constructors
TagChar
tagGetChar :: Char
tagChar :: [Char]Source
All valid tag chars. This doesn't need to match _exactly_ Ganeti's own tag regex, just enough for it to be close.
genTag :: Gen [TagChar]Source
Generates a tag
genTags :: Gen [String]Source
Generates a list of tags (correctly upper bounded).
genInstanceSmallerThan :: Int -> Int -> Int -> Gen InstanceSource
Generates a random instance with maximum diskmemcpu values.
genInstanceSmallerThanNode :: Node -> Gen InstanceSource
Generates an instance smaller than a node.
genNodeSource
:: Maybe IntMinimum node size in terms of units
-> Maybe IntMaximum node size (when Nothing, bounded just by the max... constants)
-> Gen Node
Generas an arbitrary node based on sizing information.
genOnlineNode :: Gen NodeSource
Helper function to generate a sane node.
newtype SmallRatio Source
Constructors
SmallRatio Double
genBiggerISpec :: ISpec -> Gen ISpecSource
Generates an ispec bigger than the given one.
Actual tests
Utils tests
prop_Utils_if'if :: Bool -> Int -> Int -> Gen PropSource

Helper to generate a small string that doesn't contain commas.

If the list is not just an empty element, and if the elements do not contain commas, then join+split should be idempotent.

Split and join should always be idempotent.

fromObjWithDefault, we test using the Maybe monad and an integer value.

Test that functional if' behaves like the syntactic sugar if.

prop_Utils_selectSource
:: IntDefault result
-> [Int]List of False values
-> [Int]List of True values
-> Gen PropTest result
Test basic select functionality
prop_Utils_select_undefdSource
:: [Int]List of False values
-> NonEmptyList IntList of True values
-> Gen PropTest result
Test basic select functionality with undefined default
prop_Utils_select_undefvSource
:: [Int]List of False values
-> NonEmptyList IntList of True values
-> Gen PropTest result
Test basic select functionality with undefined list values
testUtils :: (String, [(Args -> IO Result, String)])Source
Test list for the Utils module.
PeerMap tests
testPeerMap :: (String, [(Args -> IO Result, String)])Source

Make sure add is idempotent.

Make sure remove is idempotent.

Make sure a missing item returns 0.

Make sure an added item is found.

Manual check that maxElem returns the maximum indeed, or 0 for null.

List of tests for the PeerMap module.

Container tests
testContainer :: (String, [(Args -> IO Result, String)])Source
We test that in a cluster, given a random node, we can find it by its name and alias, as long as all names and aliases are unique, and that we fail to find a non-existing name.
Instance tests
testInstance :: (String, [(Args -> IO Result, String)])Source
Backends
Text backend tests
testText :: (String, [(Args -> IO Result, String)])Source
This property, while being in the text tests, does more than just test end-to-end the serialisation and loading back workflow; it also tests the Loader.mergeData and the actuall Cluster.iterateAlloc (for well-behaving w.r.t. instance allocations, not for the business logic). As such, it's a quite complex and slow test, and that's the reason we restrict it to small cluster sizes.
Simu backend
genSimuSpec :: Gen (String, Int, Int, Int, Int)Source
Generates a tuple of specs for simulation.
testSimu :: (String, [(Args -> IO Result, String)])Source
Checks that given a set of corrects specs, we can load them successfully, and that at high-level the values look right.
Node tests
testNode :: (String, [(Args -> IO Result, String)])Source

Check that an instance add with too high memory or disk will be rejected.

Check that adding a primary instance with too much disk fails with type FailDisk.

Check that adding a primary instance with too many VCPUs fails with type FailCPU.

Check that an instance add with too high memory or disk will be rejected.

Check that an offline instance with reasonable disk size but extra mem/cpu can always be added.

Check that an offline instance with reasonable disk size but extra mem/cpu can always be added.

Checks for memory reservation changes.

Check mdsk setting.

Cluster tests
canAllocOn :: List -> Int -> Instance -> BoolSource

Check that the cluster score is close to zero for a homogeneous cluster.

Check that cluster stats are sane.

Check that one instance is allocated correctly, without rebalances needed.

Checks that on a 2-5 node cluster, we can allocate a random instance spec via tiered allocation (whatever the original instance spec), on either one or two nodes. Furthermore, we test that computed allocation statistics are correct.

Helper function to create a cluster with the given range of nodes and allocate an instance on it.

Checks that on a 4-8 node cluster, once we allocate an instance, we can also relocate it.

Helper property checker for the result of a nodeEvac or changeGroup operation.

Checks that on a 4-8 node cluster, once we allocate an instance, we can also node-evacuate it.

Checks that on a 4-8 node cluster with two node groups, once we allocate an instance on the first node group, we can also change its group.

Check that allocating multiple instances on a cluster, then adding an empty node, results in a valid rebalance.

Checks consistency.

For now, we only test that we don't lose instances during the split.

Helper function to check if we can allocate an instance on a given node list.

testCluster :: (String, [(Args -> IO Result, String)])Source
Checks that allocation obeys minimum and maximum instance policies. The unittest generates a random node, duplicates it count times, and generates a random instance that can be allocated on this mini-cluster; it then checks that after applying a policy that the instance doesn't fits, the allocation fails.
OpCodes tests
testOpCodes :: (String, [(Args -> IO Result, String)])Source
Check that opcode serialization is idempotent.
Jobs tests
testJobs :: (String, [(Args -> IO Result, String)])Source
Check that (queued) job/opcode status serialization is idempotent.
Loader tests
prop_Loader_compareNameComponent_equal :: String -> BoolSource

Checks that the number of primary instances recorded on the nodes is zero.

Check that compareNameComponent on equal strings works.

prop_Loader_compareNameComponent_prefix :: NonEmptyList Char -> String -> BoolSource
Check that compareNameComponent on prefix strings works.
testLoader :: (String, [(Args -> IO Result, String)])Source
Types tests
testTypes :: (String, [(Args -> IO Result, String)])Source
CLI tests
testCLI :: (String, [(Args -> IO Result, String)])Source

Test correct parsing.

Test parsing failure due to wrong section count.

Test parseYesNo.

Helper to check for correct parsing of string arg.

Test a few string arguments.

Helper to test that a given option is accepted OK with quick exit.

Test that all binaries support some common options. There is nothing actually random about this test...

JSON tests
prop_JSON_toArray :: [Int] -> PropertySource
prop_JSON_toArrayFail :: Int -> String -> Bool -> PropertySource
testJSON :: (String, [(Args -> IO Result, String)])Source
Luxi tests
prop_Luxi_CallEncoding :: LuxiOp -> PropertySource
Simple check that encoding/decoding of LuxiOp works.
testLUXI :: (String, [(Args -> IO Result, String)])Source
Ssconf tests
testSsconf :: (String, [(Args -> IO Result, String)])Source
Produced by Haddock version 2.6.0