From 6957173cb3f9a2caae6fb0f3ee1981084bcaad75 Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Tue, 22 Mar 2016 13:55:20 +0300 Subject: [PATCH] Simulator: collect error stats Collect client-side error statistics. Change-Id: I8fb41e3a5e58a9215961775be3c70d7c1a822285 --- tools/simulator.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/simulator.py b/tools/simulator.py index c12bdac8a..d8697fa99 100755 --- a/tools/simulator.py +++ b/tools/simulator.py @@ -316,6 +316,7 @@ class Client(object): # and a message transport self.position = random.randint(0, self.messages_count - 1) self.sent_messages = MessageStatsCollector('client-%s' % client_id) + self.errors = MessageStatsCollector('error-%s' % client_id) if has_result: self.round_trip_messages = MessageStatsCollector( @@ -325,7 +326,14 @@ class Client(object): msg = make_message(self.seq, MESSAGES[self.position], time.time()) self.sent_messages.push(msg) - res = self.method(self.client, msg) + res = None + try: + res = self.method(self.client, msg) + except Exception: + self.errors.push(msg) + else: + LOG.debug("SENT: %s", msg) + if res: return_ts = time.time() res = update_message(res, return_ts=return_ts) @@ -445,6 +453,7 @@ def _rpc_call(client, msg): res = client.call({}, 'info', message=msg) except Exception as e: LOG.exception('Error %s on CALL for message %s', str(e), msg) + raise else: LOG.debug("SENT: %s, RCV: %s", msg, res) return res @@ -455,6 +464,7 @@ def _rpc_cast(client, msg): client.cast({}, 'info', message=msg) except Exception as e: LOG.exception('Error %s on CAST for message %s', str(e), msg) + raise else: LOG.debug("SENT: %s", msg) @@ -482,6 +492,7 @@ def show_client_stats(clients, json_filename, has_reply=False): for cl in clients: cl_id = cl.client_id output['series']['client_%s' % cl_id] = cl.sent_messages.get_series() + output['series']['error_%s' % cl_id] = cl.errors.get_series() if has_reply: output['series']['round_trip_%s' % cl_id] = ( @@ -491,6 +502,10 @@ def show_client_stats(clients, json_filename, has_reply=False): 'client', *(cl.sent_messages for cl in clients)) output['summary']['client'] = sent_stats + error_stats = MessageStatsCollector.calc_stats( + 'error', *(cl.errors for cl in clients)) + output['summary']['error'] = error_stats + if has_reply: round_trip_stats = MessageStatsCollector.calc_stats( 'round-trip', *(cl.round_trip_messages for cl in clients))