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_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
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_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