def download_coverage_artifacts(self, build_task_id): try: os.mkdir('ccov-artifacts') except OSError as e: if e.errno != errno.EEXIST: raise e task_data = taskcluster.get_task_details(build_task_id) artifacts = taskcluster.get_task_artifacts(build_task_id) for artifact in artifacts: if 'target.code-coverage-gcno.zip' in artifact['name']: taskcluster.download_artifact(build_task_id, '', artifact) all_suites = set() tasks = taskcluster.get_tasks_in_group(task_data['taskGroupId']) test_tasks = [t for t in tasks if taskcluster.is_coverage_task(t)] for test_task in test_tasks: suite_name = taskcluster.get_suite_name(test_task) all_suites.add(suite_name) test_task_id = test_task['status']['taskId'] artifacts = taskcluster.get_task_artifacts(test_task_id) for artifact in artifacts: if any(n in artifact['name'] for n in ['code-coverage-gcda.zip', 'code-coverage-jsvm.zip']): taskcluster.download_artifact(test_task_id, suite_name, artifact) self.suites = list(all_suites) self.suites.sort()
def test_download_artifact_badzip(mocked_sleep, tmpdir): responses.add(responses.GET, 'https://queue.taskcluster.net/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public/test_info/code-coverage-grcov.zip', body='NOT A ZIP FILE', status=200, stream=True) # noqa with pytest.raises(BadZipFile, message='File is not a zip file'): taskcluster.download_artifact( os.path.join(tmpdir.strpath, 'windows_reftest-6_code-coverage-grcov.zip'), 'FBdocjnAQOW_GJDOfmgjxw', 'public/test_info/code-coverage-grcov.zip' ) assert mocked_sleep.call_count == 4
def test_download_artifact_forbidden(mocked_sleep, tmpdir): responses.add(responses.GET, 'https://queue.taskcluster.net/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public/test_info/code-coverage-grcov.zip', body='xml error...', status=403) # noqa with pytest.raises(requests.exceptions.HTTPError, message='403 Client Error: Forbidden for url: https://taskcluster-artifacts.net/FBdocjnAQOW_GJDOfmgjxw/0/public/test_info/code-coverage-grcov.zip'): # noqa taskcluster.download_artifact( os.path.join(tmpdir.strpath, 'windows_reftest-6_code-coverage-grcov.zip'), 'FBdocjnAQOW_GJDOfmgjxw', 'public/test_info/code-coverage-grcov.zip' ) assert mocked_sleep.call_count == 4
def download_artifact(test_task): status = test_task['status']['state'] assert status in ALL_STATUSES while status not in FINISHED_STATUSES: time.sleep(60) status = taskcluster.get_task_status(test_task['status']['taskId'])['status']['state'] assert status in ALL_STATUSES chunk_name = taskcluster.get_chunk_name(test_task) platform_name = taskcluster.get_platform_name(test_task) # 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): return # If we have already downloaded this chunk from another task, check if the # other task has a better status than this one. if not should_download(status, chunk_name, platform_name): return test_task_id = test_task['status']['taskId'] for artifact in taskcluster.get_task_artifacts(test_task_id): if not any(n in artifact['name'] for n in ['code-coverage-grcov.zip', 'code-coverage-jsvm.zip']): continue artifact_path = taskcluster.download_artifact(test_task_id, chunk_name, platform_name, artifact) logger.info('%s artifact downloaded' % artifact_path) if 'code-coverage-jsvm.zip' in artifact['name']: self.rewrite_jsvm_lcov(artifact_path) logger.info('%s artifact rewritten' % artifact_path)
def download(self, test_task): chunk_name = taskcluster.get_chunk( test_task['task']['metadata']['name']) platform_name = taskcluster.get_platform( test_task['task']['metadata']['name']) test_task_id = test_task['status']['taskId'] for artifact in taskcluster.get_task_artifacts(test_task_id): if not any(n in artifact['name'] for n in ['code-coverage-grcov.zip', 'code-coverage-jsvm.zip']): continue artifact_path = self.generate_path(platform_name, chunk_name, artifact) taskcluster.download_artifact(artifact_path, test_task_id, artifact['name']) logger.info('%s artifact downloaded' % artifact_path)
def download_coverage_artifacts(build_task_id): try: os.mkdir('ccov-artifacts') except: pass task_data = taskcluster.get_task_details(build_task_id) artifacts = taskcluster.get_task_artifacts(build_task_id) for artifact in artifacts: if 'target.code-coverage-gcno.zip' in artifact['name']: taskcluster.download_artifact(build_task_id, artifact) tasks = taskcluster.get_tasks_in_group(task_data['taskGroupId']) test_tasks = [t for t in tasks if is_coverage_task(t)] for test_task in test_tasks: test_task_id = test_task['status']['taskId'] artifacts = taskcluster.get_task_artifacts(test_task_id) for artifact in artifacts: if 'code-coverage-gcda.zip' in artifact['name']: taskcluster.download_artifact(test_task_id, artifact)
def download_coverage_artifacts(self, build_task_id): try: os.mkdir('ccov-artifacts') except OSError as e: if e.errno != errno.EEXIST: raise e task_data = taskcluster.get_task_details(build_task_id) all_suites = set() def rewriting_task(path): return lambda: self.rewrite_jsvm_lcov(path) tasks = taskcluster.get_tasks_in_group(task_data['taskGroupId']) test_tasks = [t for t in tasks if taskcluster.is_coverage_task(t)] with ThreadPoolExecutorResult() as executor: for test_task in test_tasks: suite_name = taskcluster.get_suite_name(test_task) # Ignore awsy and talos as they aren't actually suites of tests. if any(to_ignore in suite_name for to_ignore in ['awsy', 'talos']): continue all_suites.add(suite_name) test_task_id = test_task['status']['taskId'] for artifact in taskcluster.get_task_artifacts(test_task_id): if not any( n in artifact['name'] for n in ['code-coverage-grcov.zip', 'code-coverage-jsvm.zip']): continue artifact_path = taskcluster.download_artifact( test_task_id, suite_name, artifact) if 'code-coverage-jsvm.zip' in artifact['name']: executor.submit(rewriting_task(artifact_path)) self.suites = list(all_suites) self.suites.sort() logger.info('Code coverage artifacts downloaded')