示例#1
0
def ListSwarmingTasksDataByTags(http_client,
                                master_name,
                                builder_name,
                                build_number,
                                step_name=None,
                                additional_tag_filters=None):
    """Downloads tasks data from swarming server.

  Args:
    http_client (RetryHttpClient): The http client to send HTTPs requests.
    master_name (str): Value of the master tag.
    builder_name (str): Value of the buildername tag.
    build_number (int): Value of the buildnumber tag.
    step_name (str): Value of the stepname tag.
    additional_tag_filters (dict): Additional tags.

  Returns:
    (list):  A list of SwarmingTaskData for all tasks with queried tags.
  """
    tag_filters = {
        'master': master_name,
        'buildername': builder_name,
        'buildnumber': build_number
    }
    if step_name:
        tag_filters['stepname'] = step_name

    additional_tag_filters = additional_tag_filters or {}
    tag_filters.update(additional_tag_filters)

    return swarming_util.ListTasks(SwarmingHost(), tag_filters, http_client)
示例#2
0
 def testListTasks(self, mock_fn):
     tags = {'master': 'm', 'buildername': 'b'}
     content1 = {
         'items': [{
             'failure': True,
             'internal_failure': False
         }, {
             'failure': True,
             'internal_failure': False
         }],
         'cursor':
         'cursor'
     }
     content2 = {
         'items': [{
             'failure': True,
             'internal_failure': False
         }, {
             'failure': True,
             'internal_failure': False
         }],
     }
     mock_fn.side_effect = [(json.dumps(content1), None),
                            (json.dumps(content2), None)]
     tasks_data = swarming_util.ListTasks('host', tags, None)
     self.assertTrue(tasks_data[0].non_internal_failure)
示例#3
0
def ListTasks(experiment_id, isolate_hash):
    tag_filter = {'experiment_id': experiment_id + isolate_hash[:4]}
    return [
        i.task_id
        for i in swarming_util.ListTasks(swarming.SwarmingHost(), tag_filter,
                                         FinditHttpClient())
    ]
示例#4
0
 def testListTasksNoItem(self, _):
     tags = {'master': 'm', 'buildername': 'b'}
     self.assertEqual([], swarming_util.ListTasks('host', tags, None))
示例#5
0
 def testListTasksNoNewData(self, mock_fn):
     tags = {'master': 'm', 'buildername': 'b'}
     self.assertEqual([], swarming_util.ListTasks('host', tags, None))
     expected_url = ('https://host/_ah/api/swarming/v1/tasks/list'
                     '?tags=master%3Am&tags=buildername%3Ab')
     mock_fn.assert_called_once_with(expected_url, None)