def test_ovs_package_version(openshift_release, expected_ovs_version):
    task_vars = dict(
        openshift=dict(common=dict()),
        openshift_release=openshift_release,
        openshift_image_tag='v' + openshift_release,
        openshift_service_type='origin'
    )
    return_value = {}  # note: check.execute_module modifies return hash contents

    def execute_module(module_name=None, module_args=None, *_):
        assert module_name == 'rpm_version'
        assert "package_list" in module_args

        for pkg in module_args["package_list"]:
            if pkg["name"] == "openvswitch":
                assert pkg["version"] == expected_ovs_version

        return return_value

    check = OvsVersion(execute_module, task_vars)
    check.openshift_to_ovs_version = {
        (3, 4): "2.4",
        (3, 5): ["2.6", "2.7"],
        (3, 6): ["2.6", "2.7", "2.8"],
    }
    result = check.run()
    assert result is return_value
Exemplo n.º 2
0
def test_ovs_package_version(openshift_release, expected_ovs_version):
    task_vars = dict(
        openshift=dict(common=dict(service_type='origin')),
        openshift_release=openshift_release,
        openshift_image_tag='v' + openshift_release,
    )
    return_value = object()

    def execute_module(module_name=None, module_args=None, *_):
        assert module_name == 'rpm_version'
        assert "package_list" in module_args

        for pkg in module_args["package_list"]:
            if pkg["name"] == "openvswitch":
                assert pkg["version"] == expected_ovs_version

        return return_value

    check = OvsVersion(execute_module, task_vars)
    check.openshift_to_ovs_version = {
        "3.7": ["2.6", "2.7", "2.8"],
        "3.6": ["2.6", "2.7", "2.8"],
        "3.5": ["2.6", "2.7"],
        "3.4": "2.4",
    }
    result = check.run()
    assert result is return_value
def test_invalid_openshift_release_format():
    def execute_module(module_name=None, module_args=None, tmp=None, task_vars=None):
        return {}

    task_vars = dict(
        openshift=dict(common=dict(service_type='origin')),
        openshift_image_tag='v0',
        openshift_deployment_type='origin',
    )

    check = OvsVersion(execute_module=execute_module)
    with pytest.raises(OpenShiftCheckException) as excinfo:
        check.run(tmp=None, task_vars=task_vars)
    assert "invalid version" in str(excinfo.value)
Exemplo n.º 4
0
def test_ovs_version_skip_when_not_master_nor_node(group_names,
                                                   openshift_is_containerized,
                                                   is_active):
    task_vars = dict(
        group_names=group_names,
        openshift_is_containerized=openshift_is_containerized,
    )
    assert OvsVersion(None, task_vars).is_active() == is_active
def test_ovs_version_skip_when_not_master_nor_node(group_names,
                                                   is_containerized,
                                                   is_active):
    task_vars = dict(
        group_names=group_names,
        openshift=dict(common=dict(is_containerized=is_containerized)),
    )
    assert OvsVersion.is_active(task_vars=task_vars) == is_active
def test_invalid_openshift_release_format():
    def execute_module(module_name=None,
                       module_args=None,
                       tmp=None,
                       task_vars=None):
        return {}

    task_vars = dict(
        openshift=dict(common=dict(service_type='origin')),
        openshift_image_tag='v0',
        openshift_deployment_type='origin',
    )

    check = OvsVersion(execute_module=execute_module)
    with pytest.raises(OpenShiftCheckException) as excinfo:
        check.run(tmp=None, task_vars=task_vars)
    assert "invalid version" in str(excinfo.value)
def test_openshift_version_not_supported():
    def execute_module(module_name=None, module_args=None, tmp=None, task_vars=None):
        return {}

    openshift_release = '111.7.0'

    task_vars = dict(
        openshift=dict(common=dict(service_type='origin')),
        openshift_release=openshift_release,
        openshift_image_tag='v' + openshift_release,
        openshift_deployment_type='origin',
    )

    check = OvsVersion(execute_module=execute_module)
    with pytest.raises(OpenShiftCheckException) as excinfo:
        check.run(tmp=None, task_vars=task_vars)

    assert "no recommended version of Open vSwitch" in str(excinfo.value)
def test_ovs_package_version(openshift_release, expected_ovs_version):
    task_vars = dict(
        openshift=dict(common=dict(service_type='origin')),
        openshift_release=openshift_release,
        openshift_image_tag='v' + openshift_release,
    )
    return_value = object()

    def execute_module(module_name=None, module_args=None, tmp=None, task_vars=None):
        assert module_name == 'rpm_version'
        assert "package_list" in module_args

        for pkg in module_args["package_list"]:
            if pkg["name"] == "openvswitch":
                assert pkg["version"] == expected_ovs_version

        return return_value

    check = OvsVersion(execute_module=execute_module)
    result = check.run(tmp=None, task_vars=task_vars)
    assert result is return_value
Exemplo n.º 9
0
def test_invalid_openshift_release_format():
    def execute_module(*_):
        return {}

    task_vars = dict(openshift=dict(common=dict()),
                     openshift_image_tag='v0',
                     openshift_deployment_type='origin',
                     openshift_service_type='origin')

    with pytest.raises(OpenShiftCheckException) as excinfo:
        OvsVersion(execute_module, task_vars).run()
    assert "invalid version" in str(excinfo.value)
def test_openshift_version_not_supported():
    def execute_module(module_name=None,
                       module_args=None,
                       tmp=None,
                       task_vars=None):
        return {}

    openshift_release = '111.7.0'

    task_vars = dict(
        openshift=dict(common=dict(service_type='origin')),
        openshift_release=openshift_release,
        openshift_image_tag='v' + openshift_release,
        openshift_deployment_type='origin',
    )

    check = OvsVersion(execute_module=execute_module)
    with pytest.raises(OpenShiftCheckException) as excinfo:
        check.run(tmp=None, task_vars=task_vars)

    assert "no recommended version of Open vSwitch" in str(excinfo.value)
Exemplo n.º 11
0
def test_openshift_version_not_supported():
    def execute_module(*_):
        return {}

    openshift_release = '111.7.0'

    task_vars = dict(openshift=dict(common=dict()),
                     openshift_release=openshift_release,
                     openshift_image_tag='v' + openshift_release,
                     openshift_deployment_type='origin',
                     openshift_service_type='origin')

    with pytest.raises(OpenShiftCheckException) as excinfo:
        OvsVersion(execute_module, task_vars).run()

    assert "no recommended version of Open vSwitch" in str(excinfo.value)
def test_ovs_version_skip_when_not_master_nor_node(group_names, is_containerized, is_active):
    task_vars = dict(
        group_names=group_names,
        openshift=dict(common=dict(is_containerized=is_containerized)),
    )
    assert OvsVersion.is_active(task_vars=task_vars) == is_active