def testGetBotNamesFromAnomalies_RemovesDuplicates(self): testing_common.AddTests(['SuperGPU'], ['Bot1'], {'foo': {'bar': {}}}) anomaly.Anomaly(test=utils.TestKey('SuperGPU/Bot1/foo/bar')).put() anomaly.Anomaly(test=utils.TestKey('SuperGPU/Bot1/foo/bar')).put() anomalies = anomaly.Anomaly.query().fetch() bot_names = anomaly.GetBotNamesFromAlerts(anomalies) self.assertEqual(2, len(anomalies)) self.assertEqual(1, len(bot_names))
def testGetBotNamesFromAnomalies_ReturnsBotNames(self): testing_common.AddTests(['SuperGPU'], ['Bot1', 'Bot2', 'Bot3'], {'foo': { 'bar': {} }}) anomaly.Anomaly(test=utils.TestKey('SuperGPU/Bot1/foo/bar')).put() anomaly.Anomaly(test=utils.TestKey('SuperGPU/Bot2/foo/bar')).put() anomaly.Anomaly(test=utils.TestKey('SuperGPU/Bot3/foo/bar')).put() anomalies = anomaly.Anomaly.query().fetch() bot_names = anomaly.GetBotNamesFromAlerts(anomalies) self.assertEqual({'Bot1', 'Bot2', 'Bot3'}, bot_names)
def _AdditionalDetails(bug_id, alerts): """Returns a message with additional information to add to a bug.""" base_url = '%s/group_report' % _GetServerURL() bug_page_url = '%s?bug_id=%s' % (base_url, bug_id) sid = short_uri.GetOrCreatePageState(json.dumps(_UrlsafeKeys(alerts))) alerts_url = '%s?sid=%s' % (base_url, sid) comment = '<b>All graphs for this bug:</b>\n %s\n\n' % bug_page_url comment += ('(For debugging:) Original alerts at time of bug-filing:\n %s\n' % alerts_url) bot_names = anomaly.GetBotNamesFromAlerts(alerts) if bot_names: comment += '\n\nBot(s) for this bug\'s original alert(s):\n\n' comment += '\n'.join(sorted(bot_names)) else: comment += '\nCould not extract bot names from the list of alerts.' return comment
def testGetBotNamesFromAnomalies_EmptyList_ReturnsEmptySet(self): self.assertEqual(set(), anomaly.GetBotNamesFromAlerts([]))