コード例 #1
0
    def testGetTestRerunBuildInputProperties(self):
        tests = {
            'step1': {
                'tests': [],
                'properties': {
                    'failure_type': 'xx_test_failures',
                    'test_spec': 'test_spec1',
                }
            },
            'step2': {
                'tests': [],
                'properties': {
                    'failure_type': 'xx_test_failures',
                    'test_spec': 'test_spec2',
                }
            }
        }

        expected_input = {
            '$chromeos/cros_bisect': {
                'test': {
                    'xx_test_failures': [{
                        'test_spec': 'test_spec2'
                    }, {
                        'test_spec': 'test_spec1'
                    }],
                },
            },
        }

        self.assertEqual(
            expected_input,
            ChromeOSProjectAPI().GetTestRerunBuildInputProperties(
                tests, 8000000000122))
コード例 #2
0
    def testGetCompileRerunBuildInputProperties(self):
        build_target = 'abc'
        output_target1 = json.dumps({
            'category': 'chromeos-base',
            'packageName': 'target1'
        })
        targets = {'install packages': [output_target1]}

        build = Build()
        build.input.properties['build_target'] = {'name': build_target}

        expected_prop = {
            'recipe': 'build_target',
            'build_target': {
                'name': build_target
            },
            '$chromeos/cros_bisect': {
                'targets': [output_target1]
            },
        }

        self.assertEqual(
            expected_prop,
            ChromeOSProjectAPI().GetCompileRerunBuildInputProperties(
                build, targets))
コード例 #3
0
    def testGetCompileRerunBuildInputPropertiesOtherStep(self):
        build = Build()
        build.input.properties['build_target'] = {'name': 'abc'}

        self.assertIsNone(
            ChromeOSProjectAPI().GetCompileRerunBuildInputProperties(
                build, {}))
コード例 #4
0
    def testGetFailuresWithMatchingCompileFailureGroupsNoExistingGroup(self):
        build_id = 8000000000122
        build = Build(builder=self.builder, number=122, id=build_id)
        build.input.gitiles_commit.host = 'gitiles.host.com'
        build.input.gitiles_commit.project = 'project/name'
        build.input.gitiles_commit.ref = 'ref/heads/master'
        build.input.gitiles_commit.id = 'git_sha'

        last_passed_build_info = {
            'id': 8000000000121,
            'number': 121,
            'commit_id': 'git_sha_121'
        }

        output_target1 = json.dumps({
            'category': 'chromeos-base',
            'packageName': 'target1'
        })

        first_failures_in_current_build = {
            'failures': {
                'install packages': {
                    'output_targets': [frozenset([output_target1])],
                    'last_passed_build': last_passed_build_info,
                },
            },
            'last_passed_build': last_passed_build_info
        }

        self.assertEqual(
            {},
            ChromeOSProjectAPI().GetFailuresWithMatchingCompileFailureGroups(
                self.context, build, first_failures_in_current_build))
コード例 #5
0
    def testGetFailuresWithMatchingTestFailureGroupsNoExistingGroup(self):
        build_id = 8000000000122
        build = Build(builder=self.builder, number=122, id=build_id)
        build.input.gitiles_commit.host = 'gitiles.host.com'
        build.input.gitiles_commit.project = 'project/name'
        build.input.gitiles_commit.ref = 'ref/heads/master'
        build.input.gitiles_commit.id = 'git_sha'

        last_passed_build_info = {
            'id': 8000000000121,
            'number': 121,
            'commit_id': 'git_sha_121'
        }

        first_failures_in_current_build = {
            'failures': {
                'step': {
                    'atomic_failures': [],
                    'last_passed_build': last_passed_build_info,
                },
            },
            'last_passed_build': last_passed_build_info,
        }

        self.assertEqual(
            {},
            ChromeOSProjectAPI().GetFailuresWithMatchingTestFailureGroups(
                self.context, build, first_failures_in_current_build))
コード例 #6
0
    def testGetTestFailures(self):
        step_name = 'results|xx test results|[FAILED] <suite1>'
        build_id = 8765432109123
        build_number = 123
        build = self._CreateBuildbucketBuildForTest(build_id,
                                                    build_number,
                                                    step_name=step_name)
        step = Step()
        step.name = step_name

        expected_failures = {
            step_name: {
                'failures': {},
                'first_failed_build': {
                    'id': build_id,
                    'number': build_number,
                    'commit_id': 'git_sha',
                },
                'last_passed_build': None,
                'properties': {
                    'failure_type': 'xx_test_failures',
                    'test_spec': 'test_spec',
                    'suite': 'suite',
                    'needs_bisection': True,
                }
            },
        }

        self.assertEqual(expected_failures,
                         ChromeOSProjectAPI().GetTestFailures(build, [step]))
コード例 #7
0
    def testGetFailuresWithMatchingCompileFailureGroupsWithExistingGroup(self):
        build_id = 8000000000122
        build = Build(builder=self.builder, number=122, id=build_id)
        build.input.gitiles_commit.host = 'gitiles.host.com'
        build.input.gitiles_commit.project = 'project/name'
        build.input.gitiles_commit.ref = 'ref/heads/master'
        build.input.gitiles_commit.id = 'git_sha'

        last_passed_build_info = {
            'id': 8000000000121,
            'number': 121,
            'commit_id': 'git_sha_121'
        }

        first_failures_in_current_build = {
            'failures': {
                'install packages': {
                    'output_targets': [
                        frozenset(['target1']),
                    ],
                    'last_passed_build': last_passed_build_info,
                },
            },
            'last_passed_build': last_passed_build_info
        }

        compile_failure = CompileFailure.Create(
            self.group_build.key,
            'install packages', ['target1'],
            'CXX',
            first_failed_build_id=self.group_build_id,
            last_passed_build_id=8000000000160)
        compile_failure.put()

        CompileFailureGroup.Create(
            luci_project=self.context.luci_project_name,
            luci_bucket=build.builder.bucket,
            build_id=self.group_build_id,
            gitiles_host=self.context.gitiles_host,
            gitiles_project=self.context.gitiles_project,
            gitiles_ref=self.context.gitiles_ref,
            last_passed_gitiles_id=last_passed_build_info['commit_id'],
            last_passed_commit_position=654321,
            first_failed_gitiles_id=self.first_failed_commit_id,
            first_failed_commit_position=654340,
            compile_failure_keys=[compile_failure.key]).put()

        expected_failures_with_existing_group = {
            'install packages': {
                frozenset(['target1']): self.group_build_id
            }
        }

        self.assertEqual(
            expected_failures_with_existing_group,
            ChromeOSProjectAPI().GetFailuresWithMatchingCompileFailureGroups(
                self.context, build, first_failures_in_current_build))
コード例 #8
0
 def testInfraStepFromABuildWithTestStep(self):
     step_name = 'results|xx test results|[FAILED] <suite1>'
     build_id = 8765432109123
     build_number = 123
     build = self._CreateBuildbucketBuildForTest(build_id,
                                                 build_number,
                                                 step_name=step_name)
     step = Step()
     step.name = 'another_step'
     self.assertEqual(StepTypeEnum.INFRA,
                      ChromeOSProjectAPI().ClassifyStepType(build, step))
コード例 #9
0
 def testInfraStepFromABuildWithoutCompileFailure(self):
     step_name = 'test step'
     build_id = 8765432109123
     build_number = 123
     build = self._CreateBuildbucketBuild(build_id, build_number)
     step = Step()
     step.name = step_name
     log = step.logs.add()
     log.name = 'reason'
     self.assertEqual(StepTypeEnum.INFRA,
                      ChromeOSProjectAPI().ClassifyStepType(build, step))
コード例 #10
0
 def testInfraStepFromABuildWithCompileFailureNoFailedStep(self):
     compile_step_name = 'install packages|installation results'
     build_id = 8765432109123
     build_number = 123
     build = self._CreateBuildbucketBuildForCompile(build_id, build_number,
                                                    self.output_targets)
     step = Step()
     step.name = compile_step_name
     log = step.logs.add()
     log.name = 'reason'
     self.assertEqual(StepTypeEnum.INFRA,
                      ChromeOSProjectAPI().ClassifyStepType(build, step))
コード例 #11
0
    def testGetCompileFailuresNoFailure(self):
        step_name = 'install packages'
        build_id = 8765432109123
        build_number = 123
        build = self._CreateBuildbucketBuild(build_id,
                                             build_number, [],
                                             step_name=step_name)
        step = Step()
        step.name = step_name

        self.assertEqual({},
                         ChromeOSProjectAPI().GetCompileFailures(
                             build, [step]))
コード例 #12
0
 def testGetFailureKeysToAnalyzeTestFailuresDifferentSuites(self):
     failure_entities = []
     for i in xrange(2):
         test_failure = TestFailure.Create(
             failed_build_key=ndb.Key(LuciFailedBuild, 8000000000123),
             step_ui_name='step.suite%d' % i,
             test=None,
             properties={'suite': 'suite%d' % i})
         failure_entities.append(test_failure)
     ndb.put_multi(failure_entities)
     analyzed_failure_keys = ChromeOSProjectAPI(
     ).GetFailureKeysToAnalyzeTestFailures(failure_entities)
     self.assertEqual(2, len(analyzed_failure_keys))
コード例 #13
0
 def testClearSkipFlag(self):
     build_id = 8000000000598
     failed_build_key = ndb.Key(LuciFailedBuild, build_id)
     failure = TestFailure.Create(failed_build_key=failed_build_key,
                                  step_ui_name='step.suite8',
                                  test=None,
                                  properties={
                                      'needs_bisection': False,
                                  })
     failure.put()
     ChromeOSProjectAPI().ClearSkipFlag([failure])
     failures = TestFailure.query(ancestor=failed_build_key).fetch()
     self.assertTrue(failures[0].properties['needs_bisection'])
コード例 #14
0
    def testGetTestFailuresMalFormedOutput(self):
        step_name = 'no spec'
        build_id = 8765432109123
        build_number = 123
        build = self._CreateBuildbucketBuildForTest(build_id,
                                                    build_number,
                                                    step_name=step_name)
        step = Step()
        step.name = step_name

        expected_failures = {}

        self.assertEqual(expected_failures,
                         ChromeOSProjectAPI().GetTestFailures(build, [step]))
コード例 #15
0
    def testGetCompileRerunBuildInputProperties(self):
        targets = {'install packages': [self.output_target1]}

        expected_prop = {
            '$chromeos/cros_bisect': {
                'compile': {
                    'targets': [self.output_target1],
                },
            },
        }

        self.assertEqual(
            expected_prop,
            ChromeOSProjectAPI().GetCompileRerunBuildInputProperties(
                targets, 8000000000122))
コード例 #16
0
 def testCompileStep(self):
     compile_step_name = 'install packages|installation results'
     build_id = 8765432109123
     build_number = 123
     build = self._CreateBuildbucketBuildForCompile(
         build_id,
         build_number,
         self.output_targets,
         step_name=compile_step_name)
     step = Step()
     step.name = compile_step_name
     log = step.logs.add()
     log.name = 'stdout'
     self.assertEqual(StepTypeEnum.COMPILE,
                      ChromeOSProjectAPI().ClassifyStepType(build, step))
コード例 #17
0
    def testGetCompileFailuresNoFailedStep(self):
        step_name = 'install packages'
        build_id = 8765432109123
        build_number = 123
        output_target = json.dumps({
            'category': 'chromeos-base',
            'packageName': 'target2'
        })
        build = self._CreateBuildbucketBuild(build_id, build_number,
                                             [output_target])
        step = Step()
        step.name = step_name

        self.assertEqual({},
                         ChromeOSProjectAPI().GetCompileFailures(
                             build, [step]))
