module Test.Ganeti.Storage.Lvm.LVParser (testStorage_Lvm_LVParser) where
import Test.QuickCheck as QuickCheck hiding (Result)
import Test.HUnit
import Test.Ganeti.TestHelper
import Test.Ganeti.TestCommon
import Control.Applicative ((<$>), (<*>))
import Data.List (intercalate)
import Ganeti.Storage.Lvm.LVParser
import Ganeti.Storage.Lvm.Types
case_lvs_lv :: Assertion
case_lvs_lv = testParser lvParser "lvs_lv.txt"
[ LVInfo "nhasjL-cnZi-uqLS-WRLj-tkXI-nvCB-n0o2lj"
"df9ff3f6-a833-48ff-8bd5-bff2eaeab759.disk0_data" "-wi-ao" (negate 1)
(negate 1) 253 0 1073741824 1
"originstname+instance1.example.com" ""
"uZgXit-eiRr-vRqe-xpEo-e9nU-mTuR-9nfVIU" "xenvg" "linear" 0 0 1073741824
"" "/dev/sda5:0-15" "/dev/sda5(0)" Nothing
, LVInfo "5fW5mE-SBSs-GSU0-KZDg-hnwb-sZOC-zZt736"
"df9ff3f6-a833-48ff-8bd5-bff2eaeab759.disk0_meta" "-wi-ao" (negate 1)
(negate 1) 253 1 134217728 1
"originstname+instance1.example.com" ""
"uZgXit-eiRr-vRqe-xpEo-e9nU-mTuR-9nfVIU" "xenvg" "linear" 0 0 134217728 ""
"/dev/sda5:16-17" "/dev/sda5(16)" Nothing
]
serializeLVInfo :: LVInfo -> String
serializeLVInfo l = intercalate ";"
[ lviUuid l
, lviName l
, lviAttr l
, show $ lviMajor l
, show $ lviMinor l
, show $ lviKernelMajor l
, show $ lviKernelMinor l
, show (lviSize l) ++ "B"
, show $ lviSegCount l
, lviTags l
, lviModules l
, lviVgUuid l
, lviVgName l
, lviSegtype l
, show (lviSegStart l) ++ "B"
, show $ lviSegStartPe l
, show (lviSegSize l) ++ "B"
, lviSegTags l
, lviSegPeRanges l
, lviDevices l
] ++ "\n"
serializeLVInfos :: [LVInfo] -> String
serializeLVInfos = concatMap serializeLVInfo
instance Arbitrary LVInfo where
arbitrary =
LVInfo
<$> genUUID
<*> genName
<*> genName
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> genNonNegative
<*> arbitrary
<*> genName
<*> genName
<*> genUUID
<*> genName
<*> genName
<*> genNonNegative
<*> arbitrary
<*> genNonNegative
<*> genName
<*> genName
<*> genName
<*> return Nothing
prop_parse_lvs_lv :: [LVInfo] -> Property
prop_parse_lvs_lv expected =
genPropParser lvParser (serializeLVInfos expected) expected
testSuite "Storage/Lvm/LVParser"
[ 'case_lvs_lv,
'prop_parse_lvs_lv
]