ganeti
Safe HaskellNone

Test.Ganeti.OpCodes

Description

Unittests for ganeti-htools.

Synopsis

Arbitrary instances

Helper functions

emptyJSObject :: JSObject JSValue Source #

Empty JSObject.

emptyMUD :: Gen (Maybe (JSObject JSValue)) Source #

Empty maybe unchecked dictionary.

genEmptyContainer :: Ord a => Gen (GenericContainer a b) Source #

Generates an empty container.

genDiskIndices :: Gen [DiskIndex] Source #

Generates list of disk indices.

genNodeNames :: Gen [String] Source #

Generates a list of node names.

genNodeNamesNE :: Gen [NonEmptyString] Source #

Generates a list of node names in non-empty string type.

genNodeNameNE :: Gen NonEmptyString Source #

Gets a node name in non-empty type.

genNameNE :: Gen NonEmptyString Source #

Gets a name (non-fqdn) in non-empty type.

genNamesNE :: Gen [NonEmptyString] Source #

Gets a list of names (non-fqdn) in non-empty type.

genFieldsNE :: Gen [NonEmptyString] Source #

Returns a list of non-empty fields.

genMacPrefix :: Gen NonEmptyString Source #

Generate a 3-byte MAC prefix.

arbitraryPrivateJSObj :: Gen (JSObject (Private JSValue)) Source #

JSObject of arbitrary data.

Since JSValue does not implement Arbitrary, I'll simply generate (String, String) objects.

arbitrarySecretJSObj :: Gen (JSObject (Secret JSValue)) Source #

JSObject of arbitrary secret data.

isJsonError :: Result a -> Bool Source #

Small helper to check for a failed JSON deserialisation

Test cases

prop_serialization :: OpCode -> Property Source #

Check that opcode serialization is idempotent.

case_AllDefined :: Assertion Source #

Check that Python and Haskell defined the same opcode list.

case_py_compat_types :: Assertion Source #

Custom HUnit test case that forks a Python process and checks correspondence between Haskell-generated OpCodes and their Python decoded, validated and re-encoded version.

Note that we have a strange beast here: since launching Python is expensive, we don't do this via a usual QuickProperty, since that's slow (I've tested it, and it's indeed quite slow). Rather, we use a single HUnit assertion, and in it we manually use QuickCheck to generate 500 opcodes times the number of defined opcodes, which then we pass in bulk to Python. The drawbacks to this method are two fold: we cannot control the number of generated opcodes, since HUnit assertions don't get access to the test options, and for the same reason we can't run a repeatable seed. We should probably find a better way to do this, for example by having a separately-launched Python process (if not running the tests would be skipped).

case_py_compat_fields :: Assertion Source #

Custom HUnit test case that forks a Python process and checks correspondence between Haskell OpCodes fields and their Python equivalent.

prop_setOpComment :: MetaOpCode -> String -> Property Source #

Checks that setOpComment works correctly.

prop_mkDiskIndex_fail :: Positive Int -> Property Source #

Tests wrong (negative) disk index.

case_readRecreateDisks_fail :: Assertion Source #

Tests a few invalid readRecreateDisks cases.

case_readDdmOldChanges_fail :: Assertion Source #

Tests a few invalid readDdmOldChanges cases.

case_readExportTarget_fail :: Assertion Source #

Tests a few invalid readExportTarget cases.

Orphan instances

Arbitrary ReplaceDisksMode # 
Instance details

Arbitrary DiskIndex # 
Instance details

Arbitrary DiskAccess # 
Instance details

Arbitrary INicParams # 
Instance details

Arbitrary ExportTarget # 
Instance details

Arbitrary DdmOldChanges # 
Instance details

Arbitrary RecreateDisksInfo # 
Instance details

Arbitrary IDiskParams # 
Instance details

Arbitrary OpCode # 
Instance details

Methods

arbitrary :: Gen OpCode

shrink :: OpCode -> [OpCode]

Arbitrary MetaOpCode #

Arbitrary instance for MetaOpCode, defined here due to TH ordering.

Instance details

Arbitrary CommonOpParams # 
Instance details

Arbitrary a => Arbitrary (SetParamsMods a) # 
Instance details