htest.hs 5.53 KB
Newer Older
1
{-| Unittest runner for ganeti-htools.
2 3 4

-}

5 6
{-

7
Copyright (C) 2009, 2011, 2012, 2013 Google Inc.
Klaus Aehlig's avatar
Klaus Aehlig committed
8
All rights reserved.
9

Klaus Aehlig's avatar
Klaus Aehlig committed
10 11 12
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
13

Klaus Aehlig's avatar
Klaus Aehlig committed
14 15
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
16

Klaus Aehlig's avatar
Klaus Aehlig committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 33 34

-}

35 36
module Main(main) where

37 38
import Data.Monoid (mappend)
import Test.Framework
39
import System.Environment (getArgs)
Iustin Pop's avatar
Iustin Pop committed
40
import System.Log.Logger
41

42
import Test.AutoConf
43
import Test.Ganeti.TestImports ()
44
import Test.Ganeti.Attoparsec
45
import Test.Ganeti.BasicTypes
Iustin Pop's avatar
Iustin Pop committed
46
import Test.Ganeti.Common
47
import Test.Ganeti.Constants
48
import Test.Ganeti.Confd.Utils
49
import Test.Ganeti.Confd.Types
Iustin Pop's avatar
Iustin Pop committed
50
import Test.Ganeti.Daemon
51
import Test.Ganeti.Errors
52
import Test.Ganeti.HTools.Backend.MonD
53 54
import Test.Ganeti.HTools.Backend.Simu
import Test.Ganeti.HTools.Backend.Text
55 56 57
import Test.Ganeti.HTools.CLI
import Test.Ganeti.HTools.Cluster
import Test.Ganeti.HTools.Container
Guido Trotter's avatar
Guido Trotter committed
58
import Test.Ganeti.HTools.Graph
59
import Test.Ganeti.HTools.Instance
60
import Test.Ganeti.HTools.Loader
61 62 63
import Test.Ganeti.HTools.Node
import Test.Ganeti.HTools.PeerMap
import Test.Ganeti.HTools.Types
64
import Test.Ganeti.Hypervisor.Xen.XmParser
65
import Test.Ganeti.JSON
66
import Test.Ganeti.Jobs
67
import Test.Ganeti.JQueue
68
import Test.Ganeti.JQScheduler
Jose A. Lopes's avatar
Jose A. Lopes committed
69
import Test.Ganeti.Kvmd
70
import Test.Ganeti.Locking.Allocation
71
import Test.Ganeti.Locking.Locks
72
import Test.Ganeti.Locking.Waiting
73
import Test.Ganeti.Luxi
74
import Test.Ganeti.Network
Iustin Pop's avatar
Iustin Pop committed
75
import Test.Ganeti.Objects
76
import Test.Ganeti.Objects.BitArray
77
import Test.Ganeti.OpCodes
78
import Test.Ganeti.Query.Aliases
Iustin Pop's avatar
Iustin Pop committed
79
import Test.Ganeti.Query.Filter
80
import Test.Ganeti.Query.Instance
81
import Test.Ganeti.Query.Language
82
import Test.Ganeti.Query.Network
83
import Test.Ganeti.Query.Query
Iustin Pop's avatar
Iustin Pop committed
84
import Test.Ganeti.Rpc
85
import Test.Ganeti.Runtime
Niklas Hambuechen's avatar
Niklas Hambuechen committed
86
import Test.Ganeti.SlotMap
87
import Test.Ganeti.Ssconf
Michele Tartara's avatar
Michele Tartara committed
88 89 90 91
import Test.Ganeti.Storage.Diskstats.Parser
import Test.Ganeti.Storage.Drbd.Parser
import Test.Ganeti.Storage.Drbd.Types
import Test.Ganeti.Storage.Lvm.LVParser
92
import Test.Ganeti.THH
Petr Pudlak's avatar
Petr Pudlak committed
93
import Test.Ganeti.THH.Types
94
import Test.Ganeti.Types
95
import Test.Ganeti.Utils
96
import Test.Ganeti.Utils.MultiMap
97
import Test.Ganeti.Utils.Statistics
98
import Test.Ganeti.WConfd.Ssconf
99
import Test.Ganeti.WConfd.TempRes
100

