ovs_version_test.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import pytest
  2. from openshift_checks.ovs_version import OvsVersion, OpenShiftCheckException
  3. def test_openshift_version_not_supported():
  4. def execute_module(*_):
  5. return {}
  6. openshift_release = '111.7.0'
  7. task_vars = dict(
  8. openshift=dict(common=dict(service_type='origin')),
  9. openshift_release=openshift_release,
  10. openshift_image_tag='v' + openshift_release,
  11. openshift_deployment_type='origin',
  12. )
  13. with pytest.raises(OpenShiftCheckException) as excinfo:
  14. OvsVersion(execute_module, task_vars).run()
  15. assert "no recommended version of Open vSwitch" in str(excinfo.value)
  16. def test_invalid_openshift_release_format():
  17. def execute_module(*_):
  18. return {}
  19. task_vars = dict(
  20. openshift=dict(common=dict(service_type='origin')),
  21. openshift_image_tag='v0',
  22. openshift_deployment_type='origin',
  23. )
  24. with pytest.raises(OpenShiftCheckException) as excinfo:
  25. OvsVersion(execute_module, task_vars).run()
  26. assert "invalid version" in str(excinfo.value)
  27. @pytest.mark.parametrize('openshift_release,expected_ovs_version', [
  28. ("3.5", ["2.6", "2.7"]),
  29. ("3.6", ["2.6", "2.7"]),
  30. ("3.4", "2.4"),
  31. ("3.3", "2.4"),
  32. ("1.0", "2.4"),
  33. ])
  34. def test_ovs_package_version(openshift_release, expected_ovs_version):
  35. task_vars = dict(
  36. openshift=dict(common=dict(service_type='origin')),
  37. openshift_release=openshift_release,
  38. openshift_image_tag='v' + openshift_release,
  39. )
  40. return_value = {} # note: check.execute_module modifies return hash contents
  41. def execute_module(module_name=None, module_args=None, *_):
  42. assert module_name == 'rpm_version'
  43. assert "package_list" in module_args
  44. for pkg in module_args["package_list"]:
  45. if pkg["name"] == "openvswitch":
  46. assert pkg["version"] == expected_ovs_version
  47. return return_value
  48. result = OvsVersion(execute_module, task_vars).run()
  49. assert result is return_value
  50. @pytest.mark.parametrize('group_names,is_containerized,is_active', [
  51. (['oo_masters_to_config'], False, True),
  52. # ensure check is skipped on containerized installs
  53. (['oo_masters_to_config'], True, False),
  54. (['oo_nodes_to_config'], False, True),
  55. (['oo_masters_to_config', 'oo_nodes_to_config'], False, True),
  56. (['oo_masters_to_config', 'oo_etcd_to_config'], False, True),
  57. ([], False, False),
  58. (['oo_etcd_to_config'], False, False),
  59. (['lb'], False, False),
  60. (['nfs'], False, False),
  61. ])
  62. def test_ovs_version_skip_when_not_master_nor_node(group_names, is_containerized, is_active):
  63. task_vars = dict(
  64. group_names=group_names,
  65. openshift=dict(common=dict(is_containerized=is_containerized)),
  66. )
  67. assert OvsVersion(None, task_vars).is_active() == is_active