Ejemplo n.º 1
0
def init_ocsci_conf(arguments=None):
    """
    Update the config object with any files passed via the CLI

    Args:
        arguments (list): Arguments for pytest execution
    """
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument('--ocsci-conf', action='append', default=[])
    parser.add_argument('--ocs-version',
                        action='store',
                        choices=['4.2', '4.3'])
    args, unknown = parser.parse_known_args(args=arguments)
    if args.ocs_version:
        version_config_file = os.path.join(CONF_DIR, 'ocs_version',
                                           f'ocs-{args.ocs_version}.yaml')
        args.ocsci_conf.insert(0, version_config_file)
    for config_file in args.ocsci_conf:
        with open(os.path.abspath(
                os.path.expanduser(config_file))) as file_stream:
            custom_config_data = yaml.safe_load(file_stream)
            framework.config.update(custom_config_data)
    framework.config.RUN['run_id'] = int(time.time())
    bin_dir = framework.config.RUN.get('bin_dir')
    if bin_dir:
        framework.config.RUN['bin_dir'] = os.path.abspath(
            os.path.expanduser(framework.config.RUN['bin_dir']))
        utils.add_path_to_env_path(framework.config.RUN['bin_dir'])
    check_config_requirements()
Ejemplo n.º 2
0
def init_ocsci_conf(arguments=None):
    """
    Update the config object with any files passed via the CLI

    Args:
        arguments (list): Arguments for pytest execution
    """
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument('--ocsci-conf', action='append', default=[])
    parser.add_argument('--ocs-version',
                        action='store',
                        choices=['4.2', '4.3'])
    parser.add_argument('--ocs-registry-image')
    args, unknown = parser.parse_known_args(args=arguments)
    ocs_version = args.ocs_version
    load_config(args.ocsci_conf)
    ocs_registry_image = framework.config.DEPLOYMENT.get('ocs_registry_image')
    if args.ocs_registry_image:
        ocs_registry_image = args.ocs_registry_image
    if ocs_registry_image:
        ocs_version = utils.get_ocs_version_from_image(ocs_registry_image)
    if ocs_version:
        version_config_file = os.path.join(CONF_DIR, 'ocs_version',
                                           f'ocs-{ocs_version}.yaml')
        load_config([version_config_file])
    framework.config.RUN['run_id'] = int(time.time())
    bin_dir = framework.config.RUN.get('bin_dir')
    if bin_dir:
        framework.config.RUN['bin_dir'] = os.path.abspath(
            os.path.expanduser(framework.config.RUN['bin_dir']))
        utils.add_path_to_env_path(framework.config.RUN['bin_dir'])
    check_config_requirements()
Ejemplo n.º 3
0
def init_ocsci_conf(arguments=None):
    """
    Update the config object with any files passed via the CLI

    Args:
        arguments (list): Arguments for pytest execution
    """
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument('--ocsci-conf', action='append', default=[])
    # cluster-conf parameter will be deleted once we will update all the jobs
    parser.add_argument('--cluster-conf')
    args, unknown = parser.parse_known_args(args=arguments)
    for config_file in args.ocsci_conf:
        with open(os.path.abspath(
                os.path.expanduser(config_file))) as file_stream:
            custom_config_data = yaml.safe_load(file_stream)
            framework.config.update(custom_config_data)
    cluster_config = args.cluster_conf
    if cluster_config:
        with open(os.path.expanduser(cluster_config)) as file_stream:
            cluster_config_data = yaml.safe_load(file_stream)
            framework.config.update(cluster_config_data)
    framework.config.RUN['run_id'] = int(time.time())
    bin_dir = framework.config.RUN.get('bin_dir')
    if bin_dir:
        framework.config.RUN['bin_dir'] = os.path.abspath(
            os.path.expanduser(framework.config.RUN['bin_dir']))
        utils.add_path_to_env_path(framework.config.RUN['bin_dir'])
    check_config_requirements()
Ejemplo n.º 4
0
def init_ocsci_conf(arguments=None):
    """
    Update the config object with any files passed via the CLI

    Args:
        arguments (list): Arguments for pytest execution
    """
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument("--ocsci-conf", action="append", default=[])
    parser.add_argument(
        "--ocs-version",
        action="store",
        choices=["4.2", "4.3", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9"],
    )
    parser.add_argument("--ocs-registry-image")
    parser.add_argument("--flexy-env-file", default="", help="Path to flexy env file")
    parser.add_argument(
        "--disable-components",
        action="append",
        choices=["rgw", "cephfs", "noobaa", "blockpools"],
        help=("disable deployment of ocs components:rgw, cephfs, noobaa, blockpools."),
    )
    args, unknown = parser.parse_known_args(args=arguments)
    ocs_version = args.ocs_version
    load_config(args.ocsci_conf)
    ocs_registry_image = framework.config.DEPLOYMENT.get("ocs_registry_image")
    if args.ocs_registry_image:
        ocs_registry_image = args.ocs_registry_image
    if ocs_registry_image:
        ocs_version_from_image = utils.get_ocs_version_from_image(ocs_registry_image)
        if ocs_version and ocs_version != ocs_version_from_image:
            framework.config.DEPLOYMENT["ignore_csv_mismatch"] = True
        if not ocs_version:
            ocs_version = ocs_version_from_image
    if ocs_version:
        version_config_file = os.path.join(
            OCS_VERSION_CONF_DIR, f"ocs-{ocs_version}.yaml"
        )
        load_config([version_config_file])

        ocp_version = framework.config.DEPLOYMENT["default_ocp_version"]
        if "ocp_version" in framework.config.DEPLOYMENT:
            ocp_version = framework.config.DEPLOYMENT["ocp_version"]
        ocp_version_config = os.path.join(
            OCP_VERSION_CONF_DIR, f"ocp-{ocp_version}-config.yaml"
        )
        load_config([ocp_version_config])
    if args.flexy_env_file:
        framework.config.ENV_DATA["flexy_env_file"] = args.flexy_env_file

    framework.config.RUN["run_id"] = int(time.time())
    bin_dir = framework.config.RUN.get("bin_dir")
    if bin_dir:
        framework.config.RUN["bin_dir"] = os.path.abspath(
            os.path.expanduser(framework.config.RUN["bin_dir"])
        )
        utils.add_path_to_env_path(framework.config.RUN["bin_dir"])
    if args.disable_components:
        framework.config.ENV_DATA["disable_components"] = args.disable_components
    check_config_requirements()
Ejemplo n.º 5
0
def main():
    """
    Main fuction of version reporting command line tool.
    used by entry point report-version from setup.py
    to invoke this function.

    """
    ap = argparse.ArgumentParser(
        description="report OCS version for QE purposes")
    ap.add_argument("--cluster-path",
                    required=True,
                    help="Path to cluster directory")
    ap.add_argument(
        "-l",
        "--loglevel",
        choices=["INFO", "DEBUG"],
        default=[],
        nargs=1,
        help="show log messages using given log level",
    )
    ap.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        help="show raw version data via pprint insteaf of plaintext",
    )
    args = ap.parse_args()

    if "INFO" in args.loglevel:
        logging.basicConfig(level=logging.INFO)
    elif "DEBUG" in args.loglevel:
        logging.basicConfig(level=logging.DEBUG)

    # make sure that bin dir is in PATH (for oc cli tool)
    utils.add_path_to_env_path(
        os.path.expanduser(framework.config.RUN["bin_dir"]))

    # set cluster path (for KUBECONFIG required by oc cli tool)
    from ocs_ci.ocs.openshift_ops import OCP

    OCP.set_kubeconfig(
        os.path.join(args.cluster_path, config.RUN["kubeconfig_location"]))

    cluster_version = get_ocp_version_dict()
    image_dict = get_ocs_version()

    if args.verbose:
        pprint.pprint(cluster_version)
        pprint.pprint(image_dict)
        return

    report_ocs_version(cluster_version, image_dict, file_obj=sys.stdout)
Ejemplo n.º 6
0
def main(arguments):
    init_ocsci_conf(arguments)
    arguments.extend([
        '-p',
        'ocs_ci.framework.pytest_customization.ocscilib',
        '-p',
        'ocs_ci.framework.pytest_customization.marks',
        '-p',
        'ocs_ci.framework.pytest_customization.reports',
    ])
    utils.add_path_to_env_path(
        os.path.expanduser(framework.config.RUN['bin_dir']))
    return pytest.main(arguments)
