Example #1
0
def download_test_provider(provider, update=False):
    """
    Download a test provider defined on a .ini file inside test-providers.d.

    This function will only download test providers that are in git repos.
    Local filesystems don't need this functionality.

    :param provider: Test provider name, such as 'io-github-autotest-qemu'.
    """
    provider_info = get_test_provider_info(provider)
    uri = provider_info.get('uri')
    if not uri.startswith('file://'):
        uri = provider_info.get('uri')
        branch = provider_info.get('branch')
        ref = provider_info.get('ref')
        pubkey = provider_info.get('pubkey')
        download_dst = data_dir.get_test_provider_dir(provider)
        repo_downloaded = os.path.isdir(os.path.join(download_dst, '.git'))
        if not repo_downloaded or update:
            download_dst = git.get_repo(uri=uri, branch=branch, commit=ref,
                                        destination_dir=download_dst)
            os.chdir(download_dst)
            try:
                utils.run('git remote add origin %s' % uri)
            except error.CmdError:
                pass
            utils.run('git pull origin %s' % branch)
        os.chdir(download_dst)
        utils.system('git log -1')
Example #2
0
def get_test_provider_info(provider):
    """
    Get a dictionary with relevant test provider info, such as:

    * provider uri (git repo or filesystem location)
    * provider git repo data, such as branch, ref, pubkey
    * backends that this provider has tests for. For each backend type the
        provider has tests for, the 'path' will be also available.

    :param provider: Test provider name, such as 'io-github-autotest-qemu'.
    """
    provider_info = {}
    provider_path = os.path.join(data_dir.get_test_providers_dir(),
                                 '%s.ini' % provider)
    provider_cfg = test_config.config_loader(provider_path)
    provider_info['name'] = provider
    provider_info['uri'] = provider_cfg.get('provider', 'uri')
    provider_info['branch'] = provider_cfg.get('provider', 'branch', 'master')
    provider_info['ref'] = provider_cfg.get('provider', 'ref')
    provider_info['pubkey'] = provider_cfg.get('provider', 'pubkey')
    provider_info['backends'] = {}

    for backend in get_known_backends():
        subdir = provider_cfg.get(backend, 'subdir')
        if subdir is not None:
            if provider_info['uri'].startswith('file://'):
                src = os.path.join(provider_info['uri'][7:],
                                   subdir)
            else:
                src = os.path.join(data_dir.get_test_provider_dir(provider),
                                   subdir)
            provider_info['backends'].update({backend: {'path': src}})

    return provider_info
Example #3
0
def get_test_provider_info(provider):
    """
    Get a dictionary with relevant test provider info, such as:

    * provider uri (git repo or filesystem location)
    * provider git repo data, such as branch, ref, pubkey
    * backends that this provider has tests for. For each backend type the
        provider has tests for, the 'path' will be also available.

    :param provider: Test provider name, such as 'io-github-autotest-qemu'.
    """
    provider_info = {}
    provider_path = os.path.join(data_dir.get_test_providers_dir(),
                                 '%s.ini' % provider)
    provider_cfg = test_config.config_loader(provider_path)
    provider_info['name'] = provider
    provider_info['uri'] = provider_cfg.get('provider', 'uri')
    provider_info['branch'] = provider_cfg.get('provider', 'branch', 'master')
    provider_info['ref'] = provider_cfg.get('provider', 'ref')
    provider_info['pubkey'] = provider_cfg.get('provider', 'pubkey')
    provider_info['backends'] = {}

    for backend in get_known_backends():
        subdir = provider_cfg.get(backend, 'subdir')
        if subdir is not None:
            if provider_info['uri'].startswith('file://'):
                src = os.path.join(provider_info['uri'][7:], subdir)
            else:
                src = os.path.join(data_dir.get_test_provider_dir(provider),
                                   subdir)
            provider_info['backends'].update({backend: {'path': src}})

    return provider_info
Example #4
0
def download_test_provider(provider, update=False):
    """
    Download a test provider defined on a .ini file inside test-providers.d.

    This function will only download test providers that are in git repos.
    Local filesystems don't need this functionality.

    :param provider: Test provider name, such as 'io-github-autotest-qemu'.
    """
    provider_info = get_test_provider_info(provider)
    uri = provider_info.get('uri')
    if not uri.startswith('file://'):
        uri = provider_info.get('uri')
        branch = provider_info.get('branch')
        ref = provider_info.get('ref')
        pubkey = provider_info.get('pubkey')
        download_dst = data_dir.get_test_provider_dir(provider)
        repo_downloaded = os.path.isdir(os.path.join(download_dst, '.git'))
        original_dir = os.getcwd()
        if not repo_downloaded or update:
            download_dst = git.get_repo(uri=uri,
                                        branch=branch,
                                        commit=ref,
                                        destination_dir=download_dst)
            os.chdir(download_dst)
            try:
                utils.run('git remote add origin %s' % uri)
            except error.CmdError:
                pass
            utils.run('git pull origin %s' % branch)
        os.chdir(download_dst)
        utils.system('git log -1')
        os.chdir(original_dir)
Example #5
0
def get_test_provider_info(provider):
    """
    Get a dictionary with relevant test provider info, such as:

    * provider uri (git repo or filesystem location)
    * provider git repo data, such as branch, ref, pubkey
    * backends that this provider has tests for. For each backend type the
        provider has tests for, the 'path' will be also available.

    :param provider: Test provider name, such as 'io-github-autotest-qemu'.
    """
    provider_info = {}
    provider_path = os.path.join(data_dir.get_test_providers_dir(), "%s.ini" % provider)
    provider_cfg = test_config.config_loader(provider_path)
    provider_info["name"] = provider
    provider_info["uri"] = provider_cfg.get("provider", "uri")
    provider_info["branch"] = provider_cfg.get("provider", "branch", "master")
    provider_info["ref"] = provider_cfg.get("provider", "ref")
    provider_info["pubkey"] = provider_cfg.get("provider", "pubkey")
    provider_info["backends"] = {}

    for backend in get_known_backends():
        subdir = provider_cfg.get(backend, "subdir")
        if subdir is not None:
            if provider_info["uri"].startswith("file://"):
                src = os.path.join(provider_info["uri"][7:], subdir)
            else:
                src = os.path.join(data_dir.get_test_provider_dir(provider), subdir)
            provider_info["backends"].update({backend: {"path": src}})

    return provider_info