summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2021-05-18 16:35:54 +0100
committerAndrei Zeliankou <zelenkov@nginx.com>2021-05-18 16:35:54 +0100
commit2f0cca2e2b48f3f96056bac14e216f1248f8d4a8 (patch)
tree852082ff1db5e4b5fd2ae8e039b67c304b5c6d0e /test
parentead6ed999a87fac6fc9ad3f4f94a6cec1d287b5e (diff)
downloadunit-2f0cca2e2b48f3f96056bac14e216f1248f8d4a8.tar.gz
unit-2f0cca2e2b48f3f96056bac14e216f1248f8d4a8.tar.bz2
Tests: added test to check port release.
Diffstat (limited to 'test')
-rw-r--r--test/test_configuration.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_configuration.py b/test/test_configuration.py
index 7feb3adb..880aef6c 100644
--- a/test/test_configuration.py
+++ b/test/test_configuration.py
@@ -1,5 +1,6 @@
import pytest
+import socket
from unit.control import TestControl
@@ -261,6 +262,33 @@ class TestConfiguration(TestControl):
}
), 'explicit ipv6'
+ def test_listeners_port_release(self):
+ for i in range(10):
+ fail = False
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
+ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+
+ self.conf(
+ {
+ "listeners": {"127.0.0.1:7080": {"pass": "routes"}},
+ "routes": [],
+ }
+ )
+
+ resp = self.conf({"listeners": {}, "applications": {}})
+
+ try:
+ s.bind(('127.0.0.1', 7080))
+ s.listen()
+
+ except OSError:
+ fail = True
+
+ if fail:
+ pytest.fail('cannot bind or listen to the address')
+
+ assert 'success' in resp, 'port release'
+
@pytest.mark.skip('not yet, unsafe')
def test_listeners_no_port(self):
assert 'error' in self.conf(