def test_outcome_checker_identifies_pushes_in_range(
    record_backfilled, test_repository, test_repository_2, range_dates, outcome_checking_pushes
):
    # TODO: retarget this test to BackfillRecord.get_pushes_in_range()
    outcome_checker = OutcomeChecker()
    total_pushes = Push.objects.count()

    from_time = range_dates['from_date']
    to_time = range_dates['to_date']

    total_outside_pushes = Push.objects.filter(
        Q(repository=test_repository) & (Q(time__lt=from_time) | Q(time__gt=to_time))
    ).count()

    pushes_in_range = outcome_checker._get_pushes_in_range(from_time, to_time, test_repository.id)
    assert len(pushes_in_range) == total_pushes - total_outside_pushes

    # change repository for the first 2 pushes in range
    assert test_repository.id != test_repository_2.id

    total_changed_pushes = 2
    for push in pushes_in_range[:total_changed_pushes]:
        push.repository = test_repository_2
        push.save()

    total_other_repo_pushes = Push.objects.filter(repository=test_repository_2).count()
    assert total_other_repo_pushes == total_changed_pushes

    updated_pushes_in_range = outcome_checker._get_pushes_in_range(
        from_time, to_time, test_repository.id
    )

    assert len(updated_pushes_in_range) == len(pushes_in_range) - total_other_repo_pushes
示例#2
0
    def test_pending_job_means_in_progress_outcome(self, record_backfilled,
                                                   outcome_checking_pushes,
                                                   jobs_with_one_pending):
        set_record_job_type(record_backfilled)
        outcome_checker = OutcomeChecker()

        response = outcome_checker.check(record_backfilled)
        assert response == OutcomeStatus.IN_PROGRESS
示例#3
0
    def test_failed_job_means_failed_outcome(self, record_backfilled,
                                             outcome_checking_pushes,
                                             jobs_with_one_failed):
        set_record_job_type(record_backfilled)
        outcome_checker = OutcomeChecker()

        response = outcome_checker.check(record_backfilled)
        assert response == OutcomeStatus.FAILED
示例#4
0
    def test_successful_jobs_mean_successful_outcome(self, record_backfilled,
                                                     outcome_checking_pushes,
                                                     successful_jobs):
        set_record_job_type(record_backfilled)
        outcome_checker = OutcomeChecker()

        response = outcome_checker.check(record_backfilled)
        assert response == OutcomeStatus.SUCCESSFUL
    def test_pending_job_means_in_progress_outcome(
        self, mock_get_job_type, record_backfilled, outcome_checking_pushes, jobs_with_one_pending
    ):
        mock_get_job_type.return_value = JOB_TYPE_ID
        outcome_checker = OutcomeChecker()

        response = outcome_checker.check(record_backfilled)
        assert response == OutcomeStatus.IN_PROGRESS
    def test_failed_job_means_failed_outcome(
        self, mock_get_job_type, record_backfilled, outcome_checking_pushes, jobs_with_one_failed
    ):
        mock_get_job_type.return_value = JOB_TYPE_ID
        outcome_checker = OutcomeChecker()

        response = outcome_checker.check(record_backfilled)
        assert response == OutcomeStatus.FAILED
    def test_successful_jobs_mean_successful_outcome(
        self, mock_get_job_type, record_backfilled, outcome_checking_pushes, successful_jobs
    ):
        # TODO: remove job type mock after soft launch lands
        mock_get_job_type.return_value = JOB_TYPE_ID
        outcome_checker = OutcomeChecker()

        response = outcome_checker.check(record_backfilled)
        assert response == OutcomeStatus.SUCCESSFUL
示例#8
0
    def test_pending_and_failed_jobs_means_in_progress_outcome(
            self, record_backfilled, outcome_checking_pushes,
            jobs_with_one_pending_and_one_failed):
        set_record_job_type(record_backfilled)
        outcome_checker = OutcomeChecker()

        response = outcome_checker.check(record_backfilled)
        # one job is in progress, one failed and the rest were successful
        assert record_backfilled.get_pushes_in_context_range().count() == 6
        assert record_backfilled.total_backfills_successful == 4
        assert record_backfilled.total_backfills_in_progress == 1
        assert record_backfilled.total_backfills_failed == 1
        assert response == OutcomeStatus.IN_PROGRESS
示例#9
0
    def test_successful_jobs_mean_successful_outcome(self, record_backfilled,
                                                     outcome_checking_pushes,
                                                     successful_jobs):
        set_record_job_type(record_backfilled)
        outcome_checker = OutcomeChecker()

        response = outcome_checker.check(record_backfilled)
        # all jobs were successful
        assert record_backfilled.get_pushes_in_context_range().count() == 6
        assert record_backfilled.total_backfills_successful == 6
        assert record_backfilled.total_backfills_in_progress == 0
        assert record_backfilled.total_backfills_failed == 0
        assert response == OutcomeStatus.SUCCESSFUL
示例#10
0
 def __init__(self,
              outcome_checker: OutcomeChecker = None,
              supported_platforms: List[str] = None):
     self.outcome_checker = outcome_checker or OutcomeChecker()
     self.supported_platforms = supported_platforms or django_settings.SUPPORTED_PLATFORMS
示例#11
0
 def __init__(self, outcome_checker: OutcomeChecker = None):
     self.outcome_checker = outcome_checker or OutcomeChecker()