コード例 #1
0
ファイル: ocscilib.py プロジェクト: shylesh/ocs-ci
def pytest_configure(config):
    """
    Load config files, and initialize ocs-ci library.

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

    """
    set_log_level(config)
    # Somewhat hacky but this lets us differentiate between run-ci executions
    # and plain pytest unit test executions
    ocscilib_module = "ocs_ci.framework.pytest_customization.ocscilib"
    if ocscilib_module not in config.getoption("-p"):
        return
    for i in range(ocsci_config.nclusters):
        log.debug(f"Pytest configure switching to: cluster={i}")
        ocsci_config.switch_ctx(i)

        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']}-cl{i}-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")

            # add logs url
            logs_url = ocsci_config.RUN.get("logs_url")
            if logs_url:
                config._metadata["Logs URL"] = logs_url

            if ocsci_config.RUN["cli_params"].get("teardown") or (
                    "deployment" in markers_arg
                    and ocsci_config.RUN["cli_params"].get("deploy")):
                log.info(
                    "Skipping versions collecting because: Deploy or destroy of "
                    "cluster is performed.")
                return
            elif ocsci_config.ENV_DATA["skip_ocs_deployment"]:
                log.info("Skipping version collection because we skipped "
                         "the OCS deployment")
                return
            elif ocsci_config.RUN["cli_params"].get("dev_mode"):
                log.info("Running in development mode")
                return
            print("Collecting Cluster versions")
            # remove extraneous metadata
            for extra_meta in ["Python", "Packages", "Plugins", "Platform"]:
                if config._metadata.get(extra_meta):
                    del config._metadata[extra_meta]

            config._metadata["Test Run Name"] = get_testrun_name()
            gather_version_info_for_report(config)
コード例 #2
0
ファイル: ocscilib.py プロジェクト: waynesun09/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") 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
コード例 #3
0
ファイル: ocscilib.py プロジェクト: xenolinux/ocs-ci
def pytest_configure(config):
    """
    Load config files, and initialize ocs-ci library.

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

    """
    # Somewhat hacky but this lets us differentiate between run-ci executions
    # and plain pytest unit test executions
    ocscilib_module = 'ocs_ci.framework.pytest_customization.ocscilib'
    if ocscilib_module not in config.getoption('-p'):
        return
    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}")
        set_report_portal_tags(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(
                "Skipping versions collecting because: Deploy or destroy of "
                "cluster is performed.")
            return
        elif ocsci_config.ENV_DATA['skip_ocs_deployment']:
            log.info("Skipping version collection because we skipped "
                     "the OCS deployment")
            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()
        gather_version_info_for_report(config)

        try:
            ocs_csv = get_ocs_csv()
            ocs_csv_version = ocs_csv.data['spec']['version']
            config.addinivalue_line("rp_launch_tags",
                                    f"ocs_csv_version:{ocs_csv_version}")
        except (ResourceNotFoundError, ChannelNotFound):
            # might be using exisitng cluster path using GUI installation
            log.warning("Unable to get CSV version for Reporting")
コード例 #4
0
ファイル: conftest.py プロジェクト: galaxy42028/ocs-ci
def polarion_testsuite_properties(record_testsuite_property, pytestconfig):
    """
    Configures polarion testsuite properties for junit xml
    """
    polarion_project_id = config.REPORTING['polarion']['project_id']
    record_testsuite_property('polarion-project-id', polarion_project_id)
    jenkins_build_url = config.RUN.get('jenkins_build_url')
    if jenkins_build_url:
        record_testsuite_property('polarion-custom-description',
                                  jenkins_build_url)
    polarion_testrun_name = get_testrun_name()
    record_testsuite_property('polarion-testrun-id', polarion_testrun_name)
    record_testsuite_property('polarion-testrun-status-id', 'inprogress')
コード例 #5
0
ファイル: ocscilib.py プロジェクト: oritwas/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") 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(
                "Skipping versions collecting because: Deploy or destroy of "
                "cluster is performed."
            )
            return
        elif ocsci_config.ENV_DATA['skip_ocs_deployment']:
            log.info(
                "Skipping version collection because we skipped "
                "the OCS deployment"
            )
            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()
        gather_version_info_for_report(config)
コード例 #6
0
ファイル: main.py プロジェクト: ekuric/ocs-ci
def main(argv=None):
    arguments = argv or sys.argv[1:]
    init_ocsci_conf(arguments)
    pytest_logs_dir = utils.ocsci_log_path()
    utils.create_directory_path(framework.config.RUN['log_dir'])
    launch_name = utils.get_testrun_name() + getuser()
    arguments.extend([
        '-p',
        'ocs_ci.framework.pytest_customization.ocscilib',
        '-p',
        'ocs_ci.framework.pytest_customization.marks',
        '-p',
        'ocs_ci.framework.pytest_customization.reports',
        '--logger-logsdir',
        pytest_logs_dir,
        '--rp-launch',
        launch_name,
    ])
    return pytest.main(arguments)
コード例 #7
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 csi versions
            csi_versions = get_csi_versions()
            config._metadata['cephfsplugin'] = csi_versions.get(
                'csi-cephfsplugin')
            config._metadata['rbdplugin'] = csi_versions.get('csi-rbdplugin')

            # add ocs operator version
            ocs_catalog = CatalogSource(
                resource_name=OPERATOR_CATALOG_SOURCE_NAME,
                namespace="openshift-marketplace")
            if ocsci_config.REPORTING['us_ds'] == 'DS':
                config._metadata['OCS operator'] = (
                    ocs_catalog.get_image_name())
            mods = get_version_info(
                namespace=ocsci_config.ENV_DATA['cluster_namespace'])
            skip_list = ['ocs-operator']
            for key, val in mods.items():
                if key not in skip_list:
                    config._metadata[key] = val.rsplit('/')[-1]
        except (FileNotFoundError, CommandFailed):
            pass
コード例 #8
0
def pytest_configure(config):
    """
    Load config files, and initialize ocs-ci library.

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

    """
    set_log_level(config)
    # Somewhat hacky but this lets us differentiate between run-ci executions
    # and plain pytest unit test executions
    ocscilib_module = "ocs_ci.framework.pytest_customization.ocscilib"
    if ocscilib_module not in config.getoption("-p"):
        return
    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}"
        )
        set_report_portal_config(config)
        # Add OCS related versions to the html report and remove
        # extraneous metadata
        markers_arg = config.getoption("-m")

        # add logs url
        logs_url = ocsci_config.RUN.get("logs_url")
        if logs_url:
            config._metadata["Logs URL"] = logs_url

        if ocsci_config.RUN["cli_params"].get("teardown") or (
            "deployment" in markers_arg and ocsci_config.RUN["cli_params"].get("deploy")
        ):
            log.info(
                "Skipping versions collecting because: Deploy or destroy of "
                "cluster is performed."
            )
            return
        elif ocsci_config.ENV_DATA["skip_ocs_deployment"]:
            log.info(
                "Skipping version collection because we skipped " "the OCS deployment"
            )
            return
        elif ocsci_config.RUN["cli_params"].get("dev_mode"):
            log.info("Running in development mode")
            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()
        gather_version_info_for_report(config)

        try:
            ocs_csv = get_ocs_csv()
            ocs_csv_version = ocs_csv.data["spec"]["version"]
            config.addinivalue_line(
                "rp_launch_tags", f"ocs_csv_version:{ocs_csv_version}"
            )
        except (ResourceNotFoundError, ChannelNotFound, ResourceWrongStatusException):
            # might be using exisitng cluster path using GUI installation
            log.warning("Unable to get CSV version for Reporting")