示例#1
0
def pytest_configure(config):
    """
    Load config files, and initialize ocs-ci library.

    Args:
        config (pytest.config): Pytest config object

    """
    if not (config.getoption("--help") or config.getoption("collectonly")):
        process_cluster_cli_params(config)
        config_file = os.path.expanduser(
            os.path.join(
                ocsci_config.RUN['log_dir'],
                f"run-{ocsci_config.RUN['run_id']}-config.yaml",
            ))
        dump_config_to_file(config_file)
        log.info(f"Dump of the consolidated config file is located here: "
                 f"{config_file}")
        # Add OCS related versions to the html report and remove extraneous metadata
        markers_arg = config.getoption('-m')
        if ocsci_config.RUN['cli_params'].get('teardown') or (
                "deployment" in markers_arg
                and ocsci_config.RUN['cli_params'].get('deploy')):
            log.info(
                "Skiping versions collecting because: Deploy or destroy of "
                "cluster is performed.")
            return
        print("Collecting Cluster versions")
        # remove extraneous metadata
        del config._metadata['Python']
        del config._metadata['Packages']
        del config._metadata['Plugins']
        del config._metadata['Platform']

        config._metadata['Test Run Name'] = get_testrun_name()

        try:
            # add cluster version
            clusterversion = get_cluster_version()
            config._metadata['Cluster Version'] = clusterversion

            # add ceph version
            ceph_version = get_ceph_version()
            config._metadata['Ceph Version'] = ceph_version

            # add rook version
            rook_version = get_rook_version()
            config._metadata['Rook Version'] = rook_version

            # add csi versions
            csi_versions = get_csi_versions()
            config._metadata['csi-provisioner'] = csi_versions.get(
                'csi-provisioner')
            config._metadata['cephfsplugin'] = csi_versions.get(
                'csi-cephfsplugin')
            config._metadata['rbdplugin'] = csi_versions.get('csi-rbdplugin')
        except (FileNotFoundError, CommandFailed):
            pass
示例#2
0
def get_environment_info():
    """
    Getting the environment information, Information that will be collected

    Versions:
        OCP - version / build / channel
        OCS - version / build
        Ceph - version
        Rook - version

    Platform:
        BM / VmWare / Cloud provider etc.
        Instance type / architecture
        Cluster name
        User name that run the test

    Return:
      dict: dictionary that contain the environment information

    """
    results = {}
    # getting the name and email  of the user that running the test.
    try:
        user = utils.run_cmd('git config --get user.name').strip()
        email = utils.run_cmd('git config --get user.email').strip()
        results['user'] = f'{user} <{email}>'
    except CommandFailed:
        # if no git user define, the default user is none
        results['user'] = ''

    results['clustername'] = ocp.get_clustername()
    results['platform'] = node.get_provider()
    if results['platform'].lower() not in constants.ON_PREM_PLATFORMS:
        results['platform'] = results['platform'].upper()

    results['ocp_build'] = ocp.get_build()
    results['ocp_channel'] = ocp.get_ocp_channel()
    results['ocp_version'] = utils.get_ocp_version()

    results['ceph_version'] = utils.get_ceph_version()
    results['rook_version'] = utils.get_rook_version()

    results['ocs_build'] = ocp.get_ocs_version()
    # Extracting the version number x.y.z from full build name
    m = re.match(r"(\d.\d).(\d)", results['ocs_build'])
    if m and m.group(1) is not None:
        results['ocs_version'] = m.group(1)

    # Getting the instance type for cloud or Arch type for None cloud
    worker_lbl = node.get_typed_nodes(
        num_of_nodes=1)[0].data['metadata']['labels']
    if 'beta.kubernetes.io/instance-type' in worker_lbl:
        results['worker_type'] = worker_lbl['beta.kubernetes.io/instance-type']
    else:
        results['worker_type'] = worker_lbl['kubernetes.io/arch']

    return results
示例#3
0
def get_environment_info():
    """
    Getting the environment information, Information that will be collected

    Versions:
        OCP - version / build / channel
        OCS - version / build
        Ceph - version
        Rook - version

    Platform:
        BM / VmWare / Cloud provider etc.
        Instance type / architecture
        Cluster name
        User name that run the test

    Return:
      dict: dictionary that contain the environment information

    """
    results = {}
    # getting the name and email  of the user that running the test.
    try:
        user = utils.run_cmd("git config --get user.name").strip()
        email = utils.run_cmd("git config --get user.email").strip()
        results["user"] = f"{user} <{email}>"
    except CommandFailed:
        # if no git user define, the default user is none
        results["user"] = ""

    results["clustername"] = ocp.get_clustername()
    results["platform"] = node.get_provider()
    if results["platform"].lower() not in constants.ON_PREM_PLATFORMS:
        results["platform"] = results["platform"].upper()

    results["ocp_build"] = ocp.get_build()
    results["ocp_channel"] = ocp.get_ocp_channel()
    results["ocp_version"] = utils.get_ocp_version()

    results["ceph_version"] = utils.get_ceph_version()
    results["rook_version"] = utils.get_rook_version()

    results[
        "ocs_build"
    ] = f"{version.get_ocs_version_from_csv(ignore_pre_release=True)}"

    # Getting the instance type for cloud or Arch type for None cloud
    worker_lbl = node.get_nodes(num_of_nodes=1)[0].data["metadata"]["labels"]
    if "beta.kubernetes.io/instance-type" in worker_lbl:
        results["worker_type"] = worker_lbl["beta.kubernetes.io/instance-type"]
    else:
        results["worker_type"] = worker_lbl["kubernetes.io/arch"]

    return results
示例#4
0
文件: ocscilib.py 项目: jhutar/ocs-ci
def pytest_configure(config):
    """
    Load config files, and initialize ocs-ci library.

    Args:
        config (pytest.config): Pytest config object

    """
    if not config.getoption("--help"):
        process_cluster_cli_params(config)
        # Add OCS related versions to the html report and remove extraneous metadata
        markers_arg = config.getoption('-m')
        if ocsci_config.RUN['cli_params'].get('teardown') or (
                "deployment" in markers_arg
                and ocsci_config.RUN['cli_params'].get('deploy')):
            log.info(
                "Skiping versions collecting because: Deploy or destroy of "
                "cluster is performed.")
            return
        print("Collecting Cluster versions")
        # remove extraneous metadata
        del config._metadata['Python']
        del config._metadata['Packages']
        del config._metadata['Plugins']
        del config._metadata['Platform']

        try:
            # add cluster version
            clusterversion = get_cluster_version()
            config._metadata['Cluster Version'] = clusterversion

            # add ceph version
            ceph_version = get_ceph_version()
            config._metadata['Ceph Version'] = ceph_version

            # add rook version
            rook_version = get_rook_version()
            config._metadata['Rook Version'] = rook_version

            # add csi versions
            csi_versions = get_csi_versions()
            config._metadata['csi-provisioner'] = csi_versions.get(
                'csi-provisioner')
            config._metadata['cephfsplugin'] = csi_versions.get('cephfsplugin')
            config._metadata['rbdplugin'] = csi_versions.get('rbdplugin')
        except (FileNotFoundError, CommandFailed):
            pass