diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2018-05-30 19:29:40 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2018-05-30 19:29:40 +0300 |
commit | 857bddeea613cdf7ce0f9228ec6601285bf3bde7 (patch) | |
tree | ad5690f69f5b90b18945dddad26bf6a532123b75 /test/test_python_application.py | |
parent | ff6ca2a82c956807e28bb290efa70e791e1f8f8d (diff) | |
download | unit-857bddeea613cdf7ce0f9228ec6601285bf3bde7.tar.gz unit-857bddeea613cdf7ce0f9228ec6601285bf3bde7.tar.bz2 |
Tests: added keep-alive with reconfiguration test.
Diffstat (limited to 'test/test_python_application.py')
-rw-r--r-- | test/test_python_application.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/test_python_application.py b/test/test_python_application.py index 39fd970c..3a3921d9 100644 --- a/test/test_python_application.py +++ b/test/test_python_application.py @@ -109,6 +109,58 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): self.assertEqual(resp['body'], '0123456789', 'keep-alive 2') + def test_python_keepalive_reconfigure(self): + self.skip_alerts.extend([ + r'sendmsg.+failed', + r'recvmsg.+failed' + ]) + self.load('mirror') + + body = '0123456789' + conns = 3 + socks = [] + + for i in range(conns): + (resp, sock) = self.post(headers={ + 'Connection': 'keep-alive', + 'Content-Type': 'text/html', + 'Host': 'localhost' + }, start=True, body=body) + + self.assertEqual(resp['body'], body, 'keep-alive open') + self.assertIn('success', self.conf({ + "spare": i % 4, + "max": (i % 4) + 1 + }, '/applications/mirror/processes'), 'reconfigure') + + socks.append(sock) + + for i in range(conns): + (resp, sock) = self.post(headers={ + 'Connection': 'keep-alive', + 'Content-Type': 'text/html', + 'Host': 'localhost' + }, start=True, sock=socks[i], body=body) + + self.assertEqual(resp['body'], body, 'keep-alive request') + self.assertIn('success', self.conf({ + "spare": i % 4, + "max": (i % 4) + 1 + }, '/applications/mirror/processes'), 'reconfigure 2') + + for i in range(conns): + resp = self.post(headers={ + 'Connection': 'close', + 'Content-Type': 'text/html', + 'Host': 'localhost' + }, sock=socks[i], body=body) + + self.assertEqual(resp['body'], body, 'keep-alive close') + self.assertIn('success', self.conf({ + "spare": i % 4, + "max": (i % 4) + 1 + }, '/applications/mirror/processes'), 'reconfigure 3') + def test_python_atexit(self): self.skip_alerts.append(r'sendmsg.+failed') self.load('atexit') |