def test_get_task_status(LINUX_TASK_ID, LINUX_TASK_STATUS): responses.add(responses.GET, 'https://queue.taskcluster.net/v1/task/{}/status'.format( LINUX_TASK_ID), json=LINUX_TASK_STATUS, status=200) assert taskcluster.get_task_status(LINUX_TASK_ID) == LINUX_TASK_STATUS
def download_all(self): os.makedirs(self.parent_dir, exist_ok=True) # The test tasks for the Linux and Windows builds are in the same group, # but the following code is generic and supports build tasks split in # separate groups. groups = set([ taskcluster.get_task_details(build_task_id)['taskGroupId'] for build_task_id in self.task_ids.values() ]) test_tasks = [ task for group in groups for task in taskcluster.get_tasks_in_group(group) if taskcluster.is_coverage_task(task) ] for test_task in test_tasks: status = test_task['status']['state'] while status not in FINISHED_STATUSES: assert status in ALL_STATUSES, "State '{}' not recognized".format( status) logger.info('Waiting for task {} to finish...'.format( test_task['status']['taskId'])) time.sleep(60) status = taskcluster.get_task_status( test_task['status']['taskId']) # Choose best tasks to download (e.g. 'completed' is better than 'failed') download_tasks = {} for test_task in test_tasks: status = test_task['status']['state'] assert status in FINISHED_STATUSES, "State '{}' not recognized".format( status) chunk_name = taskcluster.get_chunk( test_task['task']['metadata']['name']) platform_name = taskcluster.get_platform( test_task['task']['metadata']['name']) # Ignore awsy and talos as they aren't actually suites of tests. if any(to_ignore in chunk_name for to_ignore in self.suites_to_ignore): continue if (chunk_name, platform_name) not in download_tasks: # If the chunk hasn't been downloaded before, this is obviously the best task # to download it from. download_tasks[(chunk_name, platform_name)] = test_task else: # Otherwise, compare the status of this task with the previously selected task. prev_task = download_tasks[(chunk_name, platform_name)] if STATUS_VALUE[status] > STATUS_VALUE[prev_task['status'] ['state']]: download_tasks[(chunk_name, platform_name)] = test_task with ThreadPoolExecutorResult() as executor: for test_task in download_tasks.values(): executor.submit(self.download, test_task) logger.info('Code coverage artifacts downloaded')
def test_get_task_status(mock_taskcluster, LINUX_TASK_ID, LINUX_TASK_STATUS): responses.add( responses.GET, f"http://taskcluster.test/api/queue/v1/task/{LINUX_TASK_ID}/status", json=LINUX_TASK_STATUS, status=200, ) assert taskcluster.get_task_status(LINUX_TASK_ID) == LINUX_TASK_STATUS
def test_get_task_status(LINUX_TASK_ID, LINUX_TASK_STATUS): responses.add( responses.GET, f"https://queue.taskcluster.net/v1/task/{LINUX_TASK_ID}/status", json=LINUX_TASK_STATUS, status=200, ) assert taskcluster.get_task_status(LINUX_TASK_ID) == LINUX_TASK_STATUS
def download_all(self): os.makedirs(self.parent_dir, exist_ok=True) logger.info("Downloading artifacts from {} tasks".format(len(self.test_tasks))) for test_task in self.test_tasks: status = test_task["status"]["state"] task_id = test_task["status"]["taskId"] while status not in FINISHED_STATUSES: assert status in ALL_STATUSES, "State '{}' not recognized".format( status ) logger.info(f"Waiting for task {task_id} to finish...") time.sleep(60) task_status = taskcluster.get_task_status(task_id) status = task_status["status"]["state"] # Update the task status, as we will use it to compare statuses later. test_task["status"]["state"] = status # Choose best tasks to download (e.g. 'completed' is better than 'failed') download_tasks = {} for test_task in self.test_tasks: status = test_task["status"]["state"] assert status in FINISHED_STATUSES, "State '{}' not recognized".format( status ) chunk_name = taskcluster.get_chunk(test_task["task"]) platform_name = taskcluster.get_platform(test_task["task"]) if any(to_ignore in chunk_name for to_ignore in SUITES_TO_IGNORE): continue if (chunk_name, platform_name) not in download_tasks: # If the chunk hasn't been downloaded before, this is obviously the best task # to download it from. download_tasks[(chunk_name, platform_name)] = test_task else: # Otherwise, compare the status of this task with the previously selected task. prev_task = download_tasks[(chunk_name, platform_name)] if STATUS_VALUE[status] > STATUS_VALUE[prev_task["status"]["state"]]: download_tasks[(chunk_name, platform_name)] = test_task with ThreadPoolExecutorResult() as executor: for test_task in download_tasks.values(): executor.submit(self.download, test_task) logger.info("Code coverage artifacts downloaded")
def download_all(self): os.makedirs(self.parent_dir, exist_ok=True) # The test tasks for the Linux and Windows builds are in the same group, # but the following code is generic and supports build tasks split in # separate groups. groups = set([ taskcluster.get_task_details(build_task_id)["taskGroupId"] for build_task_id in self.task_ids.values() if build_task_id is not None ]) test_tasks = [ task for group in groups for task in taskcluster.get_tasks_in_group(group) if taskcluster.is_coverage_task(task["task"]) and not self.is_filtered_task(task) ] logger.info("Downloading artifacts from {} tasks".format( len(test_tasks))) for test_task in test_tasks: status = test_task["status"]["state"] task_id = test_task["status"]["taskId"] while status not in FINISHED_STATUSES: assert status in ALL_STATUSES, "State '{}' not recognized".format( status) logger.info(f"Waiting for task {task_id} to finish...") time.sleep(60) task_status = taskcluster.get_task_status(task_id) status = task_status["status"]["state"] # Update the task status, as we will use it to compare statuses later. test_task["status"]["state"] = status # Choose best tasks to download (e.g. 'completed' is better than 'failed') download_tasks = {} for test_task in test_tasks: status = test_task["status"]["state"] assert status in FINISHED_STATUSES, "State '{}' not recognized".format( status) chunk_name = taskcluster.get_chunk(test_task["task"]) platform_name = taskcluster.get_platform(test_task["task"]) if any(to_ignore in chunk_name for to_ignore in SUITES_TO_IGNORE): continue if (chunk_name, platform_name) not in download_tasks: # If the chunk hasn't been downloaded before, this is obviously the best task # to download it from. download_tasks[(chunk_name, platform_name)] = test_task else: # Otherwise, compare the status of this task with the previously selected task. prev_task = download_tasks[(chunk_name, platform_name)] if STATUS_VALUE[status] > STATUS_VALUE[prev_task["status"] ["state"]]: download_tasks[(chunk_name, platform_name)] = test_task with ThreadPoolExecutorResult() as executor: for test_task in download_tasks.values(): executor.submit(self.download, test_task) logger.info("Code coverage artifacts downloaded")
def test_get_task_status(LINUX_TASK_ID, LINUX_TASK_STATUS): responses.add(responses.GET, 'https://queue.taskcluster.net/v1/task/{}/status'.format(LINUX_TASK_ID), json=LINUX_TASK_STATUS, status=200) assert taskcluster.get_task_status(LINUX_TASK_ID) == LINUX_TASK_STATUS