|
|
|
|
|
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 {} | | getName :: Gen String | | getFQDN :: Gen String | | getMaybe :: Gen a -> Gen (Maybe a) | | getFields :: Gen [String] | | newtype TagChar = TagChar {} | | 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
|
|
|
Maximum memory (1TiB, somewhat random value).
|
|
|
Maximum disk (8TiB, somewhat random value).
|
|
|
Max CPUs (1024, somewhat random value).
|
|
|
Max vcpu ratio (random value).
|
|
maxSpindleRatio :: Double | Source |
|
Max spindle ratio (random value).
|
|
|
Max nodes, used just to limit arbitrary instances for smaller
opcode definitions (e.g. list of nodes in OpTestDelay).
|
|
|
Max opcodes or jobs in a submit job and submit many jobs.
|
|
|
All disk templates (used later)
|
|
|
Null iPolicy, and by null we mean very liberal.
|
|
|
|
|
|
Helper functions
|
|
|
Simple checker for whether OpResult is fail or pass.
|
|
(==?) :: (Show a, Eq a) => a -> a -> Property | Source |
|
Checks for equality with proper annotation.
|
|
failTest :: String -> Property | Source |
|
Show a message and fail the test.
|
|
|
Update an instance to be smaller than a node.
Create an instance given its spec.
Create a small cluster by repeating a node spec.
|
|
|
Make a small cluster, both nodes and instances.
|
|
|
Checks if a node is big enough.
|
|
canBalance :: Table -> Bool -> Bool -> Bool -> Bool | 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.
|
|
|
Checks if an instance is mirrored.
|
|
|
Returns the possible change node types for a disk template.
|
|
Arbitrary instances
|
|
|
Defines a DNS name.
| Constructors | |
|
|
|
Generates a single name component.
|
|
|
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).
|
|
|
Defines a tag type.
| Constructors | |
|
|
|
All valid tag chars. This doesn't need to match _exactly_
Ganeti's own tag regex, just enough for it to be close.
|
|
|
Generates a tag
|
|
|
Generates a list of tags (correctly upper bounded).
|
|
|
Generates a random instance with maximum diskmemcpu values.
|
|
|
Generates an instance smaller than a node.
|
|
|
:: Maybe Int | Minimum node size in terms of units
| -> Maybe Int | Maximum node size (when Nothing, bounded
just by the max... constants)
| -> Gen Node | | Generas an arbitrary node based on sizing information.
|
|
|
|
Helper function to generate a sane node.
|
|
|
|
|
|
Generates an ispec bigger than the given one.
|
|
Actual tests
|
|
Utils tests
|
|
prop_Utils_if'if :: Bool -> Int -> Int -> Gen Prop | Source |
|
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.
|
|
|
:: Int | Default result
| -> [Int] | List of False values
| -> [Int] | List of True values
| -> Gen Prop | Test result
| Test basic select functionality
|
|
|
prop_Utils_select_undefd | Source |
|
:: [Int] | List of False values
| -> NonEmptyList Int | List of True values
| -> Gen Prop | Test result
| Test basic select functionality with undefined default
|
|
|
prop_Utils_select_undefv | Source |
|
:: [Int] | List of False values
| -> NonEmptyList Int | List of True values
| -> Gen Prop | Test 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
|
|
|
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 -> Bool | Source |
|
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 -> Bool | Source |
|
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] -> Property | Source |
|
|
prop_JSON_toArrayFail :: Int -> String -> Bool -> Property | Source |
|
|
testJSON :: (String, [(Args -> IO Result, String)]) | Source |
|
|
Luxi tests
|
|
|
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 |