Skip to content
Snippets Groups Projects
Commit 3cbd5808 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix Haskell compatibility tests with disabled file storage


When file storage is disabled at ./configure time, we shouldn't pass
opcodes containing DTFile/DTSharedFile/StorageFile to Python for
validation, as they will fail.

This patch implements this by simply tweaking the Arbitrary instances
for DiskTemplate and StorageType (which IMHO is a nice and clean
way!), and also fixing the generation of arbitrary IPolicies to use
the correct 'allDiskTemplates' list (otherwise we'd loop forever
trying to generate a list of all templates).

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 3c87d614
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
{-
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -46,7 +46,7 @@ import Data.List (sort)
import Test.Ganeti.TestHelper
import Test.Ganeti.TestCommon
import Test.Ganeti.TestHTools
import Test.Ganeti.Types ()
import Test.Ganeti.Types (allDiskTemplates)
import Ganeti.BasicTypes
import qualified Ganeti.Constants as C
......@@ -56,10 +56,6 @@ import qualified Ganeti.HTools.Types as Types
-- * Helpers
-- | All disk templates (used later)
allDiskTemplates :: [Types.DiskTemplate]
allDiskTemplates = [minBound..maxBound]
-- * Arbitrary instance
$(genArbitrary ''Types.FailMode)
......
......@@ -30,13 +30,14 @@ module Test.Ganeti.Types
( testTypes
, AllocPolicy(..)
, DiskTemplate(..)
, allDiskTemplates
, InstanceStatus(..)
, NonEmpty(..)
, Hypervisor(..)
, JobId(..)
) where
import Data.List (sort)
import Data.List (delete, sort)
import Test.QuickCheck as QuickCheck hiding (Result)
import Test.HUnit
import qualified Text.JSON as J
......@@ -78,7 +79,22 @@ instance (Arbitrary a) => Arbitrary (Types.NonEmpty a) where
$(genArbitrary ''AllocPolicy)
$(genArbitrary ''DiskTemplate)
-- | Valid disk templates (depending on configure options).
allDiskTemplates :: [DiskTemplate]
allDiskTemplates =
let all_vals = [minBound..maxBound]::[DiskTemplate]
sel1 = if C.enableFileStorage
then all_vals
else delete DTFile all_vals
sel2 = if C.enableSharedFileStorage
then sel1
else delete DTSharedFile sel1
in sel2
-- | Custom 'Arbitrary' instance for 'DiskTemplate', which needs to
-- handle the case of file storage being disabled at configure time.
instance Arbitrary DiskTemplate where
arbitrary = elements allDiskTemplates
$(genArbitrary ''InstanceStatus)
......@@ -96,7 +112,18 @@ $(genArbitrary ''Hypervisor)
$(genArbitrary ''OobCommand)
$(genArbitrary ''StorageType)
-- | Valid storage types.
allStorageTypes :: [StorageType]
allStorageTypes =
let all_vals = [minBound..maxBound]::[StorageType]
in if C.enableFileStorage
then all_vals
else delete StorageFile all_vals
-- | Custom 'Arbitrary' instance for 'StorageType', which needs to
-- handle the case of file storage being disabled at configure time.
instance Arbitrary StorageType where
arbitrary = elements allStorageTypes
$(genArbitrary ''NodeEvacMode)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment