def test_return_all_failing_tests(self):
        """This function returns all tests that failed at least once."""
        job = models.Job(job_idx=1)
        kernel = models.Kernel(kernel_idx=1)
        machine = models.Machine(machine_idx=1)

        test1 = models.Test(job=job,
                            status=FAIL_STATUS,
                            kernel=kernel,
                            machine=machine,
                            test='test1',
                            started_time=datetime.datetime(2012, 1, 1))
        test1.save()
        test2 = models.Test(job=job,
                            status=FAIL_STATUS,
                            kernel=kernel,
                            machine=machine,
                            test='test2',
                            started_time=datetime.datetime(2012, 1, 2))
        test2.save()

        results = utils.get_last_fail_times()

        self.assertEquals(
            results, {
                'test1': datetime.datetime(2012, 1, 1),
                'test2': datetime.datetime(2012, 1, 2)
            })
    def test_does_not_return_passing_tests(self):
        """Test that passing test entries are not included."""
        job = models.Job(job_idx=1)
        kernel = models.Kernel(kernel_idx=1)
        machine = models.Machine(machine_idx=1)

        passing_test = models.Test(job=job,
                                   status=GOOD_STATUS,
                                   kernel=kernel,
                                   machine=machine,
                                   test='passing_test',
                                   started_time=datetime.datetime(2012, 1, 1))
        passing_test.save()
        failing_test = models.Test(job=job,
                                   status=FAIL_STATUS,
                                   kernel=kernel,
                                   machine=machine,
                                   test='failing_test',
                                   started_time=datetime.datetime(2012, 1, 1))
        failing_test.save()

        results = utils.get_last_fail_times()

        self.assertEquals(results,
                          {'failing_test': datetime.datetime(2012, 1, 1)})
    def test_return_most_recent_fail(self):
        """The last time a test failed should be returned."""
        # To add a test entry to the database, the test object has to
        # be instantiated with various other model instances. We give these
        # instances dummy id values.
        job = models.Job(job_idx=1)
        kernel = models.Kernel(kernel_idx=1)
        machine = models.Machine(machine_idx=1)

        early_fail = models.Test(job=job,
                                 status=FAIL_STATUS,
                                 kernel=kernel,
                                 machine=machine,
                                 test='test',
                                 started_time=datetime.datetime(2012, 1, 1))
        early_fail.save()
        late_fail = models.Test(job=job,
                                status=FAIL_STATUS,
                                kernel=kernel,
                                machine=machine,
                                test='test',
                                started_time=datetime.datetime(2012, 1, 2))
        late_fail.save()

        results = utils.get_last_fail_times()

        self.assertEquals(results, {'test': datetime.datetime(2012, 1, 2)})
    def test_returns_treats_alert_status_as_failure(self):
        """Alert statuses should count as failures."""
        job = models.Job(job_idx=1)
        kernel = models.Kernel(kernel_idx=1)
        machine = models.Machine(machine_idx=1)

        test = models.Test(job=job,
                           status=ALERT_STATUS,
                           kernel=kernel,
                           machine=machine,
                           test='alert',
                           started_time=datetime.datetime(2012, 1, 1))
        test.save()

        results = utils.get_last_fail_times()

        self.assertEquals(results, {'alert': datetime.datetime(2012, 1, 1)})
    def test_returns_treats_abort_status_as_failure(self):
        """
        Abort statuses should count as failures.

        This should be changed once Abort only represents user caused aborts.
        See issue crbug.com/188217.
        """
        job = models.Job(job_idx=1)
        kernel = models.Kernel(kernel_idx=1)
        machine = models.Machine(machine_idx=1)

        test = models.Test(job=job,
                           status=ABORT_STATUS,
                           kernel=kernel,
                           machine=machine,
                           test='abort',
                           started_time=datetime.datetime(2012, 1, 1))
        test.save()

        results = utils.get_last_fail_times()

        self.assertEquals(results, {'abort': datetime.datetime(2012, 1, 1)})
Пример #6
0
def main(args=None):
    """
    The script code.

    Allows other python code to import and run this code. This will be more
    important if a nice way to test this code can be determined.

    @param args: The command line arguments being passed in.

    """
    args = [] if args is None else args
    parse_options(args)

    experimental_tests = get_experimental_tests()
    pass_times = test_health_utils.get_last_pass_times()
    fail_times = test_health_utils.get_last_fail_times()

    long_passers = find_long_passing_tests(pass_times, fail_times,
                                           experimental_tests)

    submit_bug_reports(long_passers)

    return 0