コード例 #18
0
    def testGetFailureKeysToAnalyzeTestFailures(self):
        failure_entities = []
        for i in xrange(2):
            test_failure = TestFailure.Create(failed_build_key=ndb.Key(
                LuciFailedBuild, 8000000000123),
                                              step_ui_name='step%d.suite' % i,
                                              test=None,
                                              properties={'suite': 'suite'})
            failure_entities.append(test_failure)
        ndb.put_multi(failure_entities)
        analyzed_failure_keys = ChromeOSProjectAPI(
        ).GetFailureKeysToAnalyzeTestFailures(failure_entities)
        self.assertEqual(1, len(analyzed_failure_keys))

        deduped_failure_keys = set([f.key for f in failure_entities
                                    ]) - set(analyzed_failure_keys)
        self.assertEqual(analyzed_failure_keys[0],
                         deduped_failure_keys.pop().get().merged_failure_key)
コード例 #19
0
    def testGetCompileFailures(self):
        step_name = 'install packages'
        build_id = 8765432109123
        build_number = 123
        output_target1 = json.dumps({
            'category': 'chromeos-base',
            'packageName': 'target1'
        })
        output_target2 = json.dumps({
            'category': 'chromeos-base',
            'packageName': 'target2'
        })
        build = self._CreateBuildbucketBuild(build_id,
                                             build_number,
                                             [output_target1, output_target2],
                                             step_name=step_name)
        step = Step()
        step.name = step_name

        expected_failures = {
            'install packages': {
                'failures': {
                    frozenset([output_target1, output_target2]): {
                        'rule': 'emerge',
                        'first_failed_build': {
                            'id': build_id,
                            'number': build_number,
                            'commit_id': 'git_sha'
                        },
                        'last_passed_build': None,
                    },
                },
                'first_failed_build': {
                    'id': build_id,
                    'number': build_number,
                    'commit_id': 'git_sha'
                },
                'last_passed_build': None,
            },
        }

        self.assertEqual(
            expected_failures,
            ChromeOSProjectAPI().GetCompileFailures(build, [step]))
コード例 #20
0
 def testInfraStepFromABuildWithCompileFailureNoFailedStep(self):
     compile_step_name = 'install packages|installation results'
     build_id = 8765432109123
     build_number = 123
     output_target1 = json.dumps({
         'category': 'chromeos-base',
         'packageName': 'target1'
     })
     output_target2 = json.dumps({
         'category': 'chromeos-base',
         'packageName': 'target2'
     })
     build = self._CreateBuildbucketBuild(build_id, build_number,
                                          [output_target1, output_target2])
     step = Step()
     step.name = compile_step_name
     log = step.logs.add()
     log.name = 'reason'
     self.assertEqual(StepTypeEnum.INFRA,
                      ChromeOSProjectAPI().ClassifyStepType(build, step))
コード例 #21
0
    def testGetCompileFailures(self):
        step_name = 'install packages'
        build_id = 8765432109123
        build_number = 123
        build = self._CreateBuildbucketBuildForCompile(build_id,
                                                       build_number,
                                                       self.output_targets,
                                                       step_name=step_name)
        step = Step()
        step.name = step_name

        expected_failures = {
            'install packages': {
                'failures': {
                    frozenset(self.output_targets): {
                        'properties': {
                            'rule': 'emerge',
                        },
                        'first_failed_build': {
                            'id': build_id,
                            'number': build_number,
                            'commit_id': 'git_sha',
                        },
                        'last_passed_build': None,
                    },
                },
                'first_failed_build': {
                    'id': build_id,
                    'number': build_number,
                    'commit_id': 'git_sha',
                },
                'last_passed_build': None,
            },
        }

        self.assertEqual(
            expected_failures,
            ChromeOSProjectAPI().GetCompileFailures(build, [step]))
