Commit 13c16b21 authored by Jose A. Lopes's avatar Jose A. Lopes

Update tests after merging 'os_get' into 'os_validate'

... namely, unit tests and QA.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent a3a19a06
...@@ -382,6 +382,16 @@ def TestInstanceReinstall(instance): ...@@ -382,6 +382,16 @@ def TestInstanceReinstall(instance):
instance.name], instance.name],
fail=True) fail=True)
# Test with existing OS but invalid variant
AssertCommand(["gnt-instance", "reinstall", "-f", "-o", "debootstrap+ola",
instance.name],
fail=True)
# Test with existing OS but invalid variant
AssertCommand(["gnt-instance", "reinstall", "-f", "-o", "debian-image+ola",
instance.name],
fail=True)
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG) @InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
def TestInstanceRenameAndBack(rename_source, rename_target): def TestInstanceRenameAndBack(rename_source, rename_target):
......
...@@ -30,6 +30,7 @@ import unittest ...@@ -30,6 +30,7 @@ import unittest
import mock import mock
import operator import operator
from ganeti import backend
from ganeti import compat from ganeti import compat
from ganeti import constants from ganeti import constants
from ganeti import errors from ganeti import errors
...@@ -76,10 +77,6 @@ class TestLUInstanceCreate(CmdlibTestCase): ...@@ -76,10 +77,6 @@ class TestLUInstanceCreate(CmdlibTestCase):
self.node1 = self.cfg.AddNewNode() self.node1 = self.cfg.AddNewNode()
self.node2 = self.cfg.AddNewNode() self.node2 = self.cfg.AddNewNode()
self.rpc.call_os_get.side_effect = \
lambda node, _: self.RpcResultsBuilder() \
.CreateSuccessfulNodeResult(node, self.os)
hv_info = ("bootid", hv_info = ("bootid",
[{ [{
"type": constants.ST_LVM_VG, "type": constants.ST_LVM_VG,
...@@ -744,26 +741,26 @@ param1=val1 ...@@ -744,26 +741,26 @@ param1=val1
class TestCheckOSVariant(CmdlibTestCase): class TestCheckOSVariant(CmdlibTestCase):
def testNoVariantsSupported(self): def testNoVariantsSupported(self):
os = self.cfg.CreateOs(supported_variants=[]) os = self.cfg.CreateOs(supported_variants=[])
self.assertRaises(errors.OpPrereqError, instance_utils._CheckOSVariant, self.assertRaises(backend.RPCFail, backend._CheckOSVariant,
os, "os+variant") os, "os+variant")
def testNoVariantGiven(self): def testNoVariantGiven(self):
os = self.cfg.CreateOs(supported_variants=["default"]) os = self.cfg.CreateOs(supported_variants=["default"])
self.assertRaises(errors.OpPrereqError, instance_utils._CheckOSVariant, self.assertRaises(backend.RPCFail, backend._CheckOSVariant,
os, "os") os, "os")
def testWrongVariantGiven(self): def testWrongVariantGiven(self):
os = self.cfg.CreateOs(supported_variants=["default"]) os = self.cfg.CreateOs(supported_variants=["default"])
self.assertRaises(errors.OpPrereqError, instance_utils._CheckOSVariant, self.assertRaises(backend.RPCFail, backend._CheckOSVariant,
os, "os+wrong_variant") os, "os+wrong_variant")
def testOkWithVariant(self): def testOkWithVariant(self):
os = self.cfg.CreateOs(supported_variants=["default"]) os = self.cfg.CreateOs(supported_variants=["default"])
instance_utils._CheckOSVariant(os, "os+default") backend._CheckOSVariant(os, "os+default")
def testOkWithoutVariant(self): def testOkWithoutVariant(self):
os = self.cfg.CreateOs(supported_variants=[]) os = self.cfg.CreateOs(supported_variants=[])
instance_utils._CheckOSVariant(os, "os") backend._CheckOSVariant(os, "os")
class TestCheckTargetNodeIPolicy(TestLUInstanceCreate): class TestCheckTargetNodeIPolicy(TestLUInstanceCreate):
...@@ -1864,9 +1861,7 @@ class TestLUInstanceSetParams(CmdlibTestCase): ...@@ -1864,9 +1861,7 @@ class TestLUInstanceSetParams(CmdlibTestCase):
def testOsChange(self): def testOsChange(self):
os = self.cfg.CreateOs(supported_variants=[]) os = self.cfg.CreateOs(supported_variants=[])
self.rpc.call_os_get.return_value = \ self.rpc.call_os_validate.return_value = True
self.RpcResultsBuilder() \
.CreateSuccessfulNodeResult(self.master, os)
op = self.CopyOpCode(self.op, op = self.CopyOpCode(self.op,
os_name=os.name) os_name=os.name)
self.ExecOpCode(op) self.ExecOpCode(op)
......
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