class Command(BaseCommand): AVAILABLE_FRAMEWORKS = PerformanceFramework.fetch_all_names() AVAILABLE_REPOS = Repository.fetch_all_names() SHERIFFED_FRAMEWORKS = [ 'browsertime', 'raptor', 'talos', 'awsy', 'build_metrics', 'js-bench' ] SHERIFFED_REPOS = ['autoland', 'mozilla-beta'] help = "Select most relevant alerts and identify jobs to retrigger." def add_arguments(self, parser): parser.add_argument( '--time-window', action='store', type=int, default=60, help= "How far back to look for alerts to retrigger (expressed in minutes).", ) parser.add_argument( '--frameworks', nargs='+', default=self.SHERIFFED_FRAMEWORKS, choices=self.AVAILABLE_FRAMEWORKS, help="Defaults to all registered performance frameworks.", ) parser.add_argument( '--repositories', nargs='+', default=self.SHERIFFED_REPOS, choices=self.AVAILABLE_REPOS, help=f"Defaults to {self.SHERIFFED_REPOS}.", ) def handle(self, *args, **options): frameworks, repositories, since, days_to_lookup = self._parse_args( **options) perf_sheriff_bot = perf_sheriff_bot_factory(days_to_lookup) try: perf_sheriff_bot.sheriff(since, frameworks, repositories) except MaxRuntimeExceeded as ex: logging.info(ex) logging.info("Perfsheriff bot: Going back to sleep") def _parse_args(self, **options) -> Tuple[List, List, datetime, timedelta]: return ( options['frameworks'], options['repositories'], datetime.now() - timedelta(minutes=options['time_window']), timedelta(days=1), )
def test_has_job(find_it): job = Job(id=123, repository=Repository(), guid='12345') job_list = [ {'id': 111}, {'id': 222}, ] if find_it: job_list.append({'id': 123}) assert has_job(job, job_list) else: assert not has_job(job, job_list)