mirror of
https://github.com/thib8956/nginx-proxy
synced 2024-11-22 11:56:31 +00:00
TESTS: abort test suite if the 'jwilder/nginx-proxy:test' image is missing
This commit is contained in:
parent
86be8a9424
commit
7a4cae050c
@ -130,8 +130,11 @@ def get_nginx_conf_from_container(container_id):
|
|||||||
|
|
||||||
|
|
||||||
def docker_compose_up(compose_file='docker-compose.yml'):
|
def docker_compose_up(compose_file='docker-compose.yml'):
|
||||||
subprocess.check_output(shlex.split('docker-compose -f %s up -d' % compose_file))
|
try:
|
||||||
|
subprocess.check_output(shlex.split('docker-compose -f %s up -d' % compose_file))
|
||||||
|
except subprocess.CalledProcessError, e:
|
||||||
|
logging.error("Error while runninng 'docker-compose -f %s up -d':\n%s" % (compose_file, e.output))
|
||||||
|
raise
|
||||||
|
|
||||||
def wait_for_nginxproxy_to_be_ready():
|
def wait_for_nginxproxy_to_be_ready():
|
||||||
"""
|
"""
|
||||||
@ -148,7 +151,6 @@ def wait_for_nginxproxy_to_be_ready():
|
|||||||
logging.debug("nginx-proxy ready")
|
logging.debug("nginx-proxy ready")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def find_docker_compose_file(request):
|
def find_docker_compose_file(request):
|
||||||
"""
|
"""
|
||||||
helper for fixture functions to figure out the name of the docker-compose file to consider.
|
helper for fixture functions to figure out the name of the docker-compose file to consider.
|
||||||
@ -182,6 +184,13 @@ def find_docker_compose_file(request):
|
|||||||
return docker_compose_file
|
return docker_compose_file
|
||||||
|
|
||||||
|
|
||||||
|
def check_sut_image():
|
||||||
|
"""
|
||||||
|
Return True if jwilder/nginx-proxy:test image exists
|
||||||
|
"""
|
||||||
|
docker_client = docker.from_env()
|
||||||
|
return any(map(lambda x: "jwilder/nginx-proxy:test" in x.get('RepoTags'), docker_client.images()))
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
# Py.test fixtures
|
# Py.test fixtures
|
||||||
@ -197,6 +206,8 @@ def docker_compose(request):
|
|||||||
"""
|
"""
|
||||||
docker_compose_file = find_docker_compose_file(request)
|
docker_compose_file = find_docker_compose_file(request)
|
||||||
original_dns_resolver = monkey_patch_urllib_dns_resolver()
|
original_dns_resolver = monkey_patch_urllib_dns_resolver()
|
||||||
|
if not check_sut_image():
|
||||||
|
pytest.exit("The docker image 'jwilder/nginx-proxy:test' is missing")
|
||||||
remove_all_containers()
|
remove_all_containers()
|
||||||
docker_compose_up(docker_compose_file)
|
docker_compose_up(docker_compose_file)
|
||||||
wait_for_nginxproxy_to_be_ready()
|
wait_for_nginxproxy_to_be_ready()
|
||||||
|
Loading…
Reference in New Issue
Block a user