aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-05-29 02:53:54 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2017-05-29 03:03:39 +0200
commited4e5286935030cf07bd4c0888bae025aeb69278 (patch)
treecc0ff5cac08b8336543243c06d267e740e3eb0a4
parent2a1a1fa8f93aa217b10f5f0a54c6f0f14f358767 (diff)
fix: free resources when a suite run is done
Add missing code to free resources, not upon program exit, but when a suite is done. This allows running more than one suite in a row. Also add a check to not attempt to free if there is nothing to be freed, to avoid a regression test failure triggered when a suite exits without reserving anything. Change-Id: Ic017a1cf07052f5e48812c8553fba6f972d280f0 Related: OS#2301
-rw-r--r--src/osmo_gsm_tester/resource.py3
-rw-r--r--src/osmo_gsm_tester/suite.py6
2 files changed, 8 insertions, 1 deletions
diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index 8520612..ee3b209 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -494,7 +494,8 @@ class ReservedResources(log.Origin):
my_item.pop(USED_KEY)
def free(self):
- self.resources_pool.free(self.origin, self.reserved)
+ if self.reserved:
+ self.resources_pool.free(self.origin, self.reserved)
self.reserved = None
def counts(self):
diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py
index ac56ada..6a1796f 100644
--- a/src/osmo_gsm_tester/suite.py
+++ b/src/osmo_gsm_tester/suite.py
@@ -248,6 +248,7 @@ class SuiteRun(log.Origin):
# base exception is raised. Make sure to stop processes in this
# finally section. Resources are automatically freed with 'atexit'.
self.stop_processes()
+ self.free_resources()
event_loop.unregister_poll_func(self.poll)
self.duration = time.time() - self.start_timestamp
if self.test_failed_ctr:
@@ -268,6 +269,11 @@ class SuiteRun(log.Origin):
for process in self._processes:
process.terminate()
+ def free_resources(self):
+ if self.reserved_resources is None:
+ return
+ self.reserved_resources.free()
+
def ip_address(self):
return self.reserved_resources.get(resource.R_IP_ADDRESS)