コード例 #1
0
    def testBuilderNameMap(self):
        # TODO(dtu): Remove 6 months after LUCI migration is complete.
        isolate_infos = (('android_arm64-builder-perf', change_test.Change(1),
                          'target_name', 'https://isolate.server',
                          'abcd1234'), )
        isolate.Put(isolate_infos)

        isolate_server, isolate_hash = isolate.Get(
            'Android arm64 Compile Perf', change_test.Change(1), 'target_name')
        self.assertEqual(isolate_server, 'https://isolate.server')
        self.assertEqual(isolate_hash, 'abcd1234')

        with self.assertRaises(KeyError):
            isolate.Get('Android arm64 Compile Perf', change_test.Change(2),
                        'target_name')
コード例 #2
0
ファイル: isolate.py プロジェクト: zmcreynolds4/catapult
  def get(self):
    """Look up an isolate hash.

    Args:
      builder_name: The name of the builder that produced the isolate.
      change: The Change the isolate is for, as a JSON string.
      target: The isolate target.
    """
    # Get parameters.
    parameters = (
        ('builder_name', str),
        ('change', lambda x: change_module.Change.FromDict(json.loads(x))),
        ('target', str),
    )
    try:
      # pylint: disable=unbalanced-tuple-unpacking
      builder_name, change, target = self._ValidateParameters(parameters)
    except (KeyError, TypeError, ValueError) as e:
      self.response.set_status(400)
      self.response.write(e)
      return

    # Get.
    try:
      isolate_server, isolate_hash = isolate.Get(builder_name, change, target)
    except KeyError as e:
      self.response.set_status(404)
      self.response.write(e)
      return

    self.response.write(json.dumps({
        'isolate_server': isolate_server,
        'isolate_hash': isolate_hash,
    }))
コード例 #3
0
ファイル: find_isolate.py プロジェクト: itayvallach/catapult
  def _CheckBuildStatus(self):
    """Checks on the status of a previously requested build.

    Raises:
      BuildError: The build failed, was canceled, or didn't produce an isolate.
    """
    build = buildbucket_service.GetJobStatus(self._build)['build']

    self._build_url = build.get('url')

    if build['status'] != 'COMPLETED':
      return

    if build['result'] == 'FAILURE':
      raise BuildError('Build failed: ' + build['failure_reason'])
    elif build['result'] == 'CANCELED':
      raise BuildError('Build was canceled: ' + build['cancelation_reason'])
    else:
      if self._CheckCompleted():
        return
      logging.debug('Debugging info for chromium:882573')
      try:
        logging.debug(isolate.Get(
            self._builder_name, self._change, self._target))
      except KeyError:
        logging.debug('Isolate not found.')
      logging.debug(build)
      logging.debug(self._builder_name)
      logging.debug(self._change)
      logging.debug(self._target)
      raise IsolateNotFoundError(
          'Buildbucket says the build completed successfully, '
          "but Pinpoint can't find the isolate hash.")
コード例 #4
0
ファイル: isolate_test.py プロジェクト: wanghui0720/catapult
    def testPutAndGet(self):
        isolate.Put(
            (('Mac Builder', 'f9f2b720', 'telemetry_perf', '7c7e90be'),
             ('Mac Builder', 'f35be4f1', 'telemetry_perf', '38e2f262')))

        isolate_hash = isolate.Get('Mac Builder', 'f9f2b720', 'telemetry_perf')
        self.assertEqual(isolate_hash, '7c7e90be')
コード例 #5
0
  def testPutAndGet(self):
    isolate.Put((
        ('Mac Builder', _CHANGE_1, 'telemetry_perf', '7c7e90be'),
        ('Mac Builder', _CHANGE_2, 'telemetry_perf', '38e2f262')))

    isolate_hash = isolate.Get('Mac Builder', _CHANGE_1, 'telemetry_perf')
    self.assertEqual(isolate_hash, '7c7e90be')
コード例 #6
0
    def testOldKey(self):
        i = isolate.Isolate(
            isolate_hash='7c7e90be',
            id=
            '3476dfea796ba01b966d08b090fff6b2ad18c8c0f1e7c91bd1f1be0f8c299050')
        i.put()

        isolate_hash = isolate.Get('Mac Builder Perf', _CHANGE_1,
                                   'telemetry_perf')
        self.assertEqual(isolate_hash, '7c7e90be')
コード例 #7
0
ファイル: isolate_test.py プロジェクト: weinvest/catapult
    def testPutAndGet(self):
        isolate_infos = (
            ('Mac Builder Perf', _CHANGE_1, 'telemetry_perf', '7c7e90be'),
            ('Mac Builder Perf', _CHANGE_2, 'telemetry_perf', '38e2f262'),
        )
        isolate.Put('https://isolate.server', isolate_infos)

        isolate_server, isolate_hash = isolate.Get('Mac Builder Perf',
                                                   _CHANGE_1, 'telemetry_perf')
        self.assertEqual(isolate_server, 'https://isolate.server')
        self.assertEqual(isolate_hash, '7c7e90be')
コード例 #8
0
ファイル: isolate_test.py プロジェクト: swaroopcs88/catapult
  def testPutAndGet(self):
    isolate_infos = (
        ('Mac Builder Perf', change_test.Change(1), 'target_name', '7c7e90be'),
        ('Mac Builder Perf', change_test.Change(2), 'target_name', '38e2f262'),
    )
    isolate.Put('https://isolate.server', isolate_infos)

    isolate_server, isolate_hash = isolate.Get(
        'Mac Builder Perf', change_test.Change(1), 'target_name')
    self.assertEqual(isolate_server, 'https://isolate.server')
    self.assertEqual(isolate_hash, '7c7e90be')
