Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Feat/total aggregation #1622

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions bzt/modules/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def __init__(self, perc_levels=None):
self.track_percentiles = perc_levels

@staticmethod
def get_mixed_label(label, rc=None, msg=None):
def get_state(label, rc=None, msg=None):
# it is used for generation of extended label.
# each label data is split according to sample state (success/error/assert)

Expand All @@ -658,13 +658,13 @@ def http_mark():
rc = int(rc) if is_int(rc) else 0 # it's jmeter_error by default
if msg:
if rc > 299 or http_mark():
group = SAMPLE_STATES[2] # http error
state = SAMPLE_STATES[2] # http error
else:
group = SAMPLE_STATES[1] # jmeter error
state = SAMPLE_STATES[1] # jmeter error
else:
group = SAMPLE_STATES[0] # succeeded sample
state = SAMPLE_STATES[0] # succeeded sample

return '-'.join((label, str(group)))
return state

def __process_readers(self, final_pass=False):
"""
Expand Down Expand Up @@ -721,6 +721,7 @@ def __aggregate_current(self, datapoint, samples):
overall = KPISet(self.track_percentiles, self.__get_rtimes_max(''), ext_aggregation=self._redundant_aggregation)

for label in current.values():

overall.merge_kpis(label, datapoint[DataPoint.SOURCE_ID])
current[''] = overall

Expand All @@ -734,17 +735,19 @@ def _get_suffix(self, label):
return ''

def __add_sample(self, current, label, kpis):
if self._redundant_aggregation:
# kpis format: conc, r_time, con_time, latency, r_code, error_msg, trname, byte_count
label = self.get_mixed_label(label=label, rc=kpis[4], msg=kpis[5])
# kpis format: conc, r_time, con_time, latency, r_code, error_msg, trname, byte_count
state = self.get_state(label=label, rc=kpis[4], msg=kpis[5])

if label not in current:
current[label] = KPISet(
current[label] = dict()

if state not in current[label]:
current[label][state] = KPISet(
perc_levels=self.track_percentiles,
hist_max_rt=self.__get_rtimes_max(label),
ext_aggregation=self._redundant_aggregation)

current[label].add_sample(kpis)
current[label][state].add_sample(kpis)

def __get_rtimes_max(self, label):
if label in self.cumulative:
Expand Down Expand Up @@ -879,7 +882,7 @@ def prepare(self):
self.track_percentiles.sort()
self.settings["percentiles"] = self.track_percentiles

self.set_aggregation(self.settings.get('extend-aggregation'))
self.set_aggregation(self.settings.get('extend-aggregation', True))

self.ignored_labels = self.settings.get("ignore-labels", self.ignored_labels)
self.generalize_labels = self.settings.get("generalize-labels", self.generalize_labels)
Expand Down
9 changes: 4 additions & 5 deletions bzt/modules/jmeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def __init__(self, filename, parent_logger, errors_filename=None, err_msg_separa
self.read_records = 0
if errors_filename:
self.errors_reader = JTLErrorsReader(
errors_filename, parent_logger, err_msg_separator, label_converter=self.get_mixed_label)
errors_filename, parent_logger, err_msg_separator, get_state=self.get_state)
else:
self.errors_reader = None

Expand Down Expand Up @@ -1187,7 +1187,7 @@ class JTLErrorsReader(object):
"""
url_xpath = GenericTranslator().css_to_xpath("java\\.net\\.URL")

def __init__(self, filename, parent_logger, err_msg_separator=None, label_converter=None):
def __init__(self, filename, parent_logger, err_msg_separator=None, get_state=None):
# http://stackoverflow.com/questions/9809469/python-sax-to-lxml-for-80gb-xml/9814580#9814580
super(JTLErrorsReader, self).__init__()
self.log = parent_logger.getChild(self.__class__.__name__)
Expand All @@ -1196,7 +1196,7 @@ def __init__(self, filename, parent_logger, err_msg_separator=None, label_conver
self.buffer = BetterDict()
self.failed_processing = False
self.err_msg_separator = err_msg_separator
self.label_converter = label_converter
self.get_state = get_state
self._redundant_aggregation = False

def set_aggregation(self, aggregation):
Expand Down Expand Up @@ -1287,8 +1287,7 @@ def _extract_common(self, elem, label, r_code, t_stamp, r_msg):

err_item = KPISet.error_item_skel(f_msg, f_rc, 1, f_type, url_counts, f_tag)
buf = self.buffer.get(t_stamp, force_set=True)
if self._redundant_aggregation:
label = self.label_converter(label=label, rc=r_code, msg=r_msg)
state = self.get_state(label=label, rc=r_code, msg=r_msg)
KPISet.inc_list(buf.get(label, [], force_set=True), ("msg", f_msg), err_item)
KPISet.inc_list(buf.get('', [], force_set=True), ("msg", f_msg), err_item)

Expand Down