package_version_test.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import pytest
  2. from openshift_checks.package_version import PackageVersion
  3. def test_package_version():
  4. task_vars = dict(
  5. openshift=dict(common=dict(service_type='origin')),
  6. openshift_release='3.5',
  7. openshift_deployment_type='origin',
  8. )
  9. return_value = object()
  10. def execute_module(module_name=None, module_args=None, tmp=None, task_vars=None):
  11. assert module_name == 'aos_version'
  12. assert 'requested_openshift_release' in module_args
  13. assert 'openshift_deployment_type' in module_args
  14. assert 'rpm_prefix' in module_args
  15. assert module_args['requested_openshift_release'] == task_vars['openshift_release']
  16. assert module_args['openshift_deployment_type'] == task_vars['openshift_deployment_type']
  17. assert module_args['rpm_prefix'] == task_vars['openshift']['common']['service_type']
  18. return return_value
  19. check = PackageVersion(execute_module=execute_module)
  20. result = check.run(tmp=None, task_vars=task_vars)
  21. assert result is return_value
  22. @pytest.mark.parametrize('group_names,is_containerized,is_active', [
  23. (['masters'], False, True),
  24. # ensure check is skipped on containerized installs
  25. (['masters'], True, False),
  26. (['nodes'], False, True),
  27. (['masters', 'nodes'], False, True),
  28. (['masters', 'etcd'], False, True),
  29. ([], False, False),
  30. (['etcd'], False, False),
  31. (['lb'], False, False),
  32. (['nfs'], False, False),
  33. ])
  34. def test_package_version_skip_when_not_master_nor_node(group_names, is_containerized, is_active):
  35. task_vars = dict(
  36. group_names=group_names,
  37. openshift=dict(common=dict(is_containerized=is_containerized)),
  38. )
  39. assert PackageVersion.is_active(task_vars=task_vars) == is_active