package_version_test.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import pytest
  2. from openshift_checks.package_version import PackageVersion
  3. def task_vars_for(openshift_release, deployment_type):
  4. service_type_dict = {'origin': 'origin',
  5. 'openshift-enterprise': 'atomic-openshift'}
  6. service_type = service_type_dict[deployment_type]
  7. return dict(
  8. ansible_pkg_mgr='yum',
  9. openshift_service_type=service_type,
  10. openshift_release=openshift_release,
  11. openshift_image_tag='v' + openshift_release,
  12. openshift_deployment_type=deployment_type,
  13. )
  14. @pytest.mark.parametrize('openshift_release', [
  15. "111.7.0",
  16. "3.7",
  17. "3.6",
  18. "3.5.1.2.3",
  19. "3.5",
  20. "3.4",
  21. "3.3",
  22. "2.1.0",
  23. ])
  24. def test_package_version(openshift_release):
  25. return_value = {"foo": object()}
  26. def execute_module(module_name=None, module_args=None, tmp=None, task_vars=None, *_):
  27. assert module_name == 'aos_version'
  28. assert "package_list" in module_args
  29. for pkg in module_args["package_list"]:
  30. if "-master" in pkg["name"] or "-node" in pkg["name"]:
  31. assert pkg["version"] == task_vars["openshift_release"]
  32. return return_value
  33. check = PackageVersion(execute_module, task_vars_for(openshift_release, 'origin'))
  34. result = check.run()
  35. assert result == return_value
  36. @pytest.mark.parametrize('group_names,openshift_is_atomic,is_active', [
  37. (['oo_masters_to_config'], False, True),
  38. # ensure check is skipped on containerized installs
  39. (['oo_masters_to_config'], True, False),
  40. (['oo_nodes_to_config'], False, True),
  41. (['oo_masters_to_config', 'oo_nodes_to_config'], False, True),
  42. (['oo_masters_to_config', 'oo_etcd_to_config'], False, True),
  43. ([], False, False),
  44. (['oo_etcd_to_config'], False, False),
  45. (['lb'], False, False),
  46. (['nfs'], False, False),
  47. ])
  48. def test_package_version_skip_when_not_master_nor_node(group_names, openshift_is_atomic, is_active):
  49. task_vars = dict(
  50. group_names=group_names,
  51. openshift_is_atomic=openshift_is_atomic,
  52. )
  53. assert PackageVersion(None, task_vars).is_active() == is_active