Ejemplo n.º 1
0
def test_task_in_context():
    # match
    tag_set_list, task_tags = [load_json_fixture(f)
                               for f in ("matchingTagSetList.json", "matchingTaskTags.json")]
    assert TaskclusterModel._task_in_context(tag_set_list, task_tags) is True

    # mismatch
    tag_set_list, task_tags = [load_json_fixture(f)
                               for f in ("mismatchingTagSetList.json", "mismatchingTaskTags.json")]
    assert TaskclusterModel._task_in_context(tag_set_list, task_tags) is False
Ejemplo n.º 2
0
def test_backfilling_job_from_try_repo_raises_exception(job_from_try):
    backfill_tool = BackfillTool(
        TaskclusterModel('https://fakerooturl.org', 'FAKE_CLIENT_ID',
                         'FAKE_ACCESS_TOKEN'))

    with pytest.raises(CannotBackfill):
        backfill_tool.backfill_job(job_from_try.id)
Ejemplo n.º 3
0
    def _remove_leftovers(self):
        # remove any signatures which are
        # no longer associated with a job
        signatures = PerformanceSignature.objects.filter(last_updated__lte=self.max_timestamp)
        tc_model = TaskclusterModel(
            root_url, client_id=settings.NOTIFY_CLIENT_ID, access_token=settings.NOTIFY_ACCESS_TOKEN
        )
        signatures_remover = PublicSignatureRemover(timer=self.timer, taskcluster_model=tc_model)
        signatures_remover.remove_in_chunks(signatures)

        # remove empty alert summaries
        logger.warning('Removing alert summaries which no longer have any alerts...')
        (
            PerformanceAlertSummary.objects.prefetch_related('alerts', 'related_alerts')
            .annotate(
                total_alerts=Count('alerts'),
                total_related_alerts=Count('related_alerts'),
            )
            .filter(
                total_alerts=0,
                total_related_alerts=0,
                # WARNING! Don't change this without proper approval!           #
                # Otherwise we risk deleting data that's actively investigated  #
                # and cripple the perf sheriffing process!                      #
                created__lt=(datetime.now() - timedelta(days=180)),
                #################################################################
            )
            .delete()
        )
Ejemplo n.º 4
0
    def handle(self, *args, **options):
        job_id = options['job']
        client_id = settings.PERF_SHERIFF_BOT_CLIENT_ID
        access_token = settings.PERF_SHERIFF_BOT_ACCESS_TOKEN

        taskcluster_model = TaskclusterModel(root_url, client_id, access_token)
        backfill_tool = BackfillTool(taskcluster_model)

        task_id = backfill_tool.backfill_job(job_id)

        print(f"Task id {task_id} created when backfilled job id {job_id}")
Ejemplo n.º 5
0
def test_get_action(actions_json, expected_backfill_task):
    action_array = actions_json["actions"]

    backfill_task = TaskclusterModel._get_action(action_array, "backfill")
    assert backfill_task == expected_backfill_task
Ejemplo n.º 6
0
def test_filter_relevant_actions(actions_json, original_task, expected_actions_json):
    reduced_actions_json = TaskclusterModel._filter_relevant_actions(actions_json,
                                                                     original_task)

    assert reduced_actions_json == expected_actions_json