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

-}

Iustin Pop's avatar
Iustin Pop committed
5
6
{-

7
Copyright (C) 2009, 2011, 2012, 2013 Google Inc.
Iustin Pop's avatar
Iustin Pop committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.

-}

26
27
module Main(main) where

28
29
import Data.Monoid (mappend)
import Test.Framework
30
import System.Environment (getArgs)
Iustin Pop's avatar
Iustin Pop committed
31
import System.Log.Logger
32

33
import Test.AutoConf
34
import Test.Ganeti.TestImports ()
35
import Test.Ganeti.Attoparsec
36
import Test.Ganeti.BasicTypes
Iustin Pop's avatar
Iustin Pop committed
37
import Test.Ganeti.Common
Jose A. Lopes's avatar
Jose A. Lopes committed
38
import Test.Ganeti.Constants
39
import Test.Ganeti.Confd.Utils
40
import Test.Ganeti.Confd.Types
Iustin Pop's avatar
Iustin Pop committed
41
import Test.Ganeti.Daemon
42
import Test.Ganeti.Errors
43
44
import Test.Ganeti.HTools.Backend.Simu
import Test.Ganeti.HTools.Backend.Text
45
46
47
import Test.Ganeti.HTools.CLI
import Test.Ganeti.HTools.Cluster
import Test.Ganeti.HTools.Container
Guido Trotter's avatar
Guido Trotter committed
48
import Test.Ganeti.HTools.Graph
49
import Test.Ganeti.HTools.Instance
50
import Test.Ganeti.HTools.Loader
51
52
53
import Test.Ganeti.HTools.Node
import Test.Ganeti.HTools.PeerMap
import Test.Ganeti.HTools.Types
54
import Test.Ganeti.Hypervisor.Xen.XmParser
55
import Test.Ganeti.JSON
56
import Test.Ganeti.Jobs
Iustin Pop's avatar
Iustin Pop committed
57
import Test.Ganeti.JQueue
Jose A. Lopes's avatar
Jose A. Lopes committed
58
import Test.Ganeti.Kvmd
59
import Test.Ganeti.Luxi
60
import Test.Ganeti.Network
Iustin Pop's avatar
Iustin Pop committed
61
import Test.Ganeti.Objects
62
import Test.Ganeti.OpCodes
63
import Test.Ganeti.Query.Aliases
Iustin Pop's avatar
Iustin Pop committed
64
import Test.Ganeti.Query.Filter
65
import Test.Ganeti.Query.Instance
66
import Test.Ganeti.Query.Language
67
import Test.Ganeti.Query.Network
68
import Test.Ganeti.Query.Query
Iustin Pop's avatar
Iustin Pop committed
69
import Test.Ganeti.Rpc
70
import Test.Ganeti.Runtime
71
import Test.Ganeti.Ssconf
Michele Tartara's avatar
Michele Tartara committed
72
73
74
75
import Test.Ganeti.Storage.Diskstats.Parser
import Test.Ganeti.Storage.Drbd.Parser
import Test.Ganeti.Storage.Drbd.Types
import Test.Ganeti.Storage.Lvm.LVParser
76
import Test.Ganeti.THH
77
import Test.Ganeti.Types
78
import Test.Ganeti.Utils
79

80
-- | Our default test options, overring the built-in test-framework
81
82
83
-- ones (but not the supplied command line parameters).
defOpts :: TestOptions
defOpts = TestOptions
84
85
86
87
88
89
       { 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
Iustin Pop's avatar
Iustin Pop committed
90
       }
91

92
-- | All our defined tests.
93
allTests :: [Test]
Iustin Pop's avatar
Iustin Pop committed
94
allTests =
95
96
  [ testAutoConf
  , testBasicTypes
97
  , testAttoparsec
98
  , testCommon
Jose A. Lopes's avatar
Jose A. Lopes committed
99
  , testConstants
100
  , testConfd_Types
101
102
  , testConfd_Utils
  , testDaemon
103
  , testBlock_Diskstats_Parser
104
  , testBlock_Drbd_Parser
105
  , testBlock_Drbd_Types
106
  , testErrors
107
108
  , testHTools_Backend_Simu
  , testHTools_Backend_Text
109
110
111
  , testHTools_CLI
  , testHTools_Cluster
  , testHTools_Container
Guido Trotter's avatar
Guido Trotter committed
112
  , testHTools_Graph
113
114
115
116
117
  , testHTools_Instance
  , testHTools_Loader
  , testHTools_Node
  , testHTools_PeerMap
  , testHTools_Types
118
  , testHypervisor_Xen_XmParser
119
120
  , testJSON
  , testJobs
Iustin Pop's avatar
Iustin Pop committed
121
  , testJQueue
Jose A. Lopes's avatar
Jose A. Lopes committed
122
  , testKvmd
123
  , testLuxi
124
  , testNetwork
125
126
  , testObjects
  , testOpCodes
127
  , testQuery_Aliases
128
  , testQuery_Filter
129
  , testQuery_Instance
130
  , testQuery_Language
131
  , testQuery_Network
132
133
  , testQuery_Query
  , testRpc
134
  , testRuntime
135
  , testSsconf
Michele Tartara's avatar
Michele Tartara committed
136
  , testStorage_Lvm_LVParser
137
  , testTHH
138
  , testTypes
139
  , testUtils
Iustin Pop's avatar
Iustin Pop committed
140
141
  ]

142
143
-- | Main function. Note we don't use defaultMain since we want to
-- control explicitly our test sizes (and override the default).
144
main :: IO ()
145
main = do
146
  ropts <- getArgs >>= interpretArgsOrExit
147
  let opts = maybe defOpts (defOpts `mappend`) $ ropt_test_options ropts
Iustin Pop's avatar
Iustin Pop committed
148
149
150
151
  -- 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)
152
  defaultMainWithOpts allTests (ropts { ropt_test_options = Just opts })