Commit e695efbf authored by Iustin Pop's avatar Iustin Pop

Add missing paramter and unittests for this case

While git-am'ing the blockdev_prefix patch, I modified the hv_xen.py
file but forgot to amend the patch :(, so here it is.

Furthermore, to detect such inconsistencies in the future, a unittest is
added that cross-checks the default parameters in constants.py and the
hypervisor PARAMETERS dict.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 525011bc
...@@ -431,6 +431,7 @@ python_tests = \ ...@@ -431,6 +431,7 @@ python_tests = \
test/ganeti.errors_unittest.py \ test/ganeti.errors_unittest.py \
test/ganeti.hooks_unittest.py \ test/ganeti.hooks_unittest.py \
test/ganeti.http_unittest.py \ test/ganeti.http_unittest.py \
test/ganeti.hypervisor.py \
test/ganeti.hypervisor.hv_kvm_unittest.py \ test/ganeti.hypervisor.hv_kvm_unittest.py \
test/ganeti.impexpd_unittest.py \ test/ganeti.impexpd_unittest.py \
test/ganeti.jqueue_unittest.py \ test/ganeti.jqueue_unittest.py \
......
...@@ -562,6 +562,8 @@ class XenHvmHypervisor(XenHypervisor): ...@@ -562,6 +562,8 @@ class XenHvmHypervisor(XenHypervisor):
constants.HV_MIGRATION_PORT: hv_base.NET_PORT_CHECK, constants.HV_MIGRATION_PORT: hv_base.NET_PORT_CHECK,
constants.HV_MIGRATION_MODE: hv_base.MIGRATION_MODE_CHECK, constants.HV_MIGRATION_MODE: hv_base.MIGRATION_MODE_CHECK,
constants.HV_USE_LOCALTIME: hv_base.NO_CHECK, constants.HV_USE_LOCALTIME: hv_base.NO_CHECK,
# TODO: Add a check for the blockdev prefix (matching [a-z:] or similar).
constants.HV_BLOCKDEV_PREFIX: hv_base.NO_CHECK,
} }
@classmethod @classmethod
......
#!/usr/bin/python
#
# Copyright (C) 2010 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
# 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.
"""Script for testing hypervisor functionality"""
import unittest
from ganeti import constants
from ganeti import compat
from ganeti import objects
from ganeti import errors
from ganeti import hypervisor
import testutils
class TestParameters(unittest.TestCase):
def test(self):
for hv, const_params in constants.HVC_DEFAULTS.items():
hyp = hypervisor.GetHypervisorClass(hv)
for pname in const_params:
self.assertTrue(pname in hyp.PARAMETERS,
"Hypervisor %s: parameter %s defined in constants"
" but not in the permitted hypervisor parameters" %
(hv, pname))
for pname in hyp.PARAMETERS:
self.assertTrue(pname in const_params,
"Hypervisor %s: parameter %s defined in the hypervisor"
" but missing a default value" %
(hv, pname))
if __name__ == "__main__":
testutils.GanetiTestProgram()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment