4 # Copyright (C) 2010, 2013 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 """Script for testing hypervisor functionality"""
26 from ganeti import constants
27 from ganeti import compat
28 from ganeti import objects
29 from ganeti import errors
30 from ganeti import hypervisor
31 from ganeti.hypervisor import hv_base
36 class TestParameters(unittest.TestCase):
38 for hv, const_params in constants.HVC_DEFAULTS.items():
39 hyp = hypervisor.GetHypervisorClass(hv)
40 for pname in const_params:
41 self.assertTrue(pname in hyp.PARAMETERS,
42 "Hypervisor %s: parameter %s defined in constants"
43 " but not in the permitted hypervisor parameters" %
45 for pname in hyp.PARAMETERS:
46 self.assertTrue(pname in const_params,
47 "Hypervisor %s: parameter %s defined in the hypervisor"
48 " but missing a default value" %
52 class TestBase(unittest.TestCase):
53 def testVerifyResults(self):
54 fn = hv_base.BaseHypervisor._FormatVerifyResults
55 # FIXME: use assertIsNone when py 2.7 is minimum supported version
56 self.assertEqual(fn([]), None)
57 self.assertEqual(fn(["a"]), "a")
58 self.assertEqual(fn(["a", "b"]), "a; b")
61 if __name__ == "__main__":
62 testutils.GanetiTestProgram()