Ejemplo n.º 7
0
def init_ocsci_conf(arguments=None):
    """
    Update the config object with any files passed via the CLI

    Args:
        arguments (list): Arguments for pytest execution
    """
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument('--ocsci-conf', action='append', default=[])
    parser.add_argument('--ocs-version',
                        action='store',
                        choices=['4.2', '4.3', '4.4', '4.5', '4.6'])
    parser.add_argument('--ocs-registry-image')
    parser.add_argument('--flexy-env-file',
                        default='',
                        help="Path to flexy env file")
    args, unknown = parser.parse_known_args(args=arguments)
    ocs_version = args.ocs_version
    load_config(args.ocsci_conf)
    ocs_registry_image = framework.config.DEPLOYMENT.get('ocs_registry_image')
    if args.ocs_registry_image:
        ocs_registry_image = args.ocs_registry_image
    if ocs_registry_image:
        ocs_version_from_image = utils.get_ocs_version_from_image(
            ocs_registry_image)
        if ocs_version and ocs_version != ocs_version_from_image:
            framework.config.DEPLOYMENT['ignore_csv_mismatch'] = True
        if not ocs_version:
            ocs_version = ocs_version_from_image
    if ocs_version:
        version_config_file = os.path.join(CONF_DIR, 'ocs_version',
                                           f'ocs-{ocs_version}.yaml')
        load_config([version_config_file])

        default_ocp_version = framework.config.DEPLOYMENT[
            'default_ocp_version']
        ocp_version_config = os.path.join(
            CONF_DIR, 'ocp_version', f'ocp-{default_ocp_version}-config.yaml')
        load_config([ocp_version_config])
    if args.flexy_env_file:
        framework.config.ENV_DATA['flexy_env_file'] = args.flexy_env_file

    framework.config.RUN['run_id'] = int(time.time())
    bin_dir = framework.config.RUN.get('bin_dir')
    if bin_dir:
        framework.config.RUN['bin_dir'] = os.path.abspath(
            os.path.expanduser(framework.config.RUN['bin_dir']))
        utils.add_path_to_env_path(framework.config.RUN['bin_dir'])
    check_config_requirements()
Ejemplo n.º 8
0
def main(arguments):
    init_ocsci_conf(arguments)
    pytest_logs_dir = utils.ocsci_log_path()
    utils.create_directory_path(framework.config.RUN['log_dir'])
    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,
    ])
    utils.add_path_to_env_path(
        os.path.expanduser(framework.config.RUN['bin_dir']))
    return pytest.main(arguments)
Ejemplo n.º 9
0
def process_ocsci_conf(arguments):
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument("--ocsci-conf", action="append", default=[])
    parser.add_argument(
        "--ocs-version",
        action="store",
        choices=[
            "4.2",
            "4.3",
            "4.4",
            "4.5",
            "4.6",
            "4.6-eus",
            "4.7",
            "4.7-eus",
            "4.8",
            "4.8-eus",
            "4.9",
            "4.10",
            "4.11",
        ],
    )
    parser.add_argument("--ocs-registry-image")
    parser.add_argument("--flexy-env-file",
                        default="",
                        help="Path to flexy env file")
    parser.add_argument(
        "--disable-components",
        action="append",
        choices=["rgw", "cephfs", "noobaa", "blockpools"],
        help=
        ("disable deployment of ocs components:rgw, cephfs, noobaa, blockpools."
         ),
    )
    parser.add_argument(
        "--default-cluster-context-index",
        action="store",
        default=0,
    )

    args, unknown = parser.parse_known_args(args=arguments)
    load_config(args.ocsci_conf)
    ocs_version = args.ocs_version or framework.config.ENV_DATA.get(
        "ocs_version")
    ocs_registry_image = framework.config.DEPLOYMENT.get("ocs_registry_image")
    if args.ocs_registry_image:
        ocs_registry_image = args.ocs_registry_image
    if ocs_registry_image:
        ocs_version_from_image = utils.get_ocs_version_from_image(
            ocs_registry_image)
        if ocs_version and ocs_version != ocs_version_from_image:
            framework.config.DEPLOYMENT["ignore_csv_mismatch"] = True
        ocs_version = ocs_version_from_image
    if ocs_version:
        version_config_file = os.path.join(OCS_VERSION_CONF_DIR,
                                           f"ocs-{ocs_version}.yaml")
        load_config([version_config_file])

        ocp_version = framework.config.DEPLOYMENT["default_ocp_version"]
        if "ocp_version" in framework.config.DEPLOYMENT:
            ocp_version = framework.config.DEPLOYMENT["ocp_version"]
        ocp_version_config = os.path.join(OCP_VERSION_CONF_DIR,
                                          f"ocp-{ocp_version}-config.yaml")
        load_config([ocp_version_config])
        # As we may have overridden values specified in the original config,
        # reload it to get them back
        load_config(args.ocsci_conf)
    if args.flexy_env_file:
        framework.config.ENV_DATA["flexy_env_file"] = args.flexy_env_file

    framework.config.RUN["run_id"] = int(time.time())
    bin_dir = framework.config.RUN.get("bin_dir")
    if bin_dir:
        framework.config.RUN["bin_dir"] = os.path.abspath(
            os.path.expanduser(framework.config.RUN["bin_dir"]))
        utils.add_path_to_env_path(framework.config.RUN["bin_dir"])
    if args.disable_components:
        framework.config.ENV_DATA[
            "disable_components"] = args.disable_components
    framework.config.ENV_DATA["default_cluster_context_index"] = (
        int(args.default_cluster_context_index)
        if args.default_cluster_context_index else 0)