Commit 6f88e076 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

QA: Release instances through method



Instead of having a module-level function in “qa_config” to release an
instance, a new method on instance objects is used.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarBernardo Dal Seno <bdalseno@google.com>
parent 6a654276
......@@ -290,7 +290,7 @@ def RunCommonInstanceTests(instance):
RunTestIf("rapi", qa_rapi.TestRapiInstanceRenameAndBack,
rename_source, rename_target)
finally:
qa_config.ReleaseInstance(tgt_instance)
tgt_instance.Release()
RunTestIf(["instance-grow-disk"], qa_instance.TestInstanceGrowDisk, instance)
......@@ -375,7 +375,7 @@ def RunExportImportTests(instance, inodes):
RunTest(qa_instance.TestInstanceStartup, newinst)
RunTest(qa_instance.TestInstanceRemove, newinst)
finally:
qa_config.ReleaseInstance(newinst)
newinst.Release()
finally:
qa_config.ReleaseNode(expnode)
......@@ -389,7 +389,7 @@ def RunExportImportTests(instance, inodes):
finally:
qa_config.ReleaseNode(tnode)
finally:
qa_config.ReleaseInstance(newinst)
newinst.Release()
def RunDaemonTests(instance):
......@@ -482,9 +482,9 @@ def RunExclusiveStorageTests():
qa_instance.TestInstanceRemove(instance2)
qa_instance.TestInstanceRemove(instance1)
finally:
qa_config.ReleaseInstance(instance2)
instance2.Release()
finally:
qa_config.ReleaseInstance(instance1)
instance1.Release()
if qa_config.TestEnabled("instance-add-drbd-disk"):
snode = qa_config.AcquireNode()
......@@ -497,7 +497,7 @@ def RunExclusiveStorageTests():
qa_cluster.AssertClusterVerify(fail=True, errors=exp_err)
qa_instance.TestInstanceRemove(instance)
finally:
qa_config.ReleaseInstance(instance)
instance.Release()
finally:
qa_config.ReleaseNode(snode)
qa_cluster.TestSetExclStorCluster(old_es)
......@@ -541,7 +541,7 @@ def RunInstanceTests():
RunRepairDiskSizes()
RunTest(qa_instance.TestInstanceRemove, instance)
finally:
qa_config.ReleaseInstance(instance)
instance.Release()
del instance
finally:
......@@ -601,7 +601,7 @@ def RunQa():
RunCommonInstanceTests(rapi_instance)
RunTest(qa_rapi.TestRapiInstanceRemove, rapi_instance, use_client)
finally:
qa_config.ReleaseInstance(rapi_instance)
rapi_instance.Release()
del rapi_instance
finally:
......@@ -635,7 +635,7 @@ def RunQa():
finally:
qa_config.ReleaseNode(expnode)
finally:
qa_config.ReleaseInstance(instance)
instance.Release()
del expnode
del instance
qa_cluster.AssertClusterVerify()
......
......@@ -553,7 +553,7 @@ def TestClusterBurnin():
finally:
for inst in instances:
qa_config.ReleaseInstance(inst)
inst.Release()
def TestClusterMasterFailover():
......
......@@ -88,6 +88,17 @@ class _QaInstance(object):
except KeyError:
return default
def Release(self):
"""Releases instance and makes it available again.
"""
assert self.used, \
("Instance '%s' was never acquired or released more than once" %
self.name)
self.used = False
self.disk_template = None
def GetNicMacAddr(self, idx, default):
"""Returns MAC address for NIC.
......@@ -422,11 +433,6 @@ def AcquireInstance(_cfg=None):
return inst
def ReleaseInstance(inst):
inst.used = False
inst.disk_template = None
def GetInstanceTemplate(inst):
"""Return the disk template of an instance.
......
......@@ -80,7 +80,7 @@ def _DiskTest(node, disk_template):
return instance
except:
qa_config.ReleaseInstance(instance)
instance.Release()
raise
......
......@@ -598,7 +598,7 @@ def TestRapiInstanceAdd(node, use_client):
return instance
except:
qa_config.ReleaseInstance(instance)
instance.Release()
raise
......
......@@ -285,7 +285,7 @@ class TestQaConfig(unittest.TestCase):
self.assertTrue(inst.used)
self.assertTrue(inst.disk_template is None)
qa_config.ReleaseInstance(inst)
inst.Release()
self.assertFalse(inst.used)
self.assertTrue(inst.disk_template is None)
......
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