def _ChooseTest(anomalies): """Chooses a test to use for a bisect job. The particular TestMetadata chosen determines the command and metric name that is chosen. The test to choose could depend on which of the anomalies has the largest regression size. Ideally, the choice of bisect bot to use should be based on bisect bot queue length, and the choice of metric should be based on regression size and noise level. However, we don't choose bisect bot and metric independently, since some regressions only happen for some tests on some platforms; we should generally only bisect with a given bisect bot on a given metric if we know that the regression showed up on that platform for that metric. Args: anomalies: A non-empty list of Anomaly entities. Returns: An Anomaly entity, or None if no valid entity could be chosen. Raises: NotBisectableError: The only matching tests are on masters that have been blacklisted for automatic bisects on alert triage. """ if not anomalies: return None anomalies.sort(cmp=_CompareAnomalyBisectability) found_blacklisted_master = False for anomaly_entity in anomalies: if can_bisect.IsValidTestForBisect( utils.TestPath(anomaly_entity.GetTestMetadataKey())): if can_bisect.MasterNameIsBlacklistedForTriageBisects( anomaly_entity.master_name): found_blacklisted_master = True continue return anomaly_entity if found_blacklisted_master: raise NotBisectableError( 'Did not kick off bisect because only available masters are ' 'blacklisted from automatic bisects on triage.') return None
def testMasterNameIsBlacklistedForTriageBisects_Match_ReturnsTrue(self): namespaced_stored_object.Set( can_bisect.FILE_BUG_BISECT_BLACKLIST_KEY, {'foo': []}) self.assertTrue( can_bisect.MasterNameIsBlacklistedForTriageBisects('foo'))
def testMasterNameIsBlacklistedForTriageBisects_NoMasters_ReturnsFalse(self): self.assertFalse( can_bisect.MasterNameIsBlacklistedForTriageBisects('foo'))