Skip to content

Commit c287f2d

Browse files
committed
Test Nginx SIGTERM handling
1 parent 23ecf47 commit c287f2d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

test/e2e/conftest.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ def tag(request):
1313

1414
@pytest.fixture
1515
def container(host, tag):
16-
container = host.check_output('docker run -p 80 --rm -d {}'.format(tag))
16+
container = host.check_output('docker run -p 80 -d {}'.format(tag))
1717
yield container
1818
host.check_output('docker stop {}'.format(container))
19+
20+
# Remove afterwads thus the tests still have access to the logs
21+
host.check_output('docker rm -f {}'.format(container))

test/e2e/test_nginx_entrypoint.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pytest
2+
3+
4+
@pytest.mark.nginx_e2e
5+
def test_nginx_sigterm_handling(host, container):
6+
log_level = host.run('docker exec -t {} sh -c "sed -i \'s/error_log .*;/error_log stderr notice;/g\' /etc/nginx/nginx.conf"'.format(container))
7+
assert log_level.rc is 0
8+
assert u'stderr notice' in host.check_output('docker exec -t {} cat /etc/nginx/nginx.conf'.format(container))
9+
10+
nginx_reload = host.run('docker exec -t {} sh -c "nginx -s reload"'.format(container))
11+
assert nginx_reload.rc is 0
12+
13+
nginx_stop = host.run('docker stop -t 3 {}'.format(container))
14+
assert nginx_reload.rc is 0
15+
16+
logs = host.run('docker logs {}'.format(container))
17+
18+
assert u'signal 15 (SIGTERM) received, exiting' in logs.stderr
19+
assert u'exit' in logs.stderr

0 commit comments

Comments
 (0)