def ComputeTestPath(suite_path, guid, histograms): hist = histograms.LookupHistogram(guid) path = '%s/%s' % (suite_path, hist.name) tir_label = histogram_helpers.GetTIRLabelFromHistogram(hist) if tir_label: path += '/' + tir_label is_ref = hist.diagnostics.get(reserved_infos.IS_REFERENCE_BUILD.name) if is_ref and len(is_ref) == 1: is_ref = list(is_ref)[0] # If a Histogram represents a summary across multiple stories, then its # 'stories' diagnostic will contain the names of all of the stories. # If a Histogram is not a summary, then its 'stories' diagnostic will contain # the singular name of its story. story_name = hist.diagnostics.get(reserved_infos.STORIES.name) if story_name and len(story_name) == 1: escaped_story_name = add_point.EscapeName(list(story_name)[0]) path += '/' + escaped_story_name if is_ref: path += '_ref' elif is_ref: path += '/ref' return path
def testGetTIRLabelFromHistogram_NoValidTags_ReturnsEmpty(self): hist = histogram_module.Histogram('hist', 'count') histograms = histogram_set.HistogramSet([hist]) histograms.AddSharedDiagnosticToAllHistograms( reserved_infos.STORY_TAGS.name, generic_set.GenericSet(['foo', 'bar'])) self.assertEqual('', histogram_helpers.GetTIRLabelFromHistogram(hist))
def ComputeTestPath(suite_path, hist): path = '%s/%s' % (suite_path, hist.name) # If a Histogram represents a summary across multiple stories, then its # 'stories' diagnostic will contain the names of all of the stories. # If a Histogram is not a summary, then its 'stories' diagnostic will contain # the singular name of its story. is_summary = list( hist.diagnostics.get(reserved_infos.SUMMARY_KEYS.name, [])) tir_label = histogram_helpers.GetTIRLabelFromHistogram(hist) if tir_label and (not is_summary or reserved_infos.STORY_TAGS.name in is_summary): path += '/' + tir_label is_ref = hist.diagnostics.get(reserved_infos.IS_REFERENCE_BUILD.name) if is_ref and len(is_ref) == 1: is_ref = is_ref.GetOnlyElement() story_name = hist.diagnostics.get(reserved_infos.STORIES.name) if story_name and len(story_name) == 1 and not is_summary: escaped_story_name = add_point.EscapeName(story_name.GetOnlyElement()) path += '/' + escaped_story_name if is_ref: path += '_ref' elif is_ref: path += '/ref' return path
def testGetTIRLabelFromHistogram_ValidTags_SortsByKey(self): hist = histogram_module.Histogram('hist', 'count') histograms = histogram_set.HistogramSet([hist]) histograms.AddSharedDiagnosticToAllHistograms( reserved_infos.STORY_TAGS.name, generic_set.GenericSet( ['z:last', 'ignore', 'a:first', 'me', 'm:middle'])) self.assertEqual( 'first_middle_last', histogram_helpers.GetTIRLabelFromHistogram(hist))
def _Poll(self): # TODO(simonhatch): Switch this to use the new perf-output flag instead # of the chartjson one. They're functionally equivalent, just new name. histogram_dicts = _RetrieveOutputJson( self._isolate_hash, 'chartjson-output.json') histograms = histogram_set.HistogramSet() histograms.ImportDicts(histogram_dicts) histograms.ResolveRelatedHistograms() matching_histograms = histograms.GetHistogramsNamed(self._hist_name) # Get and cache any trace URLs. unique_trace_urls = set() for hist in histograms: trace_urls = hist.diagnostics.get(reserved_infos.TRACE_URLS.name) if trace_urls: unique_trace_urls.update(trace_urls) sorted_urls = sorted(unique_trace_urls) self._trace_urls = [ {'name': t.split('/')[-1], 'url': t} for t in sorted_urls] # Filter the histograms by tir_label and story. Getting either the # tir_label or the story from a histogram involves pulling out and # examining various diagnostics associated with the histogram. tir_label = self._tir_label or '' matching_histograms = [ h for h in matching_histograms if tir_label == histogram_helpers.GetTIRLabelFromHistogram(h)] # If no story is supplied, we're looking for a summary metric so just match # on name and tir_label. This is equivalent to the chartjson condition that # if no story is specified, look for "summary". if self._story: matching_histograms = [ h for h in matching_histograms if self._story == _GetStoryFromHistogram(h)] # Have to pull out either the raw sample values, or the statistic result_values = [] for h in matching_histograms: result_values.extend(self._GetValuesOrStatistic(h)) if not result_values and self._hist_name: name = 'histogram: %s' % self._hist_name if tir_label: name += ' tir_label: %s' % tir_label if self._story: name += ' story: %s' % self._story raise ReadValueError('Could not find values matching: %s' % name) self._Complete(result_values=tuple(result_values))
def testGetTIRLabelFromHistogram_NoTags_ReturnsEmpty(self): hist = histogram_module.Histogram('hist', 'count') self.assertEqual('', histogram_helpers.GetTIRLabelFromHistogram(hist))
def _MatchesStoryAndTIRLabel(hist): return ( tir_label == histogram_helpers.GetTIRLabelFromHistogram(hist) and self._story == _GetStoryFromHistogram(hist))
def _Poll(self): # TODO(dtu): Remove after data migration. if not hasattr(self, '_isolate_server'): self._isolate_server = 'https://isolateserver.appspot.com' if not hasattr(self, '_results_filename'): self._results_filename = 'chartjson-output.json' histogram_dicts = _RetrieveOutputJson(self._isolate_server, self._isolate_hash, self._results_filename) histograms = histogram_set.HistogramSet() histograms.ImportDicts(histogram_dicts) histograms.ResolveRelatedHistograms() matching_histograms = histograms.GetHistogramsNamed(self._hist_name) # Get and cache any trace URLs. unique_trace_urls = set() for hist in histograms: trace_urls = hist.diagnostics.get(reserved_infos.TRACE_URLS.name) # TODO(simonhatch): Remove this sometime after May 2018. We had a # brief period where the histograms generated by tests had invalid # trace_urls diagnostics. If the diagnostic we get back is just a ref, # then skip. # https://github.com/catapult-project/catapult/issues/4243 if trace_urls and not isinstance(trace_urls, diagnostic_ref.DiagnosticRef): unique_trace_urls.update(trace_urls) sorted_urls = sorted(unique_trace_urls) self._trace_urls = [{ 'name': t.split('/')[-1], 'url': t } for t in sorted_urls] # Filter the histograms by tir_label and story. Getting either the # tir_label or the story from a histogram involves pulling out and # examining various diagnostics associated with the histogram. tir_label = self._tir_label or '' matching_histograms = [ h for h in matching_histograms if tir_label == histogram_helpers.GetTIRLabelFromHistogram(h) ] # If no story is supplied, we're looking for a summary metric so just match # on name and tir_label. This is equivalent to the chartjson condition that # if no story is specified, look for "summary". if self._story: matching_histograms = [ h for h in matching_histograms if self._story == _GetStoryFromHistogram(h) ] # Have to pull out either the raw sample values, or the statistic result_values = [] for h in matching_histograms: result_values.extend(self._GetValuesOrStatistic(h)) if not result_values and self._hist_name: conditions = {'histogram': self._hist_name} if tir_label: conditions['tir_label'] = tir_label if self._story: conditions['story'] = self._story raise ReadValueError('Could not find values matching: %s' % conditions) self._Complete(result_values=tuple(result_values))