コード例 #22
0
ファイル: projects.py プロジェクト: asdfghjjklllllaaa/infra
        'name': 'chromeos/manifest-internal',
        # No gerrit-host for chromeos project because now Findit only deals with
        # annealing snapshots commits and they don't have code review.
        'gitiles-host': 'chrome-internal.googlesource.com',
        'dependencies': 'placeholder/path/to/the/manifest.xml',
    }
}

# Project related configs.
PROJECT_CFG = {
    'chromium': {
        'project_api': ChromiumProjectAPI(),
        'should_group_failures': False,
    },
    'chromeos': {
        'project_api': ChromeOSProjectAPI(),
        'should_group_failures': True,
    }
}


def GetProjectAPI(project):
    """Gets the project API for the project."""
    return PROJECT_CFG.get(project, {}).get('project_api')


def GetBuilderType(project, bucket, builder_name):
    # Skip builders that are not in the white list of a supported project/bucket.
    bucket_info = LUCI_PROJECTS.get(project, {}).get(bucket, {})
    if not bucket_info:
        logging.info('project: %s, bucket: %s is not supported.' %
コード例 #23
0
    def testGetFailuresWithMatchingCompileFailureGroupsFailureNotExactlySame(
            self):
        build_id = 8000000000122
        build = Build(builder=self.builder, number=122, id=build_id)
        build.input.gitiles_commit.host = 'gitiles.host.com'
        build.input.gitiles_commit.project = 'project/name'
        build.input.gitiles_commit.ref = 'ref/heads/master'
        build.input.gitiles_commit.id = 'git_sha'

        output_target1 = json.dumps({
            'category': 'chromeos-base',
            'packageName': 'target1'
        })
        output_target2 = json.dumps({
            'category': 'chromeos-base',
            'packageName': 'target2'
        })

        last_passed_build_info = {
            'id': 8000000000121,
            'number': 121,
            'commit_id': 'git_sha_121'
        }

        first_failures_in_current_build = {
            'failures': {
                'install packages': {
                    'output_targets':
                    [frozenset([output_target1]),
                     frozenset([output_target2])],
                    'last_passed_build':
                    last_passed_build_info,
                },
            },
            'last_passed_build': last_passed_build_info
        }

        compile_failure = CompileFailure.Create(
            self.group_build.key,
            'install packages', [output_target1],
            'CXX',
            first_failed_build_id=self.group_build_id,
            last_passed_build_id=8000000000160)
        compile_failure.put()

        CompileFailureGroup.Create(
            luci_project=self.context.luci_project_name,
            luci_bucket=build.builder.bucket,
            build_id=self.group_build_id,
            gitiles_host=self.context.gitiles_host,
            gitiles_project=self.context.gitiles_project,
            gitiles_ref=self.context.gitiles_ref,
            last_passed_gitiles_id=last_passed_build_info['commit_id'],
            last_passed_commit_position=654321,
            first_failed_gitiles_id=self.first_failed_commit_id,
            first_failed_commit_position=654340,
            compile_failure_keys=[compile_failure.key]).put()

        self.assertEqual(
            {},
            ChromeOSProjectAPI().GetFailuresWithMatchingCompileFailureGroups(
                self.context, build, first_failures_in_current_build))
コード例 #24
0
 def testGetCompileRerunBuildInputPropertiesOtherStep(self):
     self.assertIsNone(
         ChromeOSProjectAPI().GetCompileRerunBuildInputProperties(
             {}, 8000000000122))
コード例 #25
0
 def testFailureShouldBeAnalyzed(self, failure_entity, result):
     cros_api = ChromeOSProjectAPI()
     self.assertEqual(result,
                      cros_api.FailureShouldBeAnalyzed(failure_entity))
コード例 #26
0
    def testGetRerunBuilderId(self):
        build = Build(builder=self.builder)
        build.output.properties['BISECT_BUILDER'] = 'builder-bisect'

        self.assertEqual('chromeos/postsubmit/builder-bisect',
                         ChromeOSProjectAPI().GetRerunBuilderId(build))