ovs_version_test.py 2.4 KB

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