コード例 #9
0
ファイル: find_isolate.py プロジェクト: youngjae24/catapult
  def _CheckCompleted(self):
    """Checks the isolate cache to see if a build is already available.

    Returns:
      True iff the isolate was found, meaning the execution is completed.
    """
    try:
      isolate_hash = isolate.Get(self._builder_name, self._change, self._target)
    except KeyError:
      return False
    self._Complete(result_arguments={'isolate_hash': isolate_hash})
    return True
コード例 #10
0
    def testExpiredIsolate(self, mock_datetime):
        isolate_infos = (('Mac Builder Perf', change_test.Change(1),
                          'target_name', 'https://isolate.server',
                          '7c7e90be'), )
        isolate.Put(isolate_infos)

        # Teleport to the future after the isolate is expired.
        mock_datetime.datetime.now.return_value = (
            datetime.datetime.now() + isolate.ISOLATE_EXPIRY_DURATION +
            datetime.timedelta(days=1))
        mock_datetime.timedelta = datetime.timedelta

        with self.assertRaises(KeyError):
            isolate.Get('Mac Builder Perf', change_test.Change(1),
                        'target_name')
コード例 #11
0
    def __call__(self, task, _, change):
        if task.status == 'ongoing':
            logging.warning(
                'Ignoring an initiate event on an ongoing task; task = %s',
                task.id)
            return None

        # Outline:
        #   - Check if we can find the isolate for this revision.
        #     - If found, update the payload of the task and update accumulator with
        #       result for this task.
        #     - If not found, schedule a build for this revision, update the task
        #       payload with the build details, wait for updates.
        try:
            change = change_module.Change(commits=[
                commit_module.Commit(c['repository'], c['git_hash'])
                for c in task.payload.get('change', {}).get('commits', [])
            ],
                                          patch=task.payload.get('patch'))
            logging.debug('Looking up isolate for change = %s', change)
            isolate_server, isolate_hash = isolate.Get(
                task.payload.get('builder'), change,
                task.payload.get('target'))
            task.payload.update({
                'isolate_server': isolate_server,
                'isolate_hash': isolate_hash,
            })

            # At this point we've found an isolate from a previous build, so we mark
            # the task 'completed' and allow tasks that depend on the isolate to see
            # this information.
            @task_module.LogStateTransitionFailures
            def CompleteWithCachedIsolate(_):
                task_module.UpdateTask(self.job,
                                       task.id,
                                       new_state='completed',
                                       payload=task.payload)

            return [CompleteWithCachedIsolate]
        except KeyError as e:
            logging.error('Failed to find isolate for task = %s;\nError: %s',
                          task.id, e)
            return [ScheduleBuildAction(self.job, task, change)]
        return None
コード例 #12
0
ファイル: find_isolate.py プロジェクト: JamesLinus/catapult
    def _Poll(self):
        # Look for the .isolate in our cache.
        try:
            isolate_hash = isolate.Get(self._builder_name, self._change,
                                       self._target)
        except KeyError:
            isolate_hash = None

        if isolate_hash:
            self._Complete(result_arguments={'isolate_hash': isolate_hash})
            return

        # Check the status of a previously requested build.
        if self._build:
            status = buildbucket_service.GetJobStatus(self._build)

            if status['build']['status'] != 'COMPLETED':
                return

            if status['build']['result'] == 'FAILURE':
                raise BuildError('Build failed: ' +
                                 status['build']['failure_reason'])
            elif status['build']['result'] == 'CANCELED':
                raise BuildError('Build was canceled: ' +
                                 status['build']['cancelation_reason'])
            else:
                # It's possible for there to be a race condition if the builder uploads
                # the isolate and completes the build between the above isolate lookup
                # and buildbucket lookup, but right now, it takes builds a few minutes
                # to package the build, so that doesn't happen.
                raise BuildError(
                    'Buildbucket says the build completed successfully, '
                    "but Pinpoint can't find the isolate hash.")

        if self._change in self._previous_builds:
            # If another Execution already requested a build, reuse that one.
            self._build = self._previous_builds[self._change]
        else:
            # Request a build!
            buildbucket_info = _RequestBuild(self._builder_name, self._change)
            self._build = buildbucket_info['build']['id']
            self._previous_builds[self._change] = self._build
コード例 #13
0
ファイル: find_isolate.py プロジェクト: bopopescu/catapult-5
  def _CheckIsolateCache(self):
    """Checks the isolate cache to see if a build is already available.

    Returns:
      True iff the isolate was found, meaning the execution is completed.
    """
    try:
      isolate_server, isolate_hash = isolate.Get(
          self._builder_name, self._change, self._target)
    except KeyError:
      logging.debug('NOT found in isolate cache')
      return False

    result_arguments = {
        'isolate_server': isolate_server,
        'isolate_hash': isolate_hash,
    }
    logging.debug('Found in isolate cache: %s', result_arguments)
    self._Complete(result_arguments=result_arguments)
    return True
コード例 #14
0
 def testBuildSucceedsAndIsolateIsCached(self, *_):
   self.testBuildLifecycle()  # pylint: disable=no-value-for-parameter
   cached_isolate = isolate.Get('Mac Builder',
                                change_test.Change(123, 456, patch=True),
                                'telemetry_perf_tests')
   self.assertIsNotNone(cached_isolate)
コード例 #15
0
 def testUnknownIsolate(self):
     with self.assertRaises(KeyError):
         isolate.Get('Wrong Builder', change_test.Change(1), 'target_name')
コード例 #16
0
 def testUnknownIsolate(self):
     with self.assertRaises(KeyError):
         isolate.Get('Wrong Builder', _CHANGE_1, 'telemetry_perf')