LGTM

On Tuesday, May 17, 2016 at 1:28:21 PM UTC+1, Brian Foley wrote:
>
> commit 6387dcf3b01ee5dce7a2c4abd438b877b34de462 
> Merge: 9b6d390 671d167 
> Author: Brian Foley <bpfo...@google.com> 
> Date:   Tue May 17 12:44:44 2016 +0100 
>
>     Merge branch 'stable-2.15' into stable-2.16 
>     
>     * stable-2.15 
>       mcpu: Raise caught OpPrereqErrors with too few args 
>       Make EnsureDirs print chmod mode on errors 
>       Fix CLI option typo in NEWS file 
>     
>     Signed-off-by: Brian Foley <bpfo...@google.com> 
>
> diff --cc test/py/ganeti.mcpu_unittest.py 
> index 54bd640,796c2ba..42446c7 
> --- a/test/py/ganeti.mcpu_unittest.py 
> +++ b/test/py/ganeti.mcpu_unittest.py 
> @@@ -33,14 -33,16 +33,17 @@@ 
>   
>   import unittest 
>   import itertools 
> + import mocks 
> + from cmdlib.testsupport.rpc_runner_mock import CreateRpcRunnerMock 
>   
>   from ganeti import compat 
>  +from ganeti import errors 
>   from ganeti import mcpu 
>   from ganeti import opcodes 
>   from ganeti import cmdlib 
>   from ganeti import locking 
>  +from ganeti import serializer 
> + from ganeti import ht 
>  -from ganeti import errors 
>   from ganeti import constants 
>   from ganeti.constants import \ 
>       LOCK_ATTEMPTS_TIMEOUT, \ 
> @@@ -177,42 -179,37 +180,73 @@@ class TestProcessResult(unittest.TestCa 
>       self.assertEqual(op2.comment, "foobar") 
>       self.assertEqual(op2.debug_level, 3) 
>   
> + class TestExecLU(unittest.TestCase): 
> +   class OpTest(opcodes.OpCode): 
> +     OP_DSC_FIELD = "data" 
> +     OP_PARAMS = [ 
> +       ("data", ht.NoDefault, ht.TString, None), 
> +     ] 
> + 
> +   def setUp(self): 
> +     self.ctx = mocks.FakeContext() 
> +     self.cfg = self.ctx.GetConfig("ec_id") 
> +     self.rpc = CreateRpcRunnerMock() 
> +     self.proc = mcpu.Processor(self.ctx, "ec_id", enable_locks = False) 
> +     self.op = self.OpTest() 
> +     self.calc_timeout = lambda: 42 
> + 
> +   def testRunLU(self): 
> +     lu = mocks.FakeLU(self.proc, self.op, self.cfg, self.rpc, None) 
> +     self.proc._ExecLU(lu) 
> + 
> +   def testRunLUWithPrereqError(self): 
> +     prereq = errors.OpPrereqError(self.op, errors.ECODE_INVAL) 
> +     lu = mocks.FakeLU(self.proc, self.op, self.cfg, self.rpc, prereq) 
> +     self.assertRaises(errors.OpPrereqError, self.proc._LockAndExecLU, 
> +         lu, locking.LEVEL_CLUSTER, self.calc_timeout) 
> + 
> +   def testRunLUWithPrereqErrorMissingECode(self): 
> +     prereq = errors.OpPrereqError(self.op) 
> +     lu = mocks.FakeLU(self.proc, self.op, self.cfg, self.rpc, prereq) 
> +     self.assertRaises(errors.OpPrereqError, self.proc._LockAndExecLU, 
> +         lu, locking.LEVEL_CLUSTER, self.calc_timeout) 
> + 
>   
>  +class TestSecretParams(unittest.TestCase): 
>  +  def testSecretParamsCheckNoError(self): 
>  +    op = opcodes.OpInstanceCreate( 
>  +      instance_name="plain.example.com", 
>  +      pnode="master.example.com", 
>  +      disk_template=constants.DT_PLAIN, 
>  +      mode=constants.INSTANCE_CREATE, 
>  +      nics=[{}], 
>  +      disks=[{ 
>  +        constants.IDISK_SIZE: 1024 
>  +      }], 
>  +      osparams_secret= serializer.PrivateDict({"foo":"bar", 
> "foo2":"bar2"}), 
>  +      os_type="debian-image") 
>  + 
>  +    try: 
>  +      mcpu._CheckSecretParameters(op) 
>  +    except errors.OpPrereqError: 
>  +      self.fail("OpPrereqError raised unexpectedly in 
> _CheckSecretParameters") 
>  + 
>  +  def testSecretParamsCheckWithError(self): 
>  +    op = opcodes.OpInstanceCreate( 
>  +      instance_name="plain.example.com", 
>  +      pnode="master.example.com", 
>  +      disk_template=constants.DT_PLAIN, 
>  +      mode=constants.INSTANCE_CREATE, 
>  +      nics=[{}], 
>  +      disks=[{ 
>  +        constants.IDISK_SIZE: 1024 
>  +      }], 
>  +      osparams_secret= serializer.PrivateDict({"foo":"bar", 
>  +                                             
>  "secret_param":"<redacted>"}), 
>  +      os_type="debian-image") 
>  + 
>  +    self.assertRaises(errors.OpPrereqError, mcpu._CheckSecretParameters, 
> op) 
>  + 
>  + 
>   if __name__ == "__main__": 
>     testutils.GanetiTestProgram() 
>

Reply via email to