Skip to content

Commit

Permalink
Test Nginx SIGTERM handling
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomefi committed Apr 16, 2019
1 parent 23ecf47 commit c287f2d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def tag(request):

@pytest.fixture
def container(host, tag):
container = host.check_output('docker run -p 80 --rm -d {}'.format(tag))
container = host.check_output('docker run -p 80 -d {}'.format(tag))
yield container
host.check_output('docker stop {}'.format(container))

# Remove afterwads thus the tests still have access to the logs
host.check_output('docker rm -f {}'.format(container))
19 changes: 19 additions & 0 deletions test/e2e/test_nginx_entrypoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest


@pytest.mark.nginx_e2e
def test_nginx_sigterm_handling(host, container):
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))
assert log_level.rc is 0
assert u'stderr notice' in host.check_output('docker exec -t {} cat /etc/nginx/nginx.conf'.format(container))

nginx_reload = host.run('docker exec -t {} sh -c "nginx -s reload"'.format(container))
assert nginx_reload.rc is 0

nginx_stop = host.run('docker stop -t 3 {}'.format(container))
assert nginx_reload.rc is 0

logs = host.run('docker logs {}'.format(container))

assert u'signal 15 (SIGTERM) received, exiting' in logs.stderr
assert u'exit' in logs.stderr

0 comments on commit c287f2d

Please sign in to comment.