def test_get_task_failure(TASK_NOT_FOUND): err = TASK_NOT_FOUND.copy() err['code'] = 'RandomError' responses.add(responses.GET, 'https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.revision.b2a9a4bb5c94de179ae7a3f52fde58c0e2897498.firefox.linux64-ccov-debug', json=err, status=500) # noqa with pytest.raises(taskcluster.TaskclusterException, message='Unknown TaskCluster index error.'): taskcluster.get_task('mozilla-central', 'b2a9a4bb5c94de179ae7a3f52fde58c0e2897498', 'linux')
def test_get_task( mock_taskcluster, LINUX_TASK_ID, LATEST_LINUX, WIN_TASK_ID, LATEST_WIN ): responses.add( responses.GET, "http://taskcluster.test/api/index/v1/task/gecko.v2.mozilla-central.revision.b2a9a4bb5c94de179ae7a3f52fde58c0e2897498.firefox.linux64-ccov-debug", json=LATEST_LINUX, status=200, ) # noqa assert ( taskcluster.get_task( "mozilla-central", "b2a9a4bb5c94de179ae7a3f52fde58c0e2897498", "linux" ) == LINUX_TASK_ID ) responses.add( responses.GET, "http://taskcluster.test/api/index/v1/task/gecko.v2.mozilla-central.revision.916103b8675d9fdb28b891cac235d74f9f475942.firefox.win64-ccov-debug", json=LATEST_WIN, status=200, ) # noqa assert ( taskcluster.get_task( "mozilla-central", "916103b8675d9fdb28b891cac235d74f9f475942", "windows" ) == WIN_TASK_ID )
def __init__(self, revision, cache_root, client_id, access_token): # List of test-suite, sorted alphabetically. # This way, the index of a suite in the array should be stable enough. self.suites = [ 'web-platform-tests', ] self.cache_root = cache_root assert os.path.isdir(cache_root), 'Cache root {} is not a dir.'.format( cache_root) self.repo_dir = os.path.join(cache_root, 'mozilla-central') temp_dir = tempfile.mkdtemp() self.artifacts_dir = os.path.join(temp_dir, 'ccov-artifacts') self.ccov_reports_dir = os.path.join(temp_dir, 'code-coverage-reports') self.client_id = client_id self.access_token = access_token self.index_service = get_service('index', client_id, access_token) self.githubUtils = GitHubUtils(cache_root, client_id, access_token) if revision is None: # Retrieve revision of latest codecov build self.github_revision = uploader.get_latest_codecov() self.revision = self.githubUtils.git_to_mercurial( self.github_revision) self.from_pulse = False else: self.github_revision = None self.revision = revision self.from_pulse = True self.notifier = Notifier(self.repo_dir, revision, client_id, access_token) logger.info('Mercurial revision', revision=self.revision) task_ids = { 'linux': taskcluster.get_task('mozilla-central', self.revision, 'linux'), 'windows': taskcluster.get_task('mozilla-central', self.revision, 'win'), 'android-test': taskcluster.get_task('mozilla-central', self.revision, 'android-test'), 'android-emulator': taskcluster.get_task('mozilla-central', self.revision, 'android-emulator'), } self.artifactsHandler = ArtifactsHandler(task_ids, self.artifacts_dir)
def test_get_task_not_found(TASK_NOT_FOUND): responses.add( responses.GET, 'https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.revision.b2a9a4bb5c94de179ae7a3f52fde58c0e2897498.firefox.linux64-ccov-debug', json=TASK_NOT_FOUND, status=404) # noqa with pytest.raises( taskcluster.TaskclusterException, message='Code coverage build failed and was not indexed.'): taskcluster.get_task('mozilla-central', 'b2a9a4bb5c94de179ae7a3f52fde58c0e2897498', 'linux')
def test_get_task_failure(TASK_NOT_FOUND): err = TASK_NOT_FOUND.copy() err['code'] = 'RandomError' responses.add( responses.GET, 'https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.revision.b2a9a4bb5c94de179ae7a3f52fde58c0e2897498.firefox.linux64-ccov-debug', json=err, status=500) # noqa with pytest.raises(taskcluster.TaskclusterException, message='Unknown TaskCluster index error.'): taskcluster.get_task('mozilla-central', 'b2a9a4bb5c94de179ae7a3f52fde58c0e2897498', 'linux')
def test_get_task_failure(mock_taskcluster, TASK_NOT_FOUND): err = TASK_NOT_FOUND.copy() err["code"] = "RandomError" responses.add( responses.GET, "http://taskcluster.test/api/index/v1/task/gecko.v2.mozilla-central.revision.b2a9a4bb5c94de179ae7a3f52fde58c0e2897498.firefox.linux64-ccov-opt", json=err, status=500, ) # noqa with pytest.raises(TaskclusterRestFailure, match="Indexed task not found"): taskcluster.get_task("mozilla-central", "b2a9a4bb5c94de179ae7a3f52fde58c0e2897498", "linux")
def test_get_task_failure(TASK_NOT_FOUND): err = TASK_NOT_FOUND.copy() err["code"] = "RandomError" responses.add( responses.GET, "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.revision.b2a9a4bb5c94de179ae7a3f52fde58c0e2897498.firefox.linux64-ccov-debug", json=err, status=500, ) # noqa with pytest.raises( taskcluster.TaskclusterException, match="Unknown TaskCluster index error." ): taskcluster.get_task( "mozilla-central", "b2a9a4bb5c94de179ae7a3f52fde58c0e2897498", "linux" )
def __init__(self, repository, revision, task_name_filter, cache_root, client_id, access_token): # List of test-suite, sorted alphabetically. # This way, the index of a suite in the array should be stable enough. self.suites = [ 'web-platform-tests', ] self.cache_root = cache_root temp_dir = tempfile.mkdtemp() self.artifacts_dir = os.path.join(temp_dir, 'ccov-artifacts') self.ccov_reports_dir = os.path.join(temp_dir, 'code-coverage-reports') self.client_id = client_id self.access_token = access_token self.index_service = get_service('index', client_id, access_token) self.githubUtils = GitHubUtils(cache_root, client_id, access_token) if revision is None: # Retrieve revision of latest codecov build self.github_revision = uploader.get_latest_codecov() self.repository = MOZILLA_CENTRAL_REPOSITORY self.revision = self.githubUtils.git_to_mercurial( self.github_revision) self.from_pulse = False else: self.github_revision = None self.repository = repository self.revision = revision self.from_pulse = True self.branch = self.repository[len(HG_BASE):] assert os.path.isdir(cache_root), 'Cache root {} is not a dir.'.format( cache_root) self.repo_dir = os.path.join(cache_root, self.branch) logger.info('Mercurial revision', revision=self.revision) task_ids = {} for platform in [ 'linux', 'windows', 'android-test', 'android-emulator' ]: task = taskcluster.get_task(self.branch, self.revision, platform) # On try, developers might have requested to run only one platform, and we trust them. # On mozilla-central, we want to assert that every platform was run (except for android platforms # as they are unstable). if task is not None: task_ids[platform] = task elif self.repository == MOZILLA_CENTRAL_REPOSITORY and not platform.startswith( 'android'): raise Exception( 'Code coverage build failed and was not indexed.') self.artifactsHandler = ArtifactsHandler(task_ids, self.artifacts_dir, task_name_filter)
def test_get_task(LINUX_TASK_ID, LATEST_LINUX, WIN_TASK_ID, LATEST_WIN): responses.add( responses.GET, 'https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.revision.b2a9a4bb5c94de179ae7a3f52fde58c0e2897498.firefox.linux64-ccov-debug', json=LATEST_LINUX, status=200) # noqa assert taskcluster.get_task('mozilla-central', 'b2a9a4bb5c94de179ae7a3f52fde58c0e2897498', 'linux') == LINUX_TASK_ID responses.add( responses.GET, 'https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.revision.916103b8675d9fdb28b891cac235d74f9f475942.firefox.win64-ccov-debug', json=LATEST_WIN, status=200) # noqa assert taskcluster.get_task('mozilla-central', '916103b8675d9fdb28b891cac235d74f9f475942', 'win') == WIN_TASK_ID
def test_get_task_not_found(TASK_NOT_FOUND): responses.add( responses.GET, 'https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.revision.b2a9a4bb5c94de179ae7a3f52fde58c0e2897498.firefox.linux64-ccov-debug', json=TASK_NOT_FOUND, status=404) # noqa assert taskcluster.get_task('mozilla-central', 'b2a9a4bb5c94de179ae7a3f52fde58c0e2897498', 'linux') is None
def __init__(self, repository, revision, task_name_filter, cache_root): # List of test-suite, sorted alphabetically. # This way, the index of a suite in the array should be stable enough. self.suites = ["web-platform-tests"] self.cache_root = cache_root temp_dir = tempfile.mkdtemp() self.artifacts_dir = os.path.join(temp_dir, "ccov-artifacts") self.index_service = taskcluster_config.get_service("index") if revision is None: # Retrieve latest ingested revision self.repository = MOZILLA_CENTRAL_REPOSITORY try: self.revision = uploader.gcp_latest("mozilla-central")[0]["revision"] except Exception as e: logger.warn( "Failed to retrieve the latest reports ingested: {}".format(e) ) raise self.from_pulse = False else: self.repository = repository self.revision = revision self.from_pulse = True self.branch = self.repository[len(HG_BASE) :] assert os.path.isdir(cache_root), "Cache root {} is not a dir.".format( cache_root ) self.repo_dir = os.path.join(cache_root, self.branch) logger.info("Mercurial revision", revision=self.revision) task_ids = {} for platform in ["linux", "windows", "android-test", "android-emulator"]: task = taskcluster.get_task(self.branch, self.revision, platform) # On try, developers might have requested to run only one platform, and we trust them. # On mozilla-central, we want to assert that every platform was run (except for android platforms # as they are unstable). if task is not None: task_ids[platform] = task elif ( self.repository == MOZILLA_CENTRAL_REPOSITORY and not platform.startswith("android") ): raise Exception("Code coverage build failed and was not indexed.") self.artifactsHandler = ArtifactsHandler( task_ids, self.artifacts_dir, task_name_filter )
def test_get_task_not_found(mock_taskcluster, TASK_NOT_FOUND): responses.add( responses.GET, "http://taskcluster.test/api/index/v1/task/gecko.v2.mozilla-central.revision.b2a9a4bb5c94de179ae7a3f52fde58c0e2897498.firefox.linux64-ccov-opt", json=TASK_NOT_FOUND, status=404, ) # noqa assert (taskcluster.get_task( "mozilla-central", "b2a9a4bb5c94de179ae7a3f52fde58c0e2897498", "linux") is None)
def __init__(self, repository, revision, cache_root, client_id, access_token): # List of test-suite, sorted alphabetically. # This way, the index of a suite in the array should be stable enough. self.suites = [ 'web-platform-tests', ] self.cache_root = cache_root temp_dir = tempfile.mkdtemp() self.artifacts_dir = os.path.join(temp_dir, 'ccov-artifacts') self.ccov_reports_dir = os.path.join(temp_dir, 'code-coverage-reports') self.client_id = client_id self.access_token = access_token self.index_service = get_service('index', client_id, access_token) self.githubUtils = GitHubUtils(cache_root, client_id, access_token) if revision is None: # Retrieve revision of latest codecov build self.github_revision = uploader.get_latest_codecov() self.repository = MOZILLA_CENTRAL_REPOSITORY self.revision = self.githubUtils.git_to_mercurial(self.github_revision) self.from_pulse = False else: self.github_revision = None self.repository = repository self.revision = revision self.from_pulse = True branch = self.repository[len(HG_BASE):] assert os.path.isdir(cache_root), 'Cache root {} is not a dir.'.format(cache_root) self.repo_dir = os.path.join(cache_root, branch) logger.info('Mercurial revision', revision=self.revision) task_ids = {} for platform in ['linux', 'windows', 'android-test', 'android-emulator']: task = taskcluster.get_task(branch, self.revision, platform) # On try, developers might have requested to run only one platform, and we trust them. # On mozilla-central, we want to assert that every platform was run (except for android platforms # as they are unstable). if task is not None: task_ids[platform] = task elif self.repository == MOZILLA_CENTRAL_REPOSITORY and not platform.startswith('android'): raise Exception('Code coverage build failed and was not indexed.') self.artifactsHandler = ArtifactsHandler(task_ids, self.artifacts_dir)
def __init__( self, repository, revision, task_name_filter, cache_root, working_dir, required_platforms=[], ): os.makedirs(working_dir, exist_ok=True) self.artifacts_dir = os.path.join(working_dir, "ccov-artifacts") self.reports_dir = os.path.join(working_dir, "ccov-reports") logger.info( "Local storage initialized.", artifacts=self.artifacts_dir, reports=self.reports_dir, ) self.repository = repository self.revision = revision assert (self.revision is not None and self.repository is not None), "Missing repo/revision" logger.info("Mercurial setup", repository=self.repository, revision=self.revision) assert os.path.isdir( cache_root), f"Cache root {cache_root} is not a dir." self.repo_dir = os.path.join(cache_root, self.branch) # Load current coverage task for all platforms task_ids = { platform: taskcluster.get_task(self.branch, self.revision, platform) for platform in PLATFORMS } # Check the required platforms are present for platform in required_platforms: if not task_ids[platform]: raise Exception( f"Code coverage build on {platform} failed and was not indexed." ) self.artifactsHandler = ArtifactsHandler(task_ids, self.artifacts_dir, task_name_filter)
def test_get_task_not_found(TASK_NOT_FOUND): responses.add(responses.GET, 'https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.revision.b2a9a4bb5c94de179ae7a3f52fde58c0e2897498.firefox.linux64-ccov-debug', json=TASK_NOT_FOUND, status=404) # noqa assert taskcluster.get_task('mozilla-central', 'b2a9a4bb5c94de179ae7a3f52fde58c0e2897498', 'linux') is None
def test_get_task(LINUX_TASK_ID, LATEST_LINUX, WIN_TASK_ID, LATEST_WIN): responses.add(responses.GET, 'https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.revision.b2a9a4bb5c94de179ae7a3f52fde58c0e2897498.firefox.linux64-ccov-debug', json=LATEST_LINUX, status=200) # noqa assert taskcluster.get_task('mozilla-central', 'b2a9a4bb5c94de179ae7a3f52fde58c0e2897498', 'linux') == LINUX_TASK_ID responses.add(responses.GET, 'https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.revision.916103b8675d9fdb28b891cac235d74f9f475942.firefox.win64-ccov-debug', json=LATEST_WIN, status=200) # noqa assert taskcluster.get_task('mozilla-central', '916103b8675d9fdb28b891cac235d74f9f475942', 'windows') == WIN_TASK_ID