• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python task_request.make_request函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中server.task_request.make_request函数的典型用法代码示例。如果您正苦于以下问题:Python make_request函数的具体用法?Python make_request怎么用?Python make_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了make_request函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_make_request_parent

 def test_make_request_parent(self):
   parent = task_request.make_request(_gen_request_data())
   # Hack: Would need to know about TaskResultSummary.
   parent_id = task_pack.pack_request_key(parent.key) + '1'
   child = task_request.make_request(
       _gen_request_data(parent_task_id=parent_id))
   self.assertEqual(parent_id, child.parent_task_id)
开发者ID:misscache,项目名称:luci-py,代码行数:7,代码来源:task_request_test.py


示例2: test_make_request_clone

 def test_make_request_clone(self):
   # Compare with test_make_request().
   parent = task_request.make_request(_gen_request_data())
   # Hack: Would need to know about TaskResultSummary.
   parent_id = task_pack.pack_request_key(parent.key) + '1'
   data = _gen_request_data(
       properties=dict(idempotent=True), parent_task_id=parent_id)
   request = task_request.make_request_clone(task_request.make_request(data))
   # Differences from make_request() are:
   # - idempotent was reset to False.
   # - parent_task_id was reset to None.
   expected_properties = {
     'commands': [[u'command1', u'arg1']],
     'data': [
       # Items were sorted.
       [u'http://localhost/bar', u'bar.zip'],
       [u'http://localhost/foo', u'foo.zip'],
     ],
     'dimensions': {u'OS': u'Windows-3.1.1', u'hostname': u'localhost'},
     'env': {u'foo': u'bar', u'joe': u'2'},
     'execution_timeout_secs': 30,
     'extra_args': None,
     'grace_period_secs': 30,
     'idempotent': False,
     'io_timeout_secs': None,
     'isolated': None,
     'isolatedserver': None,
     'namespace': None,
   }
   # Differences from make_request() are:
   # - parent_task_id was reset to None.
   # - tag 'user:' was replaced
   # - user was replaced.
   expected_request = {
     'authenticated': auth_testing.DEFAULT_MOCKED_IDENTITY,
     'name': u'Request name (Retry #1)',
     'parent_task_id': None,
     'priority': 49,
     'properties': expected_properties,
     'properties_hash': None,
     'tags': [
       u'OS:Windows-3.1.1',
       u'hostname:localhost',
       u'priority:49',
       u'tag:1',
       u'user:[email protected]',
     ],
     'user': u'[email protected]',
   }
   actual = request.to_dict()
   # expiration_ts - created_ts == deadline_to_run.
   created = actual.pop('created_ts')
   expiration = actual.pop('expiration_ts')
   self.assertEqual(
       int(round((expiration - created).total_seconds())),
       data['scheduling_expiration_secs'])
   self.assertEqual(expected_request, actual)
   self.assertEqual(
       data['scheduling_expiration_secs'], request.scheduling_expiration_secs)
开发者ID:misscache,项目名称:luci-py,代码行数:59,代码来源:task_request_test.py


