test: get full nginx config from container

This commit is contained in:
Nicolas Duchon 2024-05-08 00:31:37 +02:00
parent f964176106
commit 3d9d91b043

View file

@ -288,17 +288,13 @@ def remove_all_containers():
def get_nginx_conf_from_container(container): def get_nginx_conf_from_container(container):
""" """
return the nginx /etc/nginx/conf.d/default.conf file content from a container return the full nginx config from a container
""" """
import tarfile
from io import BytesIO from io import BytesIO
strm_generator, stat = container.get_archive('/etc/nginx/conf.d/default.conf') _, strm_generator = container.exec_run("nginx -T", stream = True)
strm_fileobj = BytesIO(b"".join(strm_generator)) strm_fileobj = BytesIO(b"".join(strm_generator))
return strm_fileobj.read()
with tarfile.open(fileobj=strm_fileobj) as tf:
conffile = tf.extractfile('default.conf')
return conffile.read()
def docker_compose_up(compose_file='docker-compose.yml'): def docker_compose_up(compose_file='docker-compose.yml'):