Revision dbdb0594 test/py/qa.qa_config_unittest.py

b/test/py/qa.qa_config_unittest.py
277 277
    self.assertTrue(isinstance(self.config["instances"][0],
278 278
                               qa_config._QaInstance))
279 279

  
280
  def testNodeConversion(self):
281
    self.assertTrue(isinstance(self.config["nodes"][0],
282
                               qa_config._QaNode))
283

  
280 284
  def testAcquireAndReleaseInstance(self):
281 285
    self.assertFalse(compat.any(map(operator.attrgetter("used"),
282 286
                                    self.config["instances"])))
......
304 308
    self.assertRaises(qa_error.OutOfInstancesError,
305 309
                      qa_config.AcquireInstance, _cfg=self.config)
306 310

  
311
  def testAcquireNodeNoneAdded(self):
312
    self.assertFalse(compat.any(map(operator.attrgetter("added"),
313
                                    self.config["nodes"])))
314

  
315
    # First call must return master node
316
    node = qa_config.AcquireNode(_cfg=self.config)
317
    self.assertEqual(node, self.config.GetMasterNode())
318

  
319
    # Next call with exclusion list fails
320
    self.assertRaises(qa_error.OutOfNodesError, qa_config.AcquireNode,
321
                      exclude=[node], _cfg=self.config)
322

  
323
  def testAcquireNodeTooMany(self):
324
    # Mark all nodes as marked (master excluded)
325
    for node in self.config["nodes"]:
326
      if node != self.config.GetMasterNode():
327
        node.MarkAdded()
328

  
329
    nodecount = len(self.config["nodes"])
330

  
331
    self.assertTrue(nodecount > 1)
332

  
333
    acquired = []
334

  
335
    for _ in range(nodecount):
336
      node = qa_config.AcquireNode(exclude=acquired, _cfg=self.config)
337
      if node == self.config.GetMasterNode():
338
        self.assertFalse(node.added)
339
      else:
340
        self.assertTrue(node.added)
341
      self.assertEqual(node.use_count, 1)
342
      acquired.append(node)
343

  
344
    self.assertRaises(qa_error.OutOfNodesError, qa_config.AcquireNode,
345
                      exclude=acquired, _cfg=self.config)
346

  
307 347

  
308 348
if __name__ == "__main__":
309 349
  testutils.GanetiTestProgram()

Also available in: Unified diff