示例3: test_new_task_to_run

    def test_new_task_to_run(self):
        self.mock(random, "getrandbits", lambda _: 0x12)
        request_dimensions = {u"OS": u"Windows-3.1.1"}
        data = _gen_request_data(
            properties={
                "commands": [[u"command1", u"arg1"]],
                "data": [[u"http://localhost/foo", u"foo.zip"]],
                "dimensions": request_dimensions,
                "env": {u"foo": u"bar"},
                "execution_timeout_secs": 30,
            },
            priority=20,
            scheduling_expiration_secs=31,
        )
        task_to_run.new_task_to_run(task_request.make_request(data)).put()

        # Create a second with higher priority.
        self.mock(random, "getrandbits", lambda _: 0x23)
        data = _gen_request_data(
            properties={
                "commands": [[u"command1", u"arg1"]],
                "data": [[u"http://localhost/foo", u"foo.zip"]],
                "dimensions": request_dimensions,
                "env": {u"foo": u"bar"},
                "execution_timeout_secs": 30,
            },
            priority=10,
            scheduling_expiration_secs=31,
        )
        task_to_run.new_task_to_run(task_request.make_request(data)).put()

        expected = [
            {
                "dimensions_hash": _hash_dimensions(request_dimensions),
                "expiration_ts": self.now + datetime.timedelta(seconds=31),
                "request_key": "0x7e296460f77ffdce",
                # Lower priority value means higher priority.
                "queue_number": "0x00060dc5849f1346",
            },
            {
                "dimensions_hash": _hash_dimensions(request_dimensions),
                "expiration_ts": self.now + datetime.timedelta(seconds=31),
                "request_key": "0x7e296460f77ffede",
                "queue_number": "0x00072c96fd65d346",
            },
        ]

        def flatten(i):
            out = _task_to_run_to_dict(i)
            out["request_key"] = "0x%016x" % i.request_key.integer_id()
            return out

        # Warning: Ordering by key doesn't work because of TaskToRunShard; e.g.
        # the entity key ordering DOES NOT correlate with .queue_number
        # Ensure they come out in expected order.
        q = task_to_run.TaskToRun.query().order(task_to_run.TaskToRun.queue_number)
        self.assertEqual(expected, map(flatten, q.fetch()))
开发者ID:misscache,项目名称:luci-py,代码行数:57,代码来源:task_to_run_test.py


示例4: test_different

 def test_different(self):
     # Two TestRequest with different properties.
     request_1 = task_request.make_request(
         _gen_request(properties=dict(execution_timeout_secs=30, idempotent=True)), True
     )
     request_2 = task_request.make_request(
         _gen_request(properties=dict(execution_timeout_secs=129, idempotent=True)), True
     )
     self.assertNotEqual(request_1.properties.properties_hash, request_2.properties.properties_hash)
开发者ID:rmistry,项目名称:luci-py,代码行数:9,代码来源:task_request_test.py


示例5: test_new_task_to_run

  def test_new_task_to_run(self):
    self.mock(random, 'getrandbits', lambda _: 0x12)
    request_dimensions = {u'OS': u'Windows-3.1.1', u'pool': u'default'}
    now = utils.utcnow()
    data = _gen_request(
        properties={
          'command': [u'command1', u'arg1'],
          'dimensions': request_dimensions,
          'env': {u'foo': u'bar'},
          'execution_timeout_secs': 30,
        },
        priority=20,
        created_ts=now,
        expiration_ts=now+datetime.timedelta(seconds=31))
    task_to_run.new_task_to_run(task_request.make_request(data, True)).put()

    # Create a second with higher priority.
    self.mock(random, 'getrandbits', lambda _: 0x23)
    data = _gen_request(
        properties={
          'command': [u'command1', u'arg1'],
          'dimensions': request_dimensions,
          'env': {u'foo': u'bar'},
          'execution_timeout_secs': 30,
        },
        priority=10,
        created_ts=now,
        expiration_ts=now+datetime.timedelta(seconds=31))
    task_to_run.new_task_to_run(task_request.make_request(data, True)).put()

    expected = [
      {
        'dimensions_hash': _hash_dimensions(request_dimensions),
        'expiration_ts': self.now + datetime.timedelta(seconds=31),
        'request_key': '0x7e296460f77ffdce',
        # Lower priority value means higher priority.
        'queue_number': '0x00060dc5849f1346',
      },
      {
        'dimensions_hash': _hash_dimensions(request_dimensions),
        'expiration_ts': self.now + datetime.timedelta(seconds=31),
        'request_key': '0x7e296460f77ffede',
        'queue_number': '0x00072c96fd65d346',
      },
    ]

    def flatten(i):
      out = _task_to_run_to_dict(i)
      out['request_key'] = '0x%016x' % i.request_key.integer_id()
      return out

    # Warning: Ordering by key doesn't work because of TaskToRunShard; e.g.
    # the entity key ordering DOES NOT correlate with .queue_number
    # Ensure they come out in expected order.
    q = task_to_run.TaskToRun.query().order(task_to_run.TaskToRun.queue_number)
    self.assertEqual(expected, map(flatten, q.fetch()))
开发者ID:mellowdistrict,项目名称:luci-py,代码行数:56,代码来源:task_to_run_test.py


示例6: test_make_request_isolated

 def test_make_request_isolated(self):
   parent = task_request.make_request(
       _gen_request(
           properties={
             'commands': None,
             'data': None,
             'inputs_ref': {
               'isolated': '0123456789012345678901234567890123456789',
               'isolatedserver': 'http://localhost:1',
               'namespace': 'default-gzip',
             },
           }),
       True)
   # Hack: Would need to know about TaskResultSummary.
   parent_id = task_pack.pack_request_key(parent.key) + '1'
   request = task_request.make_request(
       _gen_request(properties={'idempotent':True}, parent_task_id=parent_id),
       True)
   expected_properties = {
     'commands': [[u'command1', u'arg1']],
     'data': [
       # Items were sorted.
       [u'http://localhost/bar', u'bar.zip'],
       [u'http://localhost/foo', u'foo.zip'],
     ],
     'dimensions': {u'OS': u'Windows-3.1.1', u'hostname': u'localhost'},
     'env': {u'foo': u'bar', u'joe': u'2'},
     'extra_args': [],
     'execution_timeout_secs': 30,
     'grace_period_secs': 30,
     'idempotent': True,
     'inputs_ref': None,
     'io_timeout_secs': None,
   }
   expected_request = {
     'authenticated': auth_testing.DEFAULT_MOCKED_IDENTITY,
     'name': u'Request name',
     'parent_task_id': unicode(parent_id),
     'priority': 49,
     'properties': expected_properties,
     'properties_hash': 'b45f6f868f9227c3035cd82b4a5b0360f5ce6f61',
     'tags': [
       u'OS:Windows-3.1.1',
       u'hostname:localhost',
       u'priority:49',
       u'tag:1',
       u'user:Jesus',
     ],
     'user': u'Jesus',
   }
   actual = request.to_dict()
   # expiration_ts - created_ts == scheduling_expiration_secs.
   actual.pop('created_ts')
   actual.pop('expiration_ts')
   self.assertEqual(expected_request, actual)
   self.assertEqual(30, request.expiration_secs)
开发者ID:eakuefner,项目名称:luci-py,代码行数:56,代码来源:task_request_test.py


示例7: test_make_request_isolated

 def test_make_request_isolated(self):
     parent = task_request.make_request(
         _gen_request(
             properties={
                 "commands": None,
                 "data": None,
                 "inputs_ref": {
                     "isolated": "0123456789012345678901234567890123456789",
                     "isolatedserver": "http://localhost:1",
                     "namespace": "default-gzip",
                 },
             }
         ),
         True,
     )
     # Hack: Would need to know about TaskResultSummary.
     parent_id = task_pack.pack_request_key(parent.key) + "1"
     request = task_request.make_request(
         _gen_request(properties={"idempotent": True}, parent_task_id=parent_id), True
     )
     expected_properties = {
         "commands": [[u"command1", u"arg1"]],
         "data": [
             # Items were sorted.
             [u"http://localhost/bar", u"bar.zip"],
             [u"http://localhost/foo", u"foo.zip"],
         ],
         "dimensions": {u"OS": u"Windows-3.1.1", u"hostname": u"localhost"},
         "env": {u"foo": u"bar", u"joe": u"2"},
         "extra_args": [],
         "execution_timeout_secs": 30,
         "grace_period_secs": 30,
         "idempotent": True,
         "inputs_ref": None,
         "io_timeout_secs": None,
     }
     expected_request = {
         "authenticated": auth_testing.DEFAULT_MOCKED_IDENTITY,
         "name": u"Request name",
         "parent_task_id": unicode(parent_id),
         "priority": 49,
         "properties": expected_properties,
         "properties_hash": "b45f6f868f9227c3035cd82b4a5b0360f5ce6f61",
         "pubsub_topic": None,
         "pubsub_userdata": None,
         "tags": [u"OS:Windows-3.1.1", u"hostname:localhost", u"priority:49", u"tag:1", u"user:Jesus"],
         "user": u"Jesus",
     }
     actual = request.to_dict()
     # expiration_ts - created_ts == scheduling_expiration_secs.
     actual.pop("created_ts")
     actual.pop("expiration_ts")
     self.assertEqual(expected_request, actual)
     self.assertEqual(30, request.expiration_secs)
开发者ID:rmistry,项目名称:luci-py,代码行数:54,代码来源:task_request_test.py


示例8: test_make_request

 def test_make_request(self):
   # Compare with test_make_request_clone().
   parent = task_request.make_request(_gen_request_data())
   # Hack: Would need to know about TaskResultSummary.
   parent_id = task_pack.pack_request_key(parent.key) + '1'
   data = _gen_request_data(
       properties=dict(idempotent=True), parent_task_id=parent_id)
   request = task_request.make_request(data)
   expected_properties = {
     'commands': [[u'command1', u'arg1']],
     'data': [
       # Items were sorted.
       [u'http://localhost/bar', u'bar.zip'],
       [u'http://localhost/foo', u'foo.zip'],
     ],
     'dimensions': {u'OS': u'Windows-3.1.1', u'hostname': u'localhost'},
     'env': {u'foo': u'bar', u'joe': u'2'},
     'extra_args': None,
     'execution_timeout_secs': 30,
     'grace_period_secs': 30,
     'idempotent': True,
     'io_timeout_secs': None,
     'isolated': None,
     'isolatedserver': None,
     'namespace': None,
   }
   expected_request = {
     'authenticated': auth_testing.DEFAULT_MOCKED_IDENTITY,
     'name': u'Request name',
     'parent_task_id': unicode(parent_id),
     'priority': 49,
     'properties': expected_properties,
     'properties_hash': 'e7276ca9999756de386d26d39ae648e641ae1eac',
     'tags': [
       u'OS:Windows-3.1.1',
       u'hostname:localhost',
       u'priority:49',
       u'tag:1',
       u'user:Jesus',
     ],
     'user': u'Jesus',
   }
   actual = request.to_dict()
   # expiration_ts - created_ts == scheduling_expiration_secs.
   created = actual.pop('created_ts')
   expiration = actual.pop('expiration_ts')
   self.assertEqual(
       int(round((expiration - created).total_seconds())),
       data['scheduling_expiration_secs'])
   self.assertEqual(expected_request, actual)
   self.assertEqual(
       data['scheduling_expiration_secs'], request.scheduling_expiration_secs)
开发者ID:misscache,项目名称:luci-py,代码行数:52,代码来源:task_request_test.py


示例9: test_duped

 def test_duped(self):
   # Two TestRequest with the same properties.
   request_1 = task_request.make_request(
       _gen_request_data(properties=dict(idempotent=True)))
   request_2 = task_request.make_request(
       _gen_request_data(
           name='Other', user='Other', priority=201,
           scheduling_expiration_secs=129, tags=['tag:2'],
           properties=dict(idempotent=True)))
   self.assertEqual(
       request_1.properties.properties_hash,
       request_2.properties.properties_hash)
   self.assertTrue(request_1.properties.properties_hash)
开发者ID:misscache,项目名称:luci-py,代码行数:13,代码来源:task_request_test.py


示例10: test_make_request_clone

 def test_make_request_clone(self):
     # Compare with test_make_request().
     parent = task_request.make_request(_gen_request(), True)
     # Hack: Would need to know about TaskResultSummary.
     parent_id = task_pack.pack_request_key(parent.key) + "1"
     data = _gen_request(properties=dict(idempotent=True), parent_task_id=parent_id)
     request = task_request.make_request_clone(task_request.make_request(data, True))
     # Differences from make_request() are:
     # - idempotent was reset to False.
     # - parent_task_id was reset to None.
     expected_properties = {
         "commands": [[u"command1", u"arg1"]],
         "data": [
             # Items were sorted.
             [u"http://localhost/bar", u"bar.zip"],
             [u"http://localhost/foo", u"foo.zip"],
         ],
         "dimensions": {u"OS": u"Windows-3.1.1", u"hostname": u"localhost"},
         "env": {u"foo": u"bar", u"joe": u"2"},
         "execution_timeout_secs": 30,
         "extra_args": [],
         "grace_period_secs": 30,
         "idempotent": False,
         "inputs_ref": None,
         "io_timeout_secs": None,
     }
     # Differences from make_request() are:
     # - parent_task_id was reset to None.
     # - tag 'user:' was replaced
     # - user was replaced.
     expected_request = {
         "authenticated": auth_testing.DEFAULT_MOCKED_IDENTITY,
         "name": u"Request name (Retry #1)",
         "parent_task_id": None,
         "priority": 49,
         "properties": expected_properties,
         "properties_hash": None,
         "pubsub_topic": None,
         "pubsub_userdata": None,
         "tags": [u"OS:Windows-3.1.1", u"hostname:localhost", u"priority:49", u"tag:1", u"user:[email protected]"],
         "user": u"[email protected]",
     }
     actual = request.to_dict()
     # expiration_ts - created_ts == deadline_to_run.
     actual.pop("created_ts")
     actual.pop("expiration_ts")
     self.assertEqual(expected_request, actual)
     self.assertEqual(30, request.expiration_secs)
开发者ID:rmistry,项目名称:luci-py,代码行数:48,代码来源:task_request_test.py


示例11: test_request_to_task_to_run_key

 def test_request_to_task_to_run_key(self):
   self.mock(random, 'getrandbits', lambda _: 0x88)
   request = task_request.make_request(_gen_request(), True)
   # Ensures that the hash value is constant for the same input.
   self.assertEqual(
       ndb.Key('TaskRequest', 0x7e296460f77ff77e, 'TaskToRun', 3420117132),
       task_to_run.request_to_task_to_run_key(request))
开发者ID:mellowdistrict,项目名称:luci-py,代码行数:7,代码来源:task_to_run_test.py


示例12: new

  def new(self, request):
    """Creates a new task.

    The task will be enqueued in the tasks list and will be executed at the
    earliest opportunity by a bot that has at least the dimensions as described
    in the task request.
    """
    logging.info('%s', request)
    try:
      request = message_conversion.new_task_request_from_rpc(
          request, utils.utcnow())
      posted_request = task_request.make_request(request, acl.is_bot_or_admin())
    except (datastore_errors.BadValueError, TypeError, ValueError) as e:
      raise endpoints.BadRequestException(e.message)

    result_summary = task_scheduler.schedule_request(posted_request)

    previous_result = None
    if result_summary.deduped_from:
      previous_result = message_conversion.task_result_to_rpc(result_summary)

    return swarming_rpcs.TaskRequestMetadata(
        request=message_conversion.task_request_to_rpc(posted_request),
        task_id=task_pack.pack_result_summary_key(result_summary.key),
        task_result=previous_result)
开发者ID:rmistry,项目名称:luci-py,代码行数:25,代码来源:handlers_endpoints.py


