Exemplo n.º 1
0
 def testMidpointRaisesWithMultipleDifferingCommits(self):
     change_a = change.Change(change.Dep('chromium/src', '0e57e2b'),
                              (change.Dep('catapult', 'e0a2efb'), ))
     change_b = change.Change(change.Dep('chromium/src', 'babe852'),
                              (change.Dep('catapult', 'bfa19de'), ))
     with self.assertRaises(change.NonLinearError):
         change.Change.Midpoint(change_a, change_b)
Exemplo n.º 2
0
    def testBuildCanceled(self, put, get_job_status):
        change = change_module.Change(
            change_module.Dep('src', 'base git hash'),
            (change_module.Dep('v8', 'dep git hash'), ),
            patch=change_module.Patch('https://example.org', 2565263002,
                                      20001))
        quest = find_isolate.FindIsolate('Mac Pro Perf',
                                         'telemetry_perf_tests')
        execution = quest.Start(change)

        # Request a build.
        put.return_value = {'build': {'id': 'build_id'}}
        execution.Poll()

        # Check build status.
        get_job_status.return_value = {
            'build': {
                'status': 'COMPLETED',
                'result': 'CANCELED',
                'cancelation_reason': 'TIMEOUT',
            }
        }
        execution.Poll()

        self.assertExecutionFailure(execution, find_isolate.BuildError)
Exemplo n.º 3
0
 def testMidpointRaisesWithDifferingPatch(self):
   change_a = change.Change(change.Dep('src', '0e57e2b'))
   change_b = change.Change(
       change.Dep('src', 'babe852'),
       patch=change.Patch('https://codereview.chromium.org', 2565263002, 20001))
   with self.assertRaises(change.NonLinearError):
     change.Change.Midpoint(change_a, change_b)
Exemplo n.º 4
0
  def testMidpointWithDepsRoll(self, commit_range, file_contents):
    def _CommitRange(repository_url, first_git_hash, last_git_hash):
      del repository_url
      if first_git_hash == '0e57e2b' and last_git_hash == 'babe852':
        return [{'commit': 'babe852'}]
      if first_git_hash == '0000000' and last_git_hash == '2222222':
        return [{'commit': '2222222'}, {'commit': '1111111'}]
      raise NotImplementedError()
    commit_range.side_effect = _CommitRange

    def _FileContents(repository_url, git_hash, path):
      del repository_url
      del path
      if git_hash == '0e57e2b':
        return 'deps = {"src/catapult": "%s@0000000"}' % _CATAPULT_URL
      if git_hash == 'babe852':
        return 'deps = {"src/catapult": "%s@2222222"}' % _CATAPULT_URL
      raise NotImplementedError()
    file_contents.side_effect = _FileContents

    change_a = change.Change(change.Dep('src', '0e57e2b'))
    change_b = change.Change(change.Dep('src', 'babe852'))
    expected = change.Change(change.Dep('src', '0e57e2b'),
                             (change.Dep('catapult', '1111111'),))

    self.assertEqual(change.Change.Midpoint(change_a, change_b), expected)
Exemplo n.º 5
0
  def testMidpointRaisesAcrossDepsRollWhenDepAlreadyOverridden(
      self, commit_range, file_contents):
    def _CommitRange(repository_url, first_git_hash, last_git_hash):
      del repository_url
      if first_git_hash == '0e57e2b' and last_git_hash == 'babe852':
        return [{'commit': 'babe852'}]
      if first_git_hash == '1111111' and last_git_hash == '3333333':
        return [{'commit': '3333333'}, {'commit': '2222222'}]
      raise NotImplementedError()
    commit_range.side_effect = _CommitRange

    def _FileContents(repository_url, git_hash, path):
      del repository_url
      del path
      if git_hash == '0e57e2b':
        return 'deps = {"src/catapult": "%s@0000000"}' % _CATAPULT_URL
      if git_hash == 'babe852':
        return 'deps = {"src/catapult": "%s@4444444"}' % _CATAPULT_URL
      raise NotImplementedError()
    file_contents.side_effect = _FileContents

    change_a = change.Change(change.Dep('src', '0e57e2b'),
                             (change.Dep('catapult', '1111111'),))
    change_b = change.Change(change.Dep('src', 'babe852'),
                             (change.Dep('catapult', '3333333'),))

    with self.assertRaises(change.NonLinearError):
      change.Change.Midpoint(change_a, change_b)
Exemplo n.º 6
0
    def testDep(self):
        dep = change.Dep('chromium/src', 'aaa7336')

        self.assertEqual(dep, change.Dep('chromium/src', 'aaa7336'))
        self.assertEqual(str(dep), 'src@aaa7336')
        self.assertEqual(dep.repository, 'chromium/src')
        self.assertEqual(dep.git_hash, 'aaa7336')
Exemplo n.º 7
0
  def testMidpointReturnsNoneWithAdjacentCommitsAndNoDepsRoll(
      self, commit_range, file_contents):
    commit_range.return_value = [{'commit': 'b57345e'}]
    file_contents.return_value = 'deps = {}'

    change_a = change.Change(change.Dep('src', '949b36d'))
    change_b = change.Change(change.Dep('src', 'b57345e'))
    self.assertIsNone(change.Change.Midpoint(change_a, change_b))
Exemplo n.º 8
0
  def testChangeHasMultipleDeps(self):
    base_commit = change_module.Dep('chromium/src', 'f9f2b720')
    deps = (change_module.Dep('r2', 'hash'), change_module.Dep('r3', 'hash'))
    change = change_module.Change(base_commit, deps)
    execution = find_isolated.FindIsolated('Mac Pro Perf').Start(change)
    execution.Poll()

    self.assertExecutionFailure(execution)
Exemplo n.º 9
0
  def testIsolateLookupSuccessWithOneDep(self):
    base_commit = change_module.Dep('src', 'f9f2b720')
    deps = (change_module.Dep('repository 2', 'githash2'),)
    change = change_module.Change(base_commit, deps)
    execution = find_isolated.FindIsolated('Mac Pro Perf').Start(change)
    execution.Poll()

    self.assertExecutionSuccess(execution)
    self.assertEqual(execution.result_arguments, {'isolated_hash': 'isohash2'})
Exemplo n.º 10
0
  def testDep(self):
    dep = change.Dep('src', 'aaa7336')

    self.assertEqual(dep, change.Dep('src', 'aaa7336'))
    self.assertEqual(str(dep), 'src@aaa7336')
    self.assertEqual(dep.repository, 'src')
    self.assertEqual(dep.git_hash, 'aaa7336')
    self.assertEqual(dep.repository_url,
                     'https://chromium.googlesource.com/chromium/src')
Exemplo n.º 11
0
    def testChange(self):
        base_commit = change.Dep('chromium/src', 'aaa7336c')
        dep = change.Dep('external/github.com/catapult-project/catapult',
                         'e0a2efb')
        patch = 'patch/rietveld/codereview.chromium.org/2565263002/20001'

        c = change.Change(base_commit, [dep], patch)

        self.assertEqual(c.base_commit, base_commit)
        self.assertEqual(c.deps, (dep, ))
        self.assertEqual(c.patch, patch)
Exemplo n.º 12
0
  def testDep(self):
    dep = change.Dep('chromium', 'aaa7336c821888839f759c6c0a36b56c6678')

    other_dep = change.Dep(u'chromium', u'aaa7336c821888839f759c6c0a36b56c6678')
    self.assertEqual(dep, other_dep)
    self.assertEqual(str(dep), 'chromium@aaa7336')
    self.assertEqual(dep.id_string,
                     'chromium@aaa7336c821888839f759c6c0a36b56c6678')
    self.assertEqual(dep.repository, 'chromium')
    self.assertEqual(dep.git_hash, 'aaa7336c821888839f759c6c0a36b56c6678')
    self.assertEqual(dep.repository_url,
                     'https://chromium.googlesource.com/chromium/src')
Exemplo n.º 13
0
  def testMidpointSuccess(self, commit_range):
    commit_range.return_value = [
        {'commit': 'babe852'},
        {'commit': 'b57345e'},
        {'commit': '949b36d'},
        {'commit': '1ef4789'},
    ]

    dep_a = change.Dep('src', '0e57e2b')
    dep_b = change.Dep('src', 'babe852')
    self.assertEqual(change.Dep.Midpoint(dep_a, dep_b),
                     change.Dep('src', '949b36d'))
Exemplo n.º 14
0
 def testAsDict(self):
     dep = change.Dep('chromium', 'aaa7336')
     expected = {
         'repository': 'chromium',
         'git_hash': 'aaa7336',
     }
     self.assertEqual(dep.AsDict(), expected)
Exemplo n.º 15
0
  def testFromDictWithAllFields(self, _):
    c = change.Change.FromDict({
        'base_commit': {'repository': 'src', 'git_hash': 'aaa7336'},
        'deps': ({'repository': 'catapult', 'git_hash': 'e0a2efb'},),
        'patch': {
            'server': 'https://codereview.chromium.org',
            'issue': 2565263002,
            'patchset': 20001,
        },
    })

    base_commit = change.Dep('src', 'aaa7336')
    deps = (change.Dep('catapult', 'e0a2efb'),)
    patch = change.Patch('https://codereview.chromium.org', 2565263002, 20001)
    expected = change.Change(base_commit, deps, patch)
    self.assertEqual(c, expected)
Exemplo n.º 16
0
  def testFromDictWithJustBaseCommit(self, _):
    c = change.Change.FromDict({
        'base_commit': {'repository': 'src', 'git_hash': 'aaa7336'},
    })

    expected = change.Change(change.Dep('src', 'aaa7336'))
    self.assertEqual(c, expected)
Exemplo n.º 17
0
  def testChange(self):
    base_commit = change.Dep('src', 'aaa7336')
    dep = change.Dep('catapult', 'e0a2efb')
    patch = change.Patch('https://codereview.chromium.org', 2565263002, 20001)

    # Also test the deps conversion to frozenset.
    c = change.Change(base_commit, [dep], patch)

    self.assertEqual(c, change.Change(base_commit, (dep,), patch))
    string = ('src@aaa7336 catapult@e0a2efb + '
              'https://codereview.chromium.org/2565263002/20001')
    self.assertEqual(str(c), string)
    self.assertEqual(c.base_commit, base_commit)
    self.assertEqual(c.deps, frozenset((dep,)))
    self.assertEqual(c.all_deps, (base_commit, dep))
    self.assertEqual(c.patch, patch)
Exemplo n.º 18
0
  def testSimultaneousBuilds(self, put, get_job_status):
    # Two builds started at the same time on the same Change should reuse the
    # same build request.
    change = change_module.Change(change_module.Dep('src', 'base git hash'))
    quest = find_isolate.FindIsolate('Mac Pro Perf', 'telemetry_perf_tests')
    execution_1 = quest.Start(change)
    execution_2 = quest.Start(change)

    # Request a build.
    put.return_value = {'build': {'id': 'build_id'}}
    execution_1.Poll()
    execution_2.Poll()

    self.assertFalse(execution_1.completed)
    self.assertFalse(execution_2.completed)
    self.assertEqual(put.call_count, 1)

    # Check build status.
    get_job_status.return_value = {'build': {'status': 'STARTED'}}
    execution_1.Poll()
    execution_2.Poll()

    self.assertFalse(execution_1.completed)
    self.assertFalse(execution_2.completed)
    self.assertEqual(get_job_status.call_count, 2)

    # Look up isolate hash.
    isolate.Put((('Mac Builder', change,
                  'telemetry_perf_tests', 'isolate git hash'),))
    execution_1.Poll()
    execution_2.Poll()

    self.assertExecutionSuccess(execution_1)
    self.assertExecutionSuccess(execution_2)
Exemplo n.º 19
0
    def testNoIsolatedAvailable(self):
        change = change_module.Change(
            change_module.Dep('chromium/src', 'bad_hash'))
        execution = find_isolated.FindIsolated('Mac Pro Perf').Start(change)

        execution.Poll()
        self.assertExecutionFailure(execution)
Exemplo n.º 20
0
    def testUnknownBuilder(self):
        change = change_module.Change(
            change_module.Dep('chromium/src', 'f9f2b720'))
        execution = find_isolated.FindIsolated('Unix Perf').Start(change)

        execution.Poll()
        self.assertExecutionFailure(execution)
Exemplo n.º 21
0
  def testIsolateLookupSuccess(self):
    change = change_module.Change(change_module.Dep('chromium/src', 'f9f2b720'))
    execution = find_isolated.FindIsolated('Mac Pro Perf').Start(change)
    execution.Poll()

    self.assertExecutionSuccess(execution)
    self.assertEqual(execution.result_arguments, {'isolated_hash': '7c7e90be'})
Exemplo n.º 22
0
    def post(self):
        # TODO(dtu): Read the parameters from the request object.
        # Not doing it for now because it's easier to run tests this way.
        configuration = 'Mac Pro 10.11 Perf'
        test_suite = 'speedometer'
        test = None
        metric = None
        deps = (
            change.Dep('src', '2c1f8ed028edcb44c954cb2a0625a8f278933481'),
            change.Dep('src', '858ceafc7cf4f11a6549b8c1ace839a45d943d68'),
        )

        # Validate parameters.
        if metric and not test_suite:
            raise ValueError(
                "Specified a metric but there's no test_suite to run.")

        # Validate commit hashes.
        for dep in deps:
            if not dep.Validate():
                raise ValueError('Could not find the commit with Gitiles: %s' %
                                 dep)

        # Convert parameters to canonical internal representation.

        # Create job.
        job = job_module.Job.New(configuration=configuration,
                                 test_suite=test_suite,
                                 test=test,
                                 metric=metric,
                                 auto_explore=True)

        # Add changes.
        for dep in deps:
            job.AddChange(change.Change(dep))

        # Put job into datastore.
        job_id = job.put().urlsafe()

        # Start job.
        job.Start()
        job.put()

        # Show status page.
        # TODO: Should return a JSON result instead. Use Cloud Endpoints.
        self.redirect('/job/' + job_id)
Exemplo n.º 23
0
  def testFromDict(self, _):
    dep = change.Dep.FromDict({
        'repository': 'src',
        'git_hash': 'aaa7336',
    })

    expected = change.Dep('src', 'aaa7336')
    self.assertEqual(dep, expected)
Exemplo n.º 24
0
  def testChange(self):
    base_commit = change.Dep('src', 'aaa7336')
    dep = change.Dep('catapult', 'e0a2efb')
    patch = 'rietveld/codereview.chromium.org/2565263002/20001'

    # Also test the deps conversion to tuple.
    c = change.Change(base_commit, [dep], patch)

    self.assertEqual(c, change.Change(base_commit, (dep,), patch))
    string = ('src@aaa7336 catapult@e0a2efb + '
              'rietveld/codereview.chromium.org/2565263002/20001')
    self.assertEqual(str(c), string)
    self.assertEqual(c.base_commit, base_commit)
    self.assertEqual(c.deps, (dep,))
    self.assertEqual(c.all_deps, (base_commit, dep))
    self.assertEqual(c.most_specific_commit, dep)
    self.assertEqual(c.patch, patch)
Exemplo n.º 25
0
    def testChangeHasPatch(self):
        change = change_module.Change(
            change_module.Dep('chromium/src', 'f9f2b720'),
            patch='patch/rietveld/codereview.chromium.org/2570613003/1')
        execution = find_isolated.FindIsolated('Mac Pro Perf').Start(change)
        execution.Poll()

        self.assertExecutionFailure(execution)
Exemplo n.º 26
0
  def testFromDictWithRepositoryUrl(self, _):
    dep = change.Dep.FromDict({
        'repository': 'https://chromium.googlesource.com/chromium/src',
        'git_hash': 'aaa7336',
    })

    expected = change.Dep('src', 'aaa7336')
    self.assertEqual(dep, expected)
Exemplo n.º 27
0
    def testBuildLifecycle(self, put, get_job_status):
        change = change_module.Change(
            change_module.Dep('src', 'base git hash'),
            (change_module.Dep('v8', 'dep git hash'), ),
            patch=change_module.Patch('https://example.org', 2565263002,
                                      20001))
        quest = find_isolate.FindIsolate('Mac Pro Perf',
                                         'telemetry_perf_tests')
        execution = quest.Start(change)

        # Request a build.
        put.return_value = {'build': {'id': 'build_id'}}
        execution.Poll()

        self.assertFalse(execution.completed)
        put.assert_called_once_with(
            find_isolate.BUCKET, {
                'builder_name': 'Mac Builder',
                'properties': {
                    'clobber': True,
                    'parent_got_revision': 'base git hash',
                    'deps_revision_overrides': {
                        'https://chromium.googlesource.com/v8/v8':
                        'dep git hash',
                    },
                    'patch_storage': 'rietveld',
                    'rietveld': 'https://example.org',
                    'issue': 2565263002,
                    'patchset': 20001,
                }
            })

        # Check build status.
        get_job_status.return_value = {'build': {'status': 'STARTED'}}
        execution.Poll()

        self.assertFalse(execution.completed)
        get_job_status.assert_called_once_with('build_id')

        # Look up isolate hash.
        isolate.Put((('Mac Builder', change, 'telemetry_perf_tests',
                      'isolate git hash'), ))
        execution.Poll()

        self.assertExecutionSuccess(execution)
Exemplo n.º 28
0
  def testChangeHasPatch(self):
    change = change_module.Change(
        change_module.Dep('src', 'f9f2b720'),
        patch=change_module.Patch('https://codereview.chromium.org',
                                  2570613003, 1))
    execution = find_isolated.FindIsolated('Mac Pro Perf').Start(change)
    execution.Poll()

    self.assertExecutionFailure(execution)
Exemplo n.º 29
0
  def testChange(self):
    base_commit = change.Dep('chromium', 'aaa7336c821888839f759c6c0a36b56c6678')
    dep = change.Dep('catapult', 'e0a2efbb3d1a81aac3c90041eefec24f066d26ba')
    patch = change.Patch('https://codereview.chromium.org', 2565263002, 20001)

    # Also test the deps conversion to frozenset.
    c = change.Change(base_commit, [dep], patch)

    self.assertEqual(c, change.Change(base_commit, (dep,), patch))
    string = ('chromium@aaa7336 catapult@e0a2efb + '
              'https://codereview.chromium.org/2565263002/20001')
    id_string = ('chromium@aaa7336c821888839f759c6c0a36b56c6678 '
                 'catapult@e0a2efbb3d1a81aac3c90041eefec24f066d26ba + '
                 'https://codereview.chromium.org/2565263002/20001')
    self.assertEqual(str(c), string)
    self.assertEqual(c.id_string, id_string)
    self.assertEqual(c.base_commit, base_commit)
    self.assertEqual(c.deps, frozenset((dep,)))
    self.assertEqual(c.all_deps, (base_commit, dep))
    self.assertEqual(c.patch, patch)
Exemplo n.º 30
0
    def testBuildSucceededButIsolateIsMissing(self, put, get_job_status):
        change = change_module.Change(
            change_module.Dep('src', 'base git hash'),
            (change_module.Dep('v8', 'dep git hash'), ),
            patch=change_module.Patch('https://example.org', 2565263002,
                                      20001))
        execution = find_isolate.FindIsolate('Mac Pro Perf').Start(change)

        # Request a build.
        put.return_value = {'build': {'id': 'build_id'}}
        execution.Poll()

        # Check build status.
        get_job_status.return_value = {
            'build': {
                'status': 'COMPLETED',
                'result': 'SUCCESS',
            }
        }
        execution.Poll()

        self.assertExecutionFailure(execution, find_isolate.BuildError)