aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-05-22 20:02:41 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-05-29 00:18:42 +0200
commit2d1d561eeb8c91a350380c9279cb9853bd7a275d (patch)
tree8d82ca0c3a4df4e74c38043745d0b3d8c36975ad
parent927344b4dc1223e0f455971ef9293c90fb7d3a80 (diff)
resource error logging that is easier to understand
Log what a suite requested, what it has reserved and the complete resource state. Change-Id: Ic6887bbe5fe74a73f0e344cd4078dd7ed989cc15
-rw-r--r--src/osmo_gsm_tester/resource.py11
-rw-r--r--src/osmo_gsm_tester/suite.py11
2 files changed, 20 insertions, 2 deletions
diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index e660066..ebc9457 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -463,8 +463,9 @@ class ReservedResources(log.Origin):
available = available_dict.get(kind)
self.dbg(available=len(available))
if not available:
- raise NoResourceExn('No unused resource found: %r%s' %
+ raise NoResourceExn('When trying to reserve %r nr %d: No unused resource found%s' %
(kind,
+ self.count(kind) + 1,
(' matching %r' % specifics) if specifics else '')
)
pick = available[0]
@@ -496,5 +497,13 @@ class ReservedResources(log.Origin):
self.resources_pool.free(self.origin, self.reserved)
self.reserved = None
+ def counts(self):
+ counts = {}
+ for key in self.reserved.keys():
+ counts[key] = self.count(key)
+ return counts
+
+ def count(self, key):
+ return len(self.reserved.get(key) or [])
# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py
index d55ee92..5d03b95 100644
--- a/src/osmo_gsm_tester/suite.py
+++ b/src/osmo_gsm_tester/suite.py
@@ -22,6 +22,7 @@ import sys
import time
import copy
import traceback
+import pprint
from . import config, log, template, util, resource, schema, ofono_client, osmo_nitb, event_loop
from . import test
@@ -130,7 +131,8 @@ class Test(log.Origin):
ftype = type(e).__name__
fmsg = repr(e) + '\n' + traceback.format_exc().rstrip()
if isinstance(e, resource.NoResourceExn):
- fmsg += '\n' + 'Current resource state:\n' + repr(suite_run.reserved_resources)
+ fmsg += suite_run.resource_status_str()
+
self.set_fail(ftype, fmsg, False)
finally:
@@ -314,6 +316,13 @@ class SuiteRun(log.Origin):
self.log('prompt entered:', repr(entered))
return entered
+ def resource_status_str(self):
+ return '\n'.join(('',
+ 'SUITE RUN: %s' % self.origin_id(),
+ 'ASKED FOR:', pprint.pformat(self._resource_requirements),
+ 'RESERVED COUNT:', pprint.pformat(self.reserved_resources.counts()),
+ 'RESOURCES STATE:', repr(self.reserved_resources)))
+
loaded_suite_definitions = {}
def load(suite_name):