示例13: test_bot_kill_task

  def test_bot_kill_task(self):
    self.mock(random, 'getrandbits', lambda _: 0x88)
    dimensions = {u'OS': u'Windows-3.1.1'}
    request = task_request.make_request(
        _gen_request(properties={'dimensions': dimensions}), True)
    result_summary = task_scheduler.schedule_request(request)
    reaped_request, run_result = task_scheduler.bot_reap_task(
        {'OS': 'Windows-3.1.1'}, 'localhost', 'abc')

    self.assertEqual(
        None, task_scheduler.bot_kill_task(run_result.key, 'localhost'))
    expected = {
      'abandoned_ts': self.now,
      'bot_dimensions': dimensions,
      'bot_id': u'localhost',
      'bot_version': u'abc',
      'children_task_ids': [],
      'completed_ts': None,
      'costs_usd': [0.],
      'cost_saved_usd': None,
      'created_ts': self.now,
      'deduped_from': None,
      'durations': [],
      'exit_codes': [],
      'failure': False,
      'id': '1d69b9f088008810',
      'internal_failure': True,
      'modified_ts': self.now,
      'name': u'Request name',
      'outputs_ref': None,
      'properties_hash': None,
      'server_versions': [u'v1a'],
      'started_ts': self.now,
      'state': State.BOT_DIED,
      'tags': [u'OS:Windows-3.1.1', u'priority:50', u'tag:1', u'user:Jesus'],
      'try_number': 1,
      'user': u'Jesus',
    }
    self.assertEqual(expected, result_summary.key.get().to_dict())
    expected = {
      'abandoned_ts': self.now,
      'bot_dimensions': dimensions,
      'bot_id': u'localhost',
      'bot_version': u'abc',
      'children_task_ids': [],
      'completed_ts': None,
      'cost_usd': 0.,
      'durations': [],
      'exit_codes': [],
      'failure': False,
      'id': '1d69b9f088008811',
      'internal_failure': True,
      'modified_ts': self.now,
      'outputs_ref': None,
      'server_versions': [u'v1a'],
      'started_ts': self.now,
      'state': State.BOT_DIED,
      'try_number': 1,
    }
    self.assertEqual(expected, run_result.key.get().to_dict())
开发者ID:maruel,项目名称:luci-py,代码行数:60,代码来源:task_scheduler_test.py


示例14: test_request_to_task_to_run_key

 def test_request_to_task_to_run_key(self):
     self.mock(random, "getrandbits", lambda _: 0x88)
     request = task_request.make_request(_gen_request_data())
     self.assertEqual(
         ndb.Key("TaskRequest", 0x7E296460F77FF77E, "TaskToRun", 2471203225),
         task_to_run.request_to_task_to_run_key(request),
     )
开发者ID:misscache,项目名称:luci-py,代码行数:7,代码来源:task_to_run_test.py


示例15: test_set_from_run_result_two_tries

  def test_set_from_run_result_two_tries(self):
    request = task_request.make_request(_gen_request(), True)
    result_summary = task_result.new_result_summary(request)
    run_result_1 = task_result.new_run_result(
        request, 1, 'localhost', 'abc', {})
    run_result_2 = task_result.new_run_result(
        request, 2, 'localhost', 'abc', {})
    self.assertTrue(result_summary.need_update_from_run_result(run_result_1))
    run_result_2.modified_ts = utils.utcnow()
    result_summary.modified_ts = utils.utcnow()
    ndb.transaction(lambda: ndb.put_multi((result_summary, run_result_2)))

    self.assertTrue(result_summary.need_update_from_run_result(run_result_1))
    run_result_1.modified_ts = utils.utcnow()
    result_summary.set_from_run_result(run_result_1, request)
    ndb.transaction(lambda: ndb.put_multi((result_summary, run_result_1)))

    result_summary = result_summary.key.get()
    self.assertFalse(result_summary.need_update_from_run_result(run_result_1))

    self.assertTrue(result_summary.need_update_from_run_result(run_result_2))
    run_result_2.modified_ts = utils.utcnow()
    result_summary.set_from_run_result(run_result_2, request)
    ndb.transaction(lambda: ndb.put_multi((result_summary, run_result_2)))
    result_summary = result_summary.key.get()

    self.assertEqual(2, result_summary.try_number)
    self.assertFalse(result_summary.need_update_from_run_result(run_result_1))
