root / test / py / ganeti.hypervisor_unittest.py @ 91c17910
History | View | Annotate | Download (2 kB)
1 |
#!/usr/bin/python
|
---|---|
2 |
#
|
3 |
|
4 |
# Copyright (C) 2010, 2013 Google Inc.
|
5 |
#
|
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.
|
10 |
#
|
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.
|
15 |
#
|
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
|
19 |
# 02110-1301, USA.
|
20 |
|
21 |
|
22 |
"""Script for testing hypervisor functionality"""
|
23 |
|
24 |
import unittest |
25 |
|
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 |
32 |
|
33 |
import testutils |
34 |
|
35 |
|
36 |
class TestParameters(unittest.TestCase): |
37 |
def test(self): |
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" %
|
44 |
(hv, pname)) |
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" %
|
49 |
(hv, pname)) |
50 |
|
51 |
|
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") |
59 |
|
60 |
|
61 |
if __name__ == "__main__": |
62 |
testutils.GanetiTestProgram() |