From ea844a4444c2daa6d4f756663a96b13ee45a5aeb Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Fri, 1 Mar 2019 18:58:16 +0300 Subject: Tests: skip more alerts. --- test/test_configuration.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/test_configuration.py') diff --git a/test/test_configuration.py b/test/test_configuration.py index 52a67d38..67a8946e 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -241,8 +241,8 @@ class TestUnitConfiguration(unit.TestUnitControl): def test_json_application_many(self): self.skip_alerts.extend([ r'eventfd.+failed', - r'epoll_create.+failed', - r'failed to apply new conf' + r'epoll.+failed', + r'failed to apply' ]) apps = 999 -- cgit From e1c4568680b63c478e8a0e111d8ad9316a96c442 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Tue, 5 Mar 2019 15:38:52 +0300 Subject: Introducing one more large config test, but without sockets. --- test/test_configuration.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/test_configuration.py') diff --git a/test/test_configuration.py b/test/test_configuration.py index 67a8946e..de20ac25 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -264,5 +264,30 @@ class TestUnitConfiguration(unit.TestUnitControl): self.assertIn('success', self.conf(conf)) + def test_json_application_many2(self): + self.skip_alerts.extend([ + r'eventfd.+failed', + r'epoll.+failed', + r'failed to apply' + ]) + + conf = { + "applications": + {"app-" + str(a): { + "type": "python", + "processes": { "spare": 0 }, + "path": "/app", + "module": "wsgi" + } for a in range(999) + }, + "listeners": { + "*:7001": { + "application": "app-1" + } + } + } + + self.assertIn('success', self.conf(conf)) + if __name__ == '__main__': TestUnitConfiguration.main() -- cgit From b96e5fd8481f79935967fed56c71f72d16c59f6b Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Mon, 25 Mar 2019 14:49:28 +0300 Subject: Turning off port read event state after main process fork. Master port stores two file descriptors and works as a read port on the master process side. After a fork, the port switches into write mode and the read socket closes, but the same event structure is used for the write socket. However, the inherited structure remained in read state, telling the epoll engine to use MOD operation instead of ADD. The patch resets read event state, so the engine may write using proper ADD operation. --- test/test_configuration.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'test/test_configuration.py') diff --git a/test/test_configuration.py b/test/test_configuration.py index de20ac25..20c5fc8b 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -216,9 +216,7 @@ class TestUnitConfiguration(unit.TestUnitControl): } }), 'no port') - @unittest.expectedFailure def test_json_application_name_large(self): - self.skip_alerts.append(r'epoll_ctl.+failed') name = "X" * 1024 * 1024 self.assertIn('success', self.conf({ -- cgit From 281899fcef10eaf815d90958d49243c5060ffac0 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Tue, 26 Mar 2019 23:38:30 +0300 Subject: Tests: style. --- test/test_configuration.py | 400 ++++++++++++++++++++++++++------------------- 1 file changed, 235 insertions(+), 165 deletions(-) (limited to 'test/test_configuration.py') diff --git a/test/test_configuration.py b/test/test_configuration.py index 20c5fc8b..4848f741 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -1,8 +1,8 @@ import unittest import unit -class TestUnitConfiguration(unit.TestUnitControl): +class TestUnitConfiguration(unit.TestUnitControl): def setUpClass(): unit.TestUnit().check_modules('python') @@ -13,7 +13,10 @@ class TestUnitConfiguration(unit.TestUnitControl): self.assertIn('error', self.conf('00'), 'leading zero') def test_json_unicode(self): - self.assertIn('success', self.conf(b""" + self.assertIn( + 'success', + self.conf( + b""" { "ap\u0070": { "type": "\u0070ython", @@ -22,32 +25,51 @@ class TestUnitConfiguration(unit.TestUnitControl): "module": "wsgi" } } - """, 'applications'), 'unicode') - - self.assertDictEqual(self.conf_get('applications'), { - "app": { - "type": "python", - "processes": { "spare": 0 }, - "path": "/app", - "module": "wsgi" - } - }, 'unicode get') + """, + 'applications', + ), + 'unicode', + ) + + self.assertDictEqual( + self.conf_get('applications'), + { + "app": { + "type": "python", + "processes": {"spare": 0}, + "path": "/app", + "module": "wsgi", + } + }, + 'unicode get', + ) def test_json_unicode_2(self): - self.assertIn('success', self.conf({ - "приложение": { - "type": "python", - "processes": { "spare": 0 }, - "path": "/app", - "module": "wsgi" - } - }, 'applications'), 'unicode 2') - - self.assertIn('приложение', self.conf_get('applications'), - 'unicode 2 get') + self.assertIn( + 'success', + self.conf( + { + "приложение": { + "type": "python", + "processes": {"spare": 0}, + "path": "/app", + "module": "wsgi", + } + }, + 'applications', + ), + 'unicode 2', + ) + + self.assertIn( + 'приложение', self.conf_get('applications'), 'unicode 2 get' + ) def test_json_unicode_number(self): - self.assertIn('error', self.conf(b""" + self.assertIn( + 'error', + self.conf( + b""" { "app": { "type": "python", @@ -56,7 +78,11 @@ class TestUnitConfiguration(unit.TestUnitControl): "module": "wsgi" } } - """, 'applications'), 'unicode number') + """, + 'applications', + ), + 'unicode number', + ) def test_applications_open_brace(self): self.assertIn('error', self.conf('{', 'applications'), 'open brace') @@ -65,20 +91,25 @@ class TestUnitConfiguration(unit.TestUnitControl): self.assertIn('error', self.conf('"{}"', 'applications'), 'string') def test_applications_type_only(self): - self.skip_alerts.extend([ - r'python module is empty', - r'failed to apply new conf', - r'process \d+ exited on signal' - ]) - - self.assertIn('error', self.conf({ - "app": { - "type": "python" - } - }, 'applications'), 'type only') + self.skip_alerts.extend( + [ + r'python module is empty', + r'failed to apply new conf', + r'process \d+ exited on signal', + ] + ) + + self.assertIn( + 'error', + self.conf({"app": {"type": "python"}}, 'applications'), + 'type only', + ) def test_applications_miss_quote(self): - self.assertIn('error', self.conf(""" + self.assertIn( + 'error', + self.conf( + """ { app": { "type": "python", @@ -87,10 +118,17 @@ class TestUnitConfiguration(unit.TestUnitControl): "module": "wsgi" } } - """, 'applications'), 'miss quote') + """, + 'applications', + ), + 'miss quote', + ) def test_applications_miss_colon(self): - self.assertIn('error', self.conf(""" + self.assertIn( + 'error', + self.conf( + """ { "app" { "type": "python", @@ -99,10 +137,17 @@ class TestUnitConfiguration(unit.TestUnitControl): "module": "wsgi" } } - """, 'applications'), 'miss colon') + """, + 'applications', + ), + 'miss colon', + ) def test_applications_miss_comma(self): - self.assertIn('error', self.conf(""" + self.assertIn( + 'error', + self.conf( + """ { "app": { "type": "python" @@ -111,181 +156,206 @@ class TestUnitConfiguration(unit.TestUnitControl): "module": "wsgi" } } - """, 'applications'), 'miss comma') + """, + 'applications', + ), + 'miss comma', + ) def test_applications_skip_spaces(self): - self.assertIn('success', self.conf(b'{ \n\r\t}', 'applications'), - 'skip spaces') + self.assertIn( + 'success', self.conf(b'{ \n\r\t}', 'applications'), 'skip spaces' + ) def test_applications_relative_path(self): - self.assertIn('success', self.conf({ - "app": { - "type": "python", - "processes": { "spare": 0 }, - "path": "../app", - "module": "wsgi" - } - }, 'applications'), 'relative path') + self.assertIn( + 'success', + self.conf( + { + "app": { + "type": "python", + "processes": {"spare": 0}, + "path": "../app", + "module": "wsgi", + } + }, + 'applications', + ), + 'relative path', + ) @unittest.expectedFailure def test_listeners_empty(self): self.skip_sanitizer = True - self.skip_alerts.extend([ - r'failed to apply previous configuration', - r'process \d+ exited on signal' - ]) + self.skip_alerts.extend( + [ + r'failed to apply previous configuration', + r'process \d+ exited on signal', + ] + ) - self.assertIn('error', self.conf({"*:7080":{}}, 'listeners'), - 'listener empty') + self.assertIn( + 'error', self.conf({"*:7080": {}}, 'listeners'), 'listener empty' + ) def test_listeners_no_app(self): - self.assertIn('error', self.conf({"*:7080":{"application":"app"}}, - 'listeners'), 'listeners no app') + self.assertIn( + 'error', + self.conf({"*:7080": {"application": "app"}}, 'listeners'), + 'listeners no app', + ) def test_listeners_wildcard(self): - self.assertIn('success', self.conf({ - "listeners": { - "*:7080": { - "application":"app" + self.assertIn( + 'success', + self.conf( + { + "listeners": {"*:7080": {"application": "app"}}, + "applications": { + "app": { + "type": "python", + "processes": {"spare": 0}, + "path": "/app", + "module": "wsgi", + } + }, } - }, - "applications": { - "app": { - "type": "python", - "processes": { "spare": 0 }, - "path": "/app", - "module": "wsgi" - } - } - }), 'listeners wildcard') + ), + 'listeners wildcard', + ) def test_listeners_explicit(self): - self.assertIn('success', self.conf({ - "listeners": { - "127.0.0.1:7080": { - "application":"app" + self.assertIn( + 'success', + self.conf( + { + "listeners": {"127.0.0.1:7080": {"application": "app"}}, + "applications": { + "app": { + "type": "python", + "processes": {"spare": 0}, + "path": "/app", + "module": "wsgi", + } + }, } - }, - "applications": { - "app": { - "type": "python", - "processes": { "spare": 0 }, - "path": "/app", - "module": "wsgi" - } - } - }), 'explicit') + ), + 'explicit', + ) def test_listeners_explicit_ipv6(self): - self.assertIn('success', self.conf({ - "listeners": { - "[::1]:7080": { - "application":"app" + self.assertIn( + 'success', + self.conf( + { + "listeners": {"[::1]:7080": {"application": "app"}}, + "applications": { + "app": { + "type": "python", + "processes": {"spare": 0}, + "path": "/app", + "module": "wsgi", + } + }, } - }, - "applications": { - "app": { - "type": "python", - "processes": { "spare": 0 }, - "path": "/app", - "module": "wsgi" - } - } - }), 'explicit ipv6') + ), + 'explicit ipv6', + ) def test_listeners_no_port(self): - self.skip_alerts.extend([ - r'invalid listener "127\.0\.0\.1"', - r'failed to apply new conf', - r'process \d+ exited on signal' - ]) - - self.assertIn('error', self.conf({ - "listeners": { - "127.0.0.1": { - "application":"app" + self.skip_alerts.extend( + [ + r'invalid listener "127\.0\.0\.1"', + r'failed to apply new conf', + r'process \d+ exited on signal', + ] + ) + + self.assertIn( + 'error', + self.conf( + { + "listeners": {"127.0.0.1": {"application": "app"}}, + "applications": { + "app": { + "type": "python", + "processes": {"spare": 0}, + "path": "/app", + "module": "wsgi", + } + }, } - }, - "applications": { - "app": { - "type": "python", - "processes": { "spare": 0 }, - "path": "/app", - "module": "wsgi" - } - } - }), 'no port') + ), + 'no port', + ) def test_json_application_name_large(self): name = "X" * 1024 * 1024 - self.assertIn('success', self.conf({ - "listeners": { - "*:7080": { - "application": name - } - }, - "applications": { - name: { - "type": "python", - "processes": { "spare": 0 }, - "path": "/app", - "module": "wsgi" + self.assertIn( + 'success', + self.conf( + { + "listeners": {"*:7080": {"application": name}}, + "applications": { + name: { + "type": "python", + "processes": {"spare": 0}, + "path": "/app", + "module": "wsgi", + } + }, } - } - })) + ), + ) @unittest.expectedFailure def test_json_application_many(self): - self.skip_alerts.extend([ - r'eventfd.+failed', - r'epoll.+failed', - r'failed to apply' - ]) + self.skip_alerts.extend( + [r'eventfd.+failed', r'epoll.+failed', r'failed to apply'] + ) apps = 999 conf = { - "applications": - {"app-" + str(a): { + "applications": { + "app-" + + str(a): { "type": "python", - "processes": { "spare": 0 }, + "processes": {"spare": 0}, "path": "/app", - "module": "wsgi" - } for a in range(apps) + "module": "wsgi", + } + for a in range(apps) }, "listeners": { - "*:" + str(7000 + a): { - "application": "app-" + str(a) - } for a in range(apps) - } + "*:" + str(7000 + a): {"application": "app-" + str(a)} + for a in range(apps) + }, } self.assertIn('success', self.conf(conf)) def test_json_application_many2(self): - self.skip_alerts.extend([ - r'eventfd.+failed', - r'epoll.+failed', - r'failed to apply' - ]) + self.skip_alerts.extend( + [r'eventfd.+failed', r'epoll.+failed', r'failed to apply'] + ) conf = { - "applications": - {"app-" + str(a): { + "applications": { + "app-" + + str(a): { "type": "python", - "processes": { "spare": 0 }, + "processes": {"spare": 0}, "path": "/app", - "module": "wsgi" - } for a in range(999) - }, - "listeners": { - "*:7001": { - "application": "app-1" + "module": "wsgi", } - } + for a in range(999) + }, + "listeners": {"*:7001": {"application": "app-1"}}, } self.assertIn('success', self.conf(conf)) + if __name__ == '__main__': TestUnitConfiguration.main() -- cgit From 19eba1730a1ca839ed62a37f34c204f580d1b653 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Thu, 28 Mar 2019 18:43:13 +0300 Subject: Tests: unit module refactoring. --- test/test_configuration.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/test_configuration.py') diff --git a/test/test_configuration.py b/test/test_configuration.py index 4848f741..eb56a548 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -1,10 +1,10 @@ import unittest -import unit +from unit.control import TestControl -class TestUnitConfiguration(unit.TestUnitControl): +class TestConfiguration(TestControl): def setUpClass(): - unit.TestUnit().check_modules('python') + TestControl().check_modules('python') def test_json_empty(self): self.assertIn('error', self.conf(''), 'empty') @@ -358,4 +358,4 @@ class TestUnitConfiguration(unit.TestUnitControl): if __name__ == '__main__': - TestUnitConfiguration.main() + TestConfiguration.main() -- cgit From af24e4dec453af7e3dcb45347cb59bfcbc037843 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Tue, 9 Apr 2019 16:14:42 +0300 Subject: Tests: simplified module checking. --- test/test_configuration.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test/test_configuration.py') diff --git a/test/test_configuration.py b/test/test_configuration.py index eb56a548..74596ed8 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -3,8 +3,7 @@ from unit.control import TestControl class TestConfiguration(TestControl): - def setUpClass(): - TestControl().check_modules('python') + prerequisites = ['python'] def test_json_empty(self): self.assertIn('error', self.conf(''), 'empty') -- cgit From c1a3b06d03c01e4ed40018944b90e6347ebf77d7 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Mon, 22 Apr 2019 18:20:53 +0300 Subject: Tests: using "pass" option instead of deprecated "application". --- test/test_configuration.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/test_configuration.py') diff --git a/test/test_configuration.py b/test/test_configuration.py index 74596ed8..51c6f6a2 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -200,7 +200,7 @@ class TestConfiguration(TestControl): def test_listeners_no_app(self): self.assertIn( 'error', - self.conf({"*:7080": {"application": "app"}}, 'listeners'), + self.conf({"*:7080": {"pass": "applications/app"}}, 'listeners'), 'listeners no app', ) @@ -209,7 +209,7 @@ class TestConfiguration(TestControl): 'success', self.conf( { - "listeners": {"*:7080": {"application": "app"}}, + "listeners": {"*:7080": {"pass": "applications/app"}}, "applications": { "app": { "type": "python", @@ -228,7 +228,7 @@ class TestConfiguration(TestControl): 'success', self.conf( { - "listeners": {"127.0.0.1:7080": {"application": "app"}}, + "listeners": {"127.0.0.1:7080": {"pass": "applications/app"}}, "applications": { "app": { "type": "python", @@ -247,7 +247,7 @@ class TestConfiguration(TestControl): 'success', self.conf( { - "listeners": {"[::1]:7080": {"application": "app"}}, + "listeners": {"[::1]:7080": {"pass": "applications/app"}}, "applications": { "app": { "type": "python", @@ -274,7 +274,7 @@ class TestConfiguration(TestControl): 'error', self.conf( { - "listeners": {"127.0.0.1": {"application": "app"}}, + "listeners": {"127.0.0.1": {"pass": "applications/app"}}, "applications": { "app": { "type": "python", @@ -295,7 +295,7 @@ class TestConfiguration(TestControl): 'success', self.conf( { - "listeners": {"*:7080": {"application": name}}, + "listeners": {"*:7080": {"pass": "applications/" + name}}, "applications": { name: { "type": "python", @@ -327,7 +327,7 @@ class TestConfiguration(TestControl): for a in range(apps) }, "listeners": { - "*:" + str(7000 + a): {"application": "app-" + str(a)} + "*:" + str(7000 + a): {"pass": "applications/app-" + str(a)} for a in range(apps) }, } @@ -350,7 +350,7 @@ class TestConfiguration(TestControl): } for a in range(999) }, - "listeners": {"*:7001": {"application": "app-1"}}, + "listeners": {"*:7001": {"pass": "applications/app-1"}}, } self.assertIn('success', self.conf(conf)) -- cgit From 90c5d3f5c0ad42ccdb764684f721b511131e0782 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Thu, 30 May 2019 16:46:04 +0300 Subject: Tests: adjusted skipping tests. --- test/test_configuration.py | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) (limited to 'test/test_configuration.py') diff --git a/test/test_configuration.py b/test/test_configuration.py index 51c6f6a2..6e59c0a7 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -89,15 +89,8 @@ class TestConfiguration(TestControl): def test_applications_string(self): self.assertIn('error', self.conf('"{}"', 'applications'), 'string') + @unittest.skip('not yet, unsafe') def test_applications_type_only(self): - self.skip_alerts.extend( - [ - r'python module is empty', - r'failed to apply new conf', - r'process \d+ exited on signal', - ] - ) - self.assertIn( 'error', self.conf({"app": {"type": "python"}}, 'applications'), @@ -183,16 +176,8 @@ class TestConfiguration(TestControl): 'relative path', ) - @unittest.expectedFailure + @unittest.skip('not yet, unsafe') def test_listeners_empty(self): - self.skip_sanitizer = True - self.skip_alerts.extend( - [ - r'failed to apply previous configuration', - r'process \d+ exited on signal', - ] - ) - self.assertIn( 'error', self.conf({"*:7080": {}}, 'listeners'), 'listener empty' ) @@ -261,15 +246,8 @@ class TestConfiguration(TestControl): 'explicit ipv6', ) + @unittest.skip('not yet, unsafe') def test_listeners_no_port(self): - self.skip_alerts.extend( - [ - r'invalid listener "127\.0\.0\.1"', - r'failed to apply new conf', - r'process \d+ exited on signal', - ] - ) - self.assertIn( 'error', self.conf( @@ -308,11 +286,8 @@ class TestConfiguration(TestControl): ), ) - @unittest.expectedFailure + @unittest.skip('not yet') def test_json_application_many(self): - self.skip_alerts.extend( - [r'eventfd.+failed', r'epoll.+failed', r'failed to apply'] - ) apps = 999 conf = { @@ -335,10 +310,6 @@ class TestConfiguration(TestControl): self.assertIn('success', self.conf(conf)) def test_json_application_many2(self): - self.skip_alerts.extend( - [r'eventfd.+failed', r'epoll.+failed', r'failed to apply'] - ) - conf = { "applications": { "app-" -- cgit