Beispiel #1
0
    def __extract_results__(self):
        test_runs = models.TestRun.objects.filter(
            build__in=self.builds, ).prefetch_related(
                'build',
                'environment',
            ).only('build', 'environment')

        test_runs_ids = {}
        for test_run in test_runs:
            build = test_run.build
            env = test_run.environment.slug

            self.all_environments.add(env)
            self.environments[build].add(env)

            if test_runs_ids.get(test_run.id, None) is None:
                test_runs_ids[test_run.id] = (build, env)

        for ids in split_dict(test_runs_ids, chunk_size=100):
            self.__extract_test_results__(ids)

        self.__resolve_intermittent_tests__()

        self.results = OrderedDict(sorted(self.results.items()))
        for build in self.builds:
            self.environments[build] = sorted(self.environments[build])
Beispiel #2
0
    def test_split_dict(self):
        _dict = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}

        chunks = split_dict(_dict)

        self.assertEqual(5, len(chunks))
        self.assertEqual({'a': 1}, chunks[0])
        self.assertEqual({'e': 5}, chunks[4])

        _dict = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
        chunks = split_dict(_dict, chunk_size=2)

        self.assertEqual(3, len(chunks))
        self.assertEqual({'a': 1, 'b': 2}, chunks[0])
        self.assertEqual({'c': 3, 'd': 4}, chunks[1])
        self.assertEqual({'e': 5}, chunks[2])
Beispiel #3
0
    def __resolve_intermittent_tests__(self):
        if len(self.tests_with_issues) == 0:
            return

        for chunk in split_dict(self.tests_with_issues, chunk_size=100):
            tests = models.Test.objects.filter(id__in=chunk.keys(
            )).prefetch_related('known_issues').only('known_issues')
            for test in tests.all():
                for issue in test.known_issues.all():
                    if issue.intermittent:
                        self.__intermittent__[chunk[test.id]] = True
                        break
Beispiel #4
0
    def __extract_results__(self):

        # New implementation below is only stable for getting regressions and fixes
        # that is used for receiving tests and generating ProjectStatus.regressions and fixes
        # It is still not good for applying transitions and getting a comparison
        # results table, for that, use legacy code, which is slow and eats up lots
        # of memory
        if self.regressions_and_fixes_only:
            self.__new_extract_results__()
            return

        test_runs = models.TestRun.objects.filter(
            build__in=self.builds, ).prefetch_related(
                'build',
                'environment',
            ).only('build', 'environment')

        test_runs_ids = {}
        for test_run in test_runs:
            build = test_run.build
            env = test_run.environment.slug

            self.all_environments.add(env)
            self.environments[build].add(env)

            if test_runs_ids.get(test_run.id, None) is None:
                test_runs_ids[test_run.id] = (build, env)

        for ids in split_dict(test_runs_ids, chunk_size=100):
            self.__extract_test_results__(ids)

        self.__resolve_intermittent_tests__()

        self.results = OrderedDict(sorted(self.results.items()))
        for build in self.builds:
            self.environments[build] = sorted(self.environments[build])