예제 #1
0
  def test_http_500(self):
    net.json_request_async.return_value = future_exception(
        net.Error('internal', 500, 'Internal server error')
    )

    with self.assertRaises(net.Error):
      self._create_task()
예제 #2
0
    def test_http_400(self):
        net.json_request_async.return_value = future_exception(
            net.Error('HTTP 401', 400, 'invalid request'))

        swarming._create_swarming_task(1)

        build = self.build.key.get()
        self.assertEqual(build.status, common_pb2.INFRA_FAILURE)
        self.assertEqual(
            build.proto.summary_markdown,
            r'Swarming task creation API responded with HTTP 400: `invalid request`'
        )
예제 #3
0
    def test_cancel_batch(self, cancel):
        props = {'p': 0}
        build = test_util.build(
            id=1, output=dict(properties=bbutil.dict_to_struct(props)))
        cancel.side_effect = [
            future(build),
            future_exception(errors.BuildIsCompletedError()),
        ]
        req = {
            'build_ids': ['1', '2'],
            'result_details_json': json.dumps(build.result_details),
        }
        res = self.call_api('cancel_batch', req).json_body

        res0 = res['results'][0]
        self.assertEqual(res0['build_id'], '1')
        self.assertEqual(res0['build']['id'], '1')
        cancel.assert_any_call(1, result_details=build.result_details)

        res1 = res['results'][1]
        self.assertEqual(res1['build_id'], '2')
        self.assertEqual(res1['error']['reason'], 'BUILD_IS_COMPLETED')
        cancel.assert_any_call(2, result_details=build.result_details)
예제 #4
0
 def test_get_auth_error(self, get_async):
   get_async.return_value = future_exception(auth.AuthorizationError())
   self.expect_error('get', {'id': 1}, 'BUILD_NOT_FOUND')
예제 #5
0
 def test_put_empty_request(self, add_async):
   add_async.return_value = future_exception(errors.InvalidInputError())
   req = {'bucket': ''}
   self.expect_error('put', req, 'INVALID_INPUT')
예제 #6
0
 def error_test(self, error_class, reason, get_async):
   get_async.return_value = future_exception(error_class(reason))
   self.expect_error('get', {'id': 123}, reason)
예제 #7
0
 def add_async(tag, entries):
     if tag == 'buildset:1':
         return future_exception(Exception('transient error'))
     return orig_add_async(tag, entries)