Beispiel #1
0
  def testFailed(self):
    alloc_result = ([], [
      ("inst5191.example.com", "errormsg21178"),
      ], [])
    assert iallocator._NEVAC_RESULT(alloc_result)

    lu = _FakeLU()
    self.assertRaises(errors.OpExecError, common.LoadNodeEvacResult,
                      lu, alloc_result, False, False)
    self.assertFalse(lu.info_log)
    (_, (args, )) = lu.warning_log.pop(0)
    self.assertTrue("inst5191.example.com" in args)
    self.assertTrue("errormsg21178" in args)
    self.assertFalse(lu.warning_log)
  def testFailed(self):
    alloc_result = ([], [
      ("inst5191.example.com", "errormsg21178"),
      ], [])
    assert iallocator._NEVAC_RESULT(alloc_result)

    lu = _FakeLU()
    self.assertRaises(errors.OpExecError, common.LoadNodeEvacResult,
                      lu, alloc_result, False, False)
    self.assertFalse(lu.info_log)
    (_, (args, )) = lu.warning_log.pop(0)
    self.assertTrue("inst5191.example.com" in args)
    self.assertTrue("errormsg21178" in args)
    self.assertFalse(lu.warning_log)
    def testSuccess(self):
        for moved in [[],
                      [
                          ("inst20153.example.com", "grp2",
                           ["nodeA4509", "nodeB2912"]),
                      ]]:
            for early_release in [False, True]:
                for use_nodes in [False, True]:
                    jobs = [
                        [opcodes.OpInstanceReplaceDisks().__getstate__()],
                        [opcodes.OpInstanceMigrate().__getstate__()],
                    ]

                    alloc_result = (moved, [], jobs)
                    assert iallocator._NEVAC_RESULT(alloc_result)

                    lu = _FakeLU()
                    result = common.LoadNodeEvacResult(lu, alloc_result,
                                                       early_release,
                                                       use_nodes)

                    if moved:
                        (_, (info_args, )) = lu.info_log.pop(0)
                        for (instname, instgroup, instnodes) in moved:
                            self.assertTrue(instname in info_args)
                            if use_nodes:
                                for i in instnodes:
                                    self.assertTrue(i in info_args)
                            else:
                                self.assertTrue(instgroup in info_args)

                    self.assertFalse(lu.info_log)
                    self.assertFalse(lu.warning_log)

                    for op in itertools.chain(*result):
                        if hasattr(op.__class__, "early_release"):
                            self.assertEqual(op.early_release, early_release)
                        else:
                            self.assertFalse(hasattr(op, "early_release"))
Beispiel #4
0
  def testSuccess(self):
    for moved in [[], [
      ("inst20153.example.com", "grp2", ["nodeA4509", "nodeB2912"]),
      ]]:
      for early_release in [False, True]:
        for use_nodes in [False, True]:
          jobs = [
            [opcodes.OpInstanceReplaceDisks().__getstate__()],
            [opcodes.OpInstanceMigrate().__getstate__()],
            ]

          alloc_result = (moved, [], jobs)
          assert iallocator._NEVAC_RESULT(alloc_result)

          lu = _FakeLU()
          result = common.LoadNodeEvacResult(lu, alloc_result,
                                             early_release, use_nodes)

          if moved:
            (_, (info_args, )) = lu.info_log.pop(0)
            for (instname, instgroup, instnodes) in moved:
              self.assertTrue(instname in info_args)
              if use_nodes:
                for i in instnodes:
                  self.assertTrue(i in info_args)
              else:
                self.assertTrue(instgroup in info_args)

          self.assertFalse(lu.info_log)
          self.assertFalse(lu.warning_log)

          for op in itertools.chain(*result):
            if hasattr(op.__class__, "early_release"):
              self.assertEqual(op.early_release, early_release)
            else:
              self.assertFalse(hasattr(op, "early_release"))