101
-- | Our default test options, overring the built-in test-framework
102 103 104
-- ones (but not the supplied command line parameters).
defOpts :: TestOptions
defOpts = TestOptions
105 106 107 108 109 110
       { topt_seed                               = Nothing
       , topt_maximum_generated_tests            = Just 500
       , topt_maximum_unsuitable_generated_tests = Just 5000
       , topt_maximum_test_size                  = Nothing
       , topt_maximum_test_depth                 = Nothing
       , topt_timeout                            = Nothing
111
       }
112

113
-- | All our defined tests.
114
allTests :: [Test]
Iustin Pop's avatar
Iustin Pop committed
115
allTests =
116 117
  [ testAutoConf
  , testBasicTypes
118
  , testAttoparsec
119
  , testCommon
120
  , testConstants
121
  , testConfd_Types
122 123
  , testConfd_Utils
  , testDaemon
124
  , testBlock_Diskstats_Parser
125
  , testBlock_Drbd_Parser
126
  , testBlock_Drbd_Types
127
  , testErrors
128
  , testHTools_Backend_MonD
129 130
  , testHTools_Backend_Simu
  , testHTools_Backend_Text
131 132 133
  , testHTools_CLI
  , testHTools_Cluster
  , testHTools_Container
Guido Trotter's avatar
Guido Trotter committed
134
  , testHTools_Graph
135 136 137 138 139
  , testHTools_Instance
  , testHTools_Loader
  , testHTools_Node
  , testHTools_PeerMap
  , testHTools_Types
140
  , testHypervisor_Xen_XmParser
141 142
  , testJSON
  , testJobs
143
  , testJQueue
144
  , testJQScheduler
Jose A. Lopes's avatar
Jose A. Lopes committed
145
  , testKvmd
146
  , testLocking_Allocation
147
  , testLocking_Locks
148
  , testLocking_Waiting
149
  , testLuxi
150
  , testNetwork
151
  , testObjects
152
  , testObjects_BitArray
153
  , testOpCodes
154
  , testQuery_Aliases
155
  , testQuery_Filter
156
  , testQuery_Instance
157
  , testQuery_Language
158
  , testQuery_Network
159 160
  , testQuery_Query
  , testRpc
161
  , testRuntime
Niklas Hambuechen's avatar
Niklas Hambuechen committed
162
  , testSlotMap
163
  , testSsconf
Michele Tartara's avatar
Michele Tartara committed
164
  , testStorage_Lvm_LVParser
165
  , testTHH
Petr Pudlak's avatar
Petr Pudlak committed
166
  , testTHH_Types
167
  , testTypes
168
  , testUtils
169
  , testUtils_MultiMap
170
  , testUtils_Statistics
171
  , testWConfd_Ssconf
172
  , testWConfd_TempRes
Iustin Pop's avatar
Iustin Pop committed
173 174
  ]

175 176
-- | Main function. Note we don't use defaultMain since we want to
-- control explicitly our test sizes (and override the default).
177
main :: IO ()
178
main = do
179
  ropts <- getArgs >>= interpretArgsOrExit
180
  let opts = maybe defOpts (defOpts `mappend`) $ ropt_test_options ropts
Iustin Pop's avatar
Iustin Pop committed
181 182 183 184
  -- silence the logging system, so that tests can execute I/O actions
  -- which create logs without polluting stderr
  -- FIXME: improve this by allowing tests to use logging if needed
  updateGlobalLogger rootLoggerName (setLevel EMERGENCY)
185
  defaultMainWithOpts allTests (ropts { ropt_test_options = Just opts })