def test_all_images_available_remotely(task_vars, available_locally): def execute_module(module_name, *_): if module_name == 'docker_image_facts': return {'images': [], 'failed': available_locally} return {} task_vars['openshift_docker_additional_registries'] = ["docker.io", "registry.access.redhat.com"] task_vars['openshift_image_tag'] = 'v3.4' check = DockerImageAvailability(execute_module, task_vars) check._module_retry_interval = 0 result = check.run() assert not result.get('failed', False)
def test_registry_availability(image, registries, connection_test_failed, skopeo_failed, expect_success, expect_registries_reached): def execute_module(module_name=None, *_): if module_name == "wait_for": return dict(msg="msg", failed=connection_test_failed) elif module_name == "command": return dict(msg="msg", failed=skopeo_failed) check = DockerImageAvailability(execute_module, task_vars()) check._module_retry_interval = 0 available = check.is_available_skopeo_image(image, registries) assert available == expect_success assert expect_registries_reached == check.reachable_registries
def test_all_images_unavailable(task_vars): def execute_module(module_name=None, *args): if module_name == "wait_for": return {} elif module_name == "command": return {'failed': True} return {} # docker_image_facts failure task_vars['openshift_docker_additional_registries'] = ["docker.io"] task_vars['openshift_deployment_type'] = "openshift-enterprise" task_vars['openshift_image_tag'] = 'latest' check = DockerImageAvailability(execute_module, task_vars) check._module_retry_interval = 0 actual = check.run() assert actual['failed'] assert "required container images are not available" in actual['msg']
def test_skopeo_update_failure(task_vars, message, extra_words): def execute_module(module_name=None, *_): if module_name == "yum": return { "failed": True, "msg": message, } return {} task_vars['openshift_docker_additional_registries'] = ["unknown.io"] task_vars['openshift_deployment_type'] = "openshift-enterprise" check = DockerImageAvailability(execute_module, task_vars) check._module_retry_interval = 0 actual = check.run() assert actual["failed"] for word in extra_words: assert word in actual["msg"]