Compare commits
2 commits
main
...
test/nginx
Author | SHA1 | Date | |
---|---|---|---|
![]() |
35c1d16ff8 | ||
![]() |
3d9d91b043 |
4 changed files with 39 additions and 2 deletions
|
@ -84,11 +84,18 @@ class requests_for_docker(object):
|
||||||
|
|
||||||
def get_conf(self):
|
def get_conf(self):
|
||||||
"""
|
"""
|
||||||
Return the nginx config file
|
Return the generated nginx config file
|
||||||
"""
|
"""
|
||||||
nginx_proxy_containers = self.get_nginx_proxy_containers()
|
nginx_proxy_containers = self.get_nginx_proxy_containers()
|
||||||
return get_nginx_conf_from_container(nginx_proxy_containers[0])
|
return get_nginx_conf_from_container(nginx_proxy_containers[0])
|
||||||
|
|
||||||
|
def get_toplevel_conf(self):
|
||||||
|
"""
|
||||||
|
Return the top level nginx config file
|
||||||
|
"""
|
||||||
|
nginx_proxy_containers = self.get_nginx_proxy_containers()
|
||||||
|
return get_nginx_toplevel_conf_from_container(nginx_proxy_containers[0])
|
||||||
|
|
||||||
def get_ip(self) -> str:
|
def get_ip(self) -> str:
|
||||||
"""
|
"""
|
||||||
Return the nginx container ip address
|
Return the nginx container ip address
|
||||||
|
@ -301,6 +308,21 @@ def get_nginx_conf_from_container(container):
|
||||||
return conffile.read()
|
return conffile.read()
|
||||||
|
|
||||||
|
|
||||||
|
def get_nginx_toplevel_conf_from_container(container):
|
||||||
|
"""
|
||||||
|
return the nginx /etc/nginx/nginx.conf file content from a container
|
||||||
|
"""
|
||||||
|
import tarfile
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
strm_generator, stat = container.get_archive('/etc/nginx/nginx.conf')
|
||||||
|
strm_fileobj = BytesIO(b"".join(strm_generator))
|
||||||
|
|
||||||
|
with tarfile.open(fileobj=strm_fileobj) as tf:
|
||||||
|
conffile = tf.extractfile('nginx.conf')
|
||||||
|
return conffile.read()
|
||||||
|
|
||||||
|
|
||||||
def docker_compose_up(compose_file='docker-compose.yml'):
|
def docker_compose_up(compose_file='docker-compose.yml'):
|
||||||
logging.info(f'{DOCKER_COMPOSE} -f {compose_file} up -d')
|
logging.info(f'{DOCKER_COMPOSE} -f {compose_file} up -d')
|
||||||
try:
|
try:
|
||||||
|
|
8
test/test_nginx-conf/test_nginx-conf.py
Normal file
8
test/test_nginx-conf/test_nginx-conf.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import pytest
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def test_nginx_toplevel_conf_contains_customizations(docker_compose, nginxproxy):
|
||||||
|
conf = nginxproxy.get_toplevel_conf().decode('ASCII')
|
||||||
|
assert re.search(r"^ +worker_connections 10240;$", conf)
|
||||||
|
assert re.search(r"^worker_rlimit_nofile 20480;$", conf)
|
7
test/test_nginx-conf/test_nginx-conf.yml
Normal file
7
test/test_nginx-conf/test_nginx-conf.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
version: "2"
|
||||||
|
|
||||||
|
services:
|
||||||
|
sut:
|
||||||
|
image: nginxproxy/nginx-proxy:test
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
Loading…
Reference in a new issue