def _ProcessTest(test_key): """Processes a test to find new anomalies. Args: test_key: The ndb.Key for a TestMetadata. """ # We're dropping clank support, which goes through the old recipe_bisect # system. For now, we're simply disabling alert generation and stopping # bisects from getting kicked off. We'll follow up with a more thorough # removal of all old bisect related code. # crbug.com/937230 if test_key.id().startswith('ClankInternal'): raise ndb.Return(None) test = yield test_key.get_async() config = yield anomaly_config.GetAnomalyConfigDictAsync(test) max_num_rows = config.get('max_window_size', DEFAULT_NUM_POINTS) rows_by_stat = yield GetRowsToAnalyzeAsync(test, max_num_rows) ref_rows_by_stat = {} ref_test = yield _CorrespondingRefTest(test_key) if ref_test: ref_rows_by_stat = yield GetRowsToAnalyzeAsync(ref_test, max_num_rows) for s, rows in rows_by_stat.items(): if rows: logging.info('Processing test: %s', test_key.id()) yield _ProcessTestStat(config, test, s, rows, ref_rows_by_stat.get(s))
def _ProcessTest(test_key): """Processes a test to find new anomalies. Args: test_key: The ndb.Key for a TestMetadata. """ test = yield test_key.get_async() sheriff = yield _GetSheriffForTest(test) if not sheriff: logging.error('No sheriff for %s', test_key) raise ndb.Return(None) config = yield anomaly_config.GetAnomalyConfigDictAsync(test) max_num_rows = config.get('max_window_size', DEFAULT_NUM_POINTS) rows_by_stat = yield GetRowsToAnalyzeAsync(test, max_num_rows) ref_rows_by_stat = {} ref_test = yield _CorrespondingRefTest(test_key) if ref_test: ref_rows_by_stat = yield GetRowsToAnalyzeAsync(ref_test, max_num_rows) for s, rows in rows_by_stat.iteritems(): if rows: yield _ProcesssTestStat(config, sheriff, test, s, rows, ref_rows_by_stat.get(s))
def _ProcessTest(test_key): """Processes a test to find new anomalies. Args: test_key: The ndb.Key for a TestMetadata. """ test = yield test_key.get_async() sheriff = yield _GetSheriffForTest(test) if not sheriff: logging.error('No sheriff for %s', test_key) raise ndb.Return(None) config = yield anomaly_config.GetAnomalyConfigDictAsync(test) max_num_rows = config.get('max_window_size', DEFAULT_NUM_POINTS) rows = yield GetRowsToAnalyzeAsync(test, max_num_rows) # If there were no rows fetched, then there's nothing to analyze. if not rows: # In some cases (e.g. if some points are deleted) it might be possible # that last_alerted_revision is incorrect. In this case, reset it. highest_rev = yield _HighestRevision(test_key) if test.last_alerted_revision > highest_rev: logging.error('last_alerted_revision %d is higher than highest rev %d ' 'for test %s; setting last_alerted_revision to None.', test.last_alerted_revision, highest_rev, test.test_path) test.last_alerted_revision = None yield test.put_async() logging.error('No rows fetched for %s', test.test_path) raise ndb.Return(None) # Get anomalies and check if they happen in ref build also. change_points = FindChangePointsForTest(rows, config) change_points = yield _FilterAnomaliesFoundInRef( change_points, test_key, len(rows)) anomalies = yield [_MakeAnomalyEntity(c, test, rows) for c in change_points] # If no new anomalies were found, then we're done. if not anomalies: return logging.info('Created %d anomalies', len(anomalies)) logging.info(' Test: %s', test_key.id()) logging.info(' Sheriff: %s', test.sheriff.id()) # Update the last_alerted_revision property of the test. test.last_alerted_revision = anomalies[-1].end_revision yield test.put_async() yield ndb.put_multi_async(anomalies) # TODO(simonhatch): email_sheriff.EmailSheriff() isn't a tasklet yet, so this # code will run serially. # Email sheriff about any new regressions. for anomaly_entity in anomalies: if (anomaly_entity.bug_id is None and not anomaly_entity.is_improvement and not sheriff.summarize): email_sheriff.EmailSheriff(sheriff, test, anomaly_entity)
def _ProcessTest(test_key): """Processes a test to find new anomalies. Args: test_key: The ndb.Key for a TestMetadata. """ # We're dropping clank support, which goes through the old recipe_bisect # system. For now, we're simply disabling alert generation and stopping # bisects from getting kicked off. We'll follow up with a more thorough # removal of all old bisect related code. # crbug.com/937230 if test_key.id().startswith('ClankInternal'): raise ndb.Return(None) test = yield test_key.get_async() sheriff, (new_sheriffs, err_msg) = yield _GetSheriffForTest(test) new_sheriffs_keys = [s.key.string_id() for s in new_sheriffs or []] logging.info('Sheriff for %s: old: %s, new: %s', test.test_path, 'None' if sheriff is None else sheriff.key.string_id(), err_msg if new_sheriffs is None else new_sheriffs_keys) if sheriff and sheriff.key.string_id() not in new_sheriffs_keys: logging.warn('Sheriff do not match: %s', test_key.string_id()) if not sheriff: logging.error('No sheriff for %s', test_key) raise ndb.Return(None) config = yield anomaly_config.GetAnomalyConfigDictAsync(test) max_num_rows = config.get('max_window_size', DEFAULT_NUM_POINTS) rows_by_stat = yield GetRowsToAnalyzeAsync(test, max_num_rows) ref_rows_by_stat = {} ref_test = yield _CorrespondingRefTest(test_key) if ref_test: ref_rows_by_stat = yield GetRowsToAnalyzeAsync(ref_test, max_num_rows) for s, rows in rows_by_stat.items(): if rows: yield _ProcesssTestStat(config, sheriff, test, s, rows, ref_rows_by_stat.get(s))