开发者ID:rmistry,项目名称:luci-py,代码行数:28,代码来源:task_result_test.py


示例16: test_new_run_result

 def test_new_run_result(self):
   request = task_request.make_request(_gen_request(), True)
   actual = task_result.new_run_result(
       request, 1, 'localhost', 'abc',
       {'id': ['localhost'], 'foo': ['bar', 'biz']})
   expected = {
     'abandoned_ts': None,
     'bot_dimensions': {'id': ['localhost'], 'foo': ['bar', 'biz']},
     'bot_id': 'localhost',
     'bot_version': 'abc',
     'children_task_ids': [],
     'completed_ts': None,
     'cost_usd': 0.,
     'durations': [],
     'exit_codes': [],
     'failure': False,
     'id': '1d69b9f088008811',
     'internal_failure': False,
     'modified_ts': None,
     'outputs_ref': None,
     'server_versions': ['v1a'],
     'started_ts': self.now,
     'state': task_result.State.RUNNING,
     'try_number': 1,
   }
   self.assertEqual(expected, actual.to_dict())
   self.assertEqual(50, actual.priority)
   self.assertEqual(False, actual.can_be_canceled)
开发者ID:rmistry,项目名称:luci-py,代码行数:28,代码来源:task_result_test.py


示例17: test_cron_abort_expired_task_to_run

 def test_cron_abort_expired_task_to_run(self):
   self.mock(random, 'getrandbits', lambda _: 0x88)
   data = _gen_request_data(
       properties=dict(dimensions={u'OS': u'Windows-3.1.1'}))
   request = task_request.make_request(data)
   result_summary = task_scheduler.schedule_request(request)
   abandoned_ts = self.mock_now(self.now, data['scheduling_expiration_secs']+1)
   self.assertEqual(1, task_scheduler.cron_abort_expired_task_to_run())
   self.assertEqual([], task_result.TaskRunResult.query().fetch())
   expected = {
     'abandoned_ts': abandoned_ts,
     'bot_id': None,
     'bot_version': None,
     'children_task_ids': [],
     'completed_ts': None,
     'costs_usd': [],
     'cost_saved_usd': None,
     'created_ts': self.now,
     'deduped_from': None,
     'durations': [],
     'exit_codes': [],
     'failure': False,
     'id': '1d69b9f088008810',
     'internal_failure': False,
     'modified_ts': abandoned_ts,
     'name': u'Request name',
     'properties_hash': None,
     'server_versions': [],
     'started_ts': None,
     'state': task_result.State.EXPIRED,
     'try_number': None,
     'user': u'Jesus',
   }
   self.assertEqual(expected, result_summary.key.get().to_dict())
开发者ID:nodirt,项目名称:luci-py,代码行数:34,代码来源:task_scheduler_test.py


示例18: test_bot_update_pubsub_error

  def test_bot_update_pubsub_error(self):
    data = _gen_request(
        properties=dict(dimensions={u'OS': u'Windows-3.1.1'}),
        pubsub_topic='projects/abc/topics/def')
    request = task_request.make_request(data, True)
    task_scheduler.schedule_request(request)
    bot_dimensions = {
      u'OS': [u'Windows', u'Windows-3.1.1'],
      u'hostname': u'localhost',
      u'foo': u'bar',
    }
    _, run_result = task_scheduler.bot_reap_task(
        bot_dimensions, 'localhost', 'abc')
    self.assertEqual('localhost', run_result.bot_id)

    # Attempt to terminate the task with success, but make PubSub call fail.
    self.mock_pub_sub(publish_successful=False)
    self.assertEqual(
        (False, False),
        task_scheduler.bot_update_task(
            run_result.key, 'localhost', 'Foo1', 0, 0, 0.1, False, False,
            0.1, None))

    # Bot retries bot_update, now PubSub works and notification is sent.
    pub_sub_calls = self.mock_pub_sub(publish_successful=True)
    self.assertEqual(
        (True, True),
        task_scheduler.bot_update_task(
            run_result.key, 'localhost', 'Foo1', 0, 0, 0.1, False, False,
            0.1, None))
    self.assertEqual(1, len(pub_sub_calls)) # notification is sent
开发者ID:rmistry,项目名称:luci-py,代码行数:31,代码来源:task_scheduler_test.py


示例19: test_new_run_result

 def test_new_run_result(self):
     request = task_request.make_request(_gen_request(), True)
     actual = task_result.new_run_result(
         request, 1, "localhost", "abc", {"id": ["localhost"], "foo": ["bar", "biz"]}
     )
     expected = {
         "abandoned_ts": None,
         "bot_dimensions": {"id": ["localhost"], "foo": ["bar", "biz"]},
         "bot_id": "localhost",
         "bot_version": "abc",
         "children_task_ids": [],
         "completed_ts": None,
         "cost_usd": 0.0,
         "durations": [],
         "exit_codes": [],
         "failure": False,
         "id": "1d69b9f088008811",
         "internal_failure": False,
         "modified_ts": None,
         "outputs_ref": None,
         "server_versions": ["v1a"],
         "started_ts": self.now,
         "state": task_result.State.RUNNING,
         "try_number": 1,
     }
     self.assertEqual(expected, actual.to_dict())
     self.assertEqual(50, actual.priority)
     self.assertEqual(False, actual.can_be_canceled)
开发者ID:eakuefner,项目名称:luci-py,代码行数:28,代码来源:task_result_test.py


示例20: test_task_parent_isolated

  def test_task_parent_isolated(self):
    request = task_request.make_request(
        _gen_request(
            properties={
              'commands': None,
              'dimensions': {u'OS': u'Windows-3.1.1'},
              'inputs_ref': {
                'isolated': '1' * 40,
                'isolatedserver': 'http://localhost:1',
                'namespace': 'default-gzip',
              },
            }),
        True)
    _result_summary = task_scheduler.schedule_request(request)
    bot_dimensions = {
      u'OS': [u'Windows', u'Windows-3.1.1'],
      u'hostname': u'localhost',
      u'foo': u'bar',
    }
    actual_request, run_result = task_scheduler.bot_reap_task(
        bot_dimensions, 'localhost', 'abc')
    self.assertEqual(request, actual_request)
    self.assertEqual('localhost', run_result.bot_id)
    self.assertEqual(None, task_to_run.TaskToRun.query().get().queue_number)
    # It's important to terminate the task with success.
    self.assertEqual(
        (True, True),
        task_scheduler.bot_update_task(
            run_result.key, 'localhost', 'Foo1', 0, 0, 0.1, False, False,
            0.1, None))

    parent_id = run_result.task_id
    request = task_request.make_request(
        _gen_request(
            parent_task_id=parent_id,
            properties={'dimensions':{u'OS': u'Windows-3.1.1'}}),
        True)
    result_summary = task_scheduler.schedule_request(request)
    self.assertEqual([], result_summary.children_task_ids)
    self.assertEqual(parent_id, request.parent_task_id)

    parent_run_result_key = task_pack.unpack_run_result_key(parent_id)
    parent_res_summary_key = task_pack.run_result_key_to_result_summary_key(
        parent_run_result_key)
    expected = [result_summary.task_id]
    self.assertEqual(expected, parent_run_result_key.get().children_task_ids)
    self.assertEqual(expected, parent_res_summary_key.get().children_task_ids)
开发者ID:rmistry,项目名称:luci-py,代码行数:47,代码来源:task_scheduler_test.py



注:本文中的server.task_request.make_request函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python task_scheduler.bot_reap_task函数代码示例发布时间:2022-05-27
下一篇:
Python server.Server类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap