Skip to content
Snippets Groups Projects
Commit 64a66bd2 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

hv_xen: Test errors while writing config file


Test error handling while writing Xen configuration files.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 1dee2041
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,8 @@
import string # pylint: disable=W0402
import unittest
import tempfile
import shutil
from ganeti import constants
from ganeti import objects
......@@ -298,5 +300,29 @@ class TestXenHypervisorUnknownCommand(unittest.TestCase):
self.assertRaises(errors.ProgrammerError, hv._RunXen, [])
class TestXenHypervisorWriteConfigFile(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp()
def tearDown(self):
shutil.rmtree(self.tmpdir)
def testWriteError(self):
cfgdir = utils.PathJoin(self.tmpdir, "foobar")
hv = hv_xen.XenHypervisor(_cfgdir=cfgdir,
_run_cmd_fn=NotImplemented,
_cmd=NotImplemented)
self.assertFalse(os.path.exists(cfgdir))
try:
hv._WriteConfigFile("name", "data")
except errors.HypervisorError, err:
self.assertTrue(str(err).startswith("Cannot write Xen instance"))
else:
self.fail("Exception was not raised")
if __name__ == "__main__":
testutils.GanetiTestProgram()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment