Tests: speed up tests.
This commit is contained in:
@@ -4,7 +4,6 @@ def application(environ, start_response):
|
|||||||
body = bytes(environ['wsgi.input'].read(content_length))
|
body = bytes(environ['wsgi.input'].read(content_length))
|
||||||
|
|
||||||
start_response('200', [
|
start_response('200', [
|
||||||
('Content-Type', environ.get('CONTENT_TYPE')),
|
|
||||||
('Content-Length', str(len(body)))
|
('Content-Length', str(len(body)))
|
||||||
])
|
])
|
||||||
return [body]
|
return [body]
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ class TestAccessLog(TestApplicationPython):
|
|||||||
def test_access_log_keepalive(self):
|
def test_access_log_keepalive(self):
|
||||||
self.load('mirror')
|
self.load('mirror')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
(resp, sock) = self.post(
|
(resp, sock) = self.post(
|
||||||
headers={
|
headers={
|
||||||
'Host': 'localhost',
|
'Host': 'localhost',
|
||||||
@@ -27,6 +29,7 @@ class TestAccessLog(TestApplicationPython):
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body='01234',
|
body='01234',
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertIsNotNone(
|
self.assertIsNotNone(
|
||||||
@@ -174,7 +177,7 @@ Connection: close
|
|||||||
def test_access_log_partial(self):
|
def test_access_log_partial(self):
|
||||||
self.load('empty')
|
self.load('empty')
|
||||||
|
|
||||||
self.http(b"""GE""", raw=True)
|
self.http(b"""GE""", raw=True, no_recv=True)
|
||||||
|
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
@@ -185,7 +188,7 @@ Connection: close
|
|||||||
def test_access_log_partial_2(self):
|
def test_access_log_partial_2(self):
|
||||||
self.load('empty')
|
self.load('empty')
|
||||||
|
|
||||||
self.http(b"""GET /\n""", raw=True)
|
self.http(b"""GET /\n""", raw=True, no_recv=True)
|
||||||
|
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
@@ -196,7 +199,7 @@ Connection: close
|
|||||||
def test_access_log_partial_3(self):
|
def test_access_log_partial_3(self):
|
||||||
self.load('empty')
|
self.load('empty')
|
||||||
|
|
||||||
self.http(b"""GET / HTTP/1.1""", raw=True)
|
self.http(b"""GET / HTTP/1.1""", raw=True, no_recv=True)
|
||||||
|
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
@@ -207,7 +210,7 @@ Connection: close
|
|||||||
def test_access_log_partial_4(self):
|
def test_access_log_partial_4(self):
|
||||||
self.load('empty')
|
self.load('empty')
|
||||||
|
|
||||||
resp = self.http(b"""GET / HTTP/1.1\n""", raw=True)
|
resp = self.http(b"""GET / HTTP/1.1\n""", raw=True, no_recv=True)
|
||||||
|
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
@@ -219,7 +222,9 @@ Connection: close
|
|||||||
def test_access_log_partial_5(self):
|
def test_access_log_partial_5(self):
|
||||||
self.load('empty')
|
self.load('empty')
|
||||||
|
|
||||||
self.http(b"""GET / HTTP/1.1\n\n""", raw=True)
|
self.assertEqual(self.post()['status'], 200, 'init')
|
||||||
|
|
||||||
|
self.http(b"""GET / HTTP/1.1\n\n""", raw=True, read_timeout=1)
|
||||||
|
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ class TestGoApplication(TestApplicationGo):
|
|||||||
def test_go_keepalive_body(self):
|
def test_go_keepalive_body(self):
|
||||||
self.load('mirror')
|
self.load('mirror')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
(resp, sock) = self.post(
|
(resp, sock) = self.post(
|
||||||
headers={
|
headers={
|
||||||
'Host': 'localhost',
|
'Host': 'localhost',
|
||||||
@@ -96,6 +98,7 @@ class TestGoApplication(TestApplicationGo):
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body='0123456789' * 500,
|
body='0123456789' * 500,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||||
|
|||||||
@@ -1031,6 +1031,8 @@ class TestJavaApplication(TestApplicationJava):
|
|||||||
def test_java_application_keepalive_body(self):
|
def test_java_application_keepalive_body(self):
|
||||||
self.load('mirror')
|
self.load('mirror')
|
||||||
|
|
||||||
|
self.assertEqual(self.post()['status'], 200, 'init')
|
||||||
|
|
||||||
(resp, sock) = self.post(
|
(resp, sock) = self.post(
|
||||||
headers={
|
headers={
|
||||||
'Connection': 'keep-alive',
|
'Connection': 'keep-alive',
|
||||||
@@ -1039,6 +1041,7 @@ class TestJavaApplication(TestApplicationJava):
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body='0123456789' * 500,
|
body='0123456789' * 500,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||||
@@ -1128,6 +1131,8 @@ class TestJavaApplication(TestApplicationJava):
|
|||||||
def test_java_application_get_header_names_empty(self):
|
def test_java_application_get_header_names_empty(self):
|
||||||
self.load('get_header_names')
|
self.load('get_header_names')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
self.assertNotIn(
|
self.assertNotIn(
|
||||||
'X-Reply-0',
|
'X-Reply-0',
|
||||||
self.get(headers={}, read_timeout=1)['headers'],
|
self.get(headers={}, read_timeout=1)['headers'],
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ class TestNodeApplication(TestApplicationNode):
|
|||||||
def test_node_keepalive_body(self):
|
def test_node_keepalive_body(self):
|
||||||
self.load('mirror')
|
self.load('mirror')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
(resp, sock) = self.post(
|
(resp, sock) = self.post(
|
||||||
headers={
|
headers={
|
||||||
'Host': 'localhost',
|
'Host': 'localhost',
|
||||||
@@ -118,6 +120,7 @@ class TestNodeApplication(TestApplicationNode):
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body='0123456789' * 500,
|
body='0123456789' * 500,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||||
|
|||||||
@@ -196,6 +196,8 @@ class TestPerlApplication(TestApplicationPerl):
|
|||||||
def test_perl_keepalive_body(self):
|
def test_perl_keepalive_body(self):
|
||||||
self.load('variables')
|
self.load('variables')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
(resp, sock) = self.post(
|
(resp, sock) = self.post(
|
||||||
headers={
|
headers={
|
||||||
'Host': 'localhost',
|
'Host': 'localhost',
|
||||||
@@ -204,6 +206,7 @@ class TestPerlApplication(TestApplicationPerl):
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body='0123456789' * 500,
|
body='0123456789' * 500,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ class TestPHPApplication(TestApplicationPHP):
|
|||||||
def test_php_application_keepalive_body(self):
|
def test_php_application_keepalive_body(self):
|
||||||
self.load('mirror')
|
self.load('mirror')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
(resp, sock) = self.post(
|
(resp, sock) = self.post(
|
||||||
headers={
|
headers={
|
||||||
'Host': 'localhost',
|
'Host': 'localhost',
|
||||||
@@ -124,6 +126,7 @@ class TestPHPApplication(TestApplicationPHP):
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body='0123456789' * 500,
|
body='0123456789' * 500,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ class TestPythonApplication(TestApplicationPython):
|
|||||||
def test_python_keepalive_body(self):
|
def test_python_keepalive_body(self):
|
||||||
self.load('mirror')
|
self.load('mirror')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
(resp, sock) = self.post(
|
(resp, sock) = self.post(
|
||||||
headers={
|
headers={
|
||||||
'Host': 'localhost',
|
'Host': 'localhost',
|
||||||
@@ -142,6 +144,7 @@ class TestPythonApplication(TestApplicationPython):
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body='0123456789' * 500,
|
body='0123456789' * 500,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||||
@@ -168,6 +171,8 @@ class TestPythonApplication(TestApplicationPython):
|
|||||||
)
|
)
|
||||||
self.load('mirror')
|
self.load('mirror')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
body = '0123456789'
|
body = '0123456789'
|
||||||
conns = 3
|
conns = 3
|
||||||
socks = []
|
socks = []
|
||||||
@@ -181,6 +186,7 @@ class TestPythonApplication(TestApplicationPython):
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body=body,
|
body=body,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['body'], body, 'keep-alive open')
|
self.assertEqual(resp['body'], body, 'keep-alive open')
|
||||||
@@ -202,6 +208,7 @@ class TestPythonApplication(TestApplicationPython):
|
|||||||
start=True,
|
start=True,
|
||||||
sock=socks[i],
|
sock=socks[i],
|
||||||
body=body,
|
body=body,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['body'], body, 'keep-alive request')
|
self.assertEqual(resp['body'], body, 'keep-alive request')
|
||||||
@@ -232,6 +239,8 @@ class TestPythonApplication(TestApplicationPython):
|
|||||||
def test_python_keepalive_reconfigure_2(self):
|
def test_python_keepalive_reconfigure_2(self):
|
||||||
self.load('mirror')
|
self.load('mirror')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
body = '0123456789'
|
body = '0123456789'
|
||||||
|
|
||||||
(resp, sock) = self.post(
|
(resp, sock) = self.post(
|
||||||
@@ -242,12 +251,15 @@ class TestPythonApplication(TestApplicationPython):
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body=body,
|
body=body,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['body'], body, 'reconfigure 2 keep-alive 1')
|
self.assertEqual(resp['body'], body, 'reconfigure 2 keep-alive 1')
|
||||||
|
|
||||||
self.load('empty')
|
self.load('empty')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
(resp, sock) = self.post(
|
(resp, sock) = self.post(
|
||||||
headers={
|
headers={
|
||||||
'Host': 'localhost',
|
'Host': 'localhost',
|
||||||
@@ -275,11 +287,14 @@ class TestPythonApplication(TestApplicationPython):
|
|||||||
def test_python_keepalive_reconfigure_3(self):
|
def test_python_keepalive_reconfigure_3(self):
|
||||||
self.load('empty')
|
self.load('empty')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
(resp, sock) = self.http(
|
(resp, sock) = self.http(
|
||||||
b"""GET / HTTP/1.1
|
b"""GET / HTTP/1.1
|
||||||
""",
|
""",
|
||||||
start=True,
|
start=True,
|
||||||
raw=True,
|
raw=True,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
|
|||||||
@@ -321,6 +321,8 @@ class TestRubyApplication(TestApplicationRuby):
|
|||||||
def test_ruby_keepalive_body(self):
|
def test_ruby_keepalive_body(self):
|
||||||
self.load('mirror')
|
self.load('mirror')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
(resp, sock) = self.post(
|
(resp, sock) = self.post(
|
||||||
headers={
|
headers={
|
||||||
'Host': 'localhost',
|
'Host': 'localhost',
|
||||||
@@ -329,6 +331,7 @@ class TestRubyApplication(TestApplicationRuby):
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body='0123456789' * 500,
|
body='0123456789' * 500,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ Connection: close
|
|||||||
b"""GET / HTTP/1.1
|
b"""GET / HTTP/1.1
|
||||||
""",
|
""",
|
||||||
start=True,
|
start=True,
|
||||||
read_timeout=1,
|
|
||||||
raw=True,
|
raw=True,
|
||||||
no_recv=True,
|
no_recv=True,
|
||||||
)
|
)
|
||||||
@@ -54,7 +53,6 @@ Connection: close
|
|||||||
""",
|
""",
|
||||||
start=True,
|
start=True,
|
||||||
sock=sock,
|
sock=sock,
|
||||||
read_timeout=1,
|
|
||||||
raw=True,
|
raw=True,
|
||||||
no_recv=True,
|
no_recv=True,
|
||||||
)
|
)
|
||||||
@@ -189,6 +187,8 @@ Connection: close
|
|||||||
def test_settings_idle_timeout(self):
|
def test_settings_idle_timeout(self):
|
||||||
self.load('empty')
|
self.load('empty')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
self.conf({'http': {'idle_timeout': 2}}, 'settings')
|
self.conf({'http': {'idle_timeout': 2}}, 'settings')
|
||||||
|
|
||||||
(resp, sock) = self.get(
|
(resp, sock) = self.get(
|
||||||
|
|||||||
@@ -411,11 +411,14 @@ basicConstraints = critical,CA:TRUE"""
|
|||||||
def test_tls_reconfigure(self):
|
def test_tls_reconfigure(self):
|
||||||
self.load('empty')
|
self.load('empty')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
self.certificate()
|
self.certificate()
|
||||||
|
|
||||||
(resp, sock) = self.get(
|
(resp, sock) = self.get(
|
||||||
headers={'Host': 'localhost', 'Connection': 'keep-alive'},
|
headers={'Host': 'localhost', 'Connection': 'keep-alive'},
|
||||||
start=True,
|
start=True,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['status'], 200, 'initial status')
|
self.assertEqual(resp['status'], 200, 'initial status')
|
||||||
@@ -432,6 +435,8 @@ basicConstraints = critical,CA:TRUE"""
|
|||||||
def test_tls_keepalive(self):
|
def test_tls_keepalive(self):
|
||||||
self.load('mirror')
|
self.load('mirror')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
self.certificate()
|
self.certificate()
|
||||||
|
|
||||||
self.add_tls(application='mirror')
|
self.add_tls(application='mirror')
|
||||||
@@ -444,6 +449,7 @@ basicConstraints = critical,CA:TRUE"""
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body='0123456789',
|
body='0123456789',
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(resp['body'], '0123456789', 'keepalive 1')
|
self.assertEqual(resp['body'], '0123456789', 'keepalive 1')
|
||||||
@@ -464,6 +470,8 @@ basicConstraints = critical,CA:TRUE"""
|
|||||||
def test_tls_keepalive_certificate_remove(self):
|
def test_tls_keepalive_certificate_remove(self):
|
||||||
self.load('empty')
|
self.load('empty')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
self.certificate()
|
self.certificate()
|
||||||
|
|
||||||
self.add_tls()
|
self.add_tls()
|
||||||
@@ -471,6 +479,7 @@ basicConstraints = critical,CA:TRUE"""
|
|||||||
(resp, sock) = self.get_ssl(
|
(resp, sock) = self.get_ssl(
|
||||||
headers={'Host': 'localhost', 'Connection': 'keep-alive'},
|
headers={'Host': 'localhost', 'Connection': 'keep-alive'},
|
||||||
start=True,
|
start=True,
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.conf({"application": "empty"}, 'listeners/*:7080')
|
self.conf({"application": "empty"}, 'listeners/*:7080')
|
||||||
@@ -501,6 +510,8 @@ basicConstraints = critical,CA:TRUE"""
|
|||||||
self.skip_alerts.append(r'process \d+ exited on signal 9')
|
self.skip_alerts.append(r'process \d+ exited on signal 9')
|
||||||
self.load('mirror')
|
self.load('mirror')
|
||||||
|
|
||||||
|
self.assertEqual(self.get()['status'], 200, 'init')
|
||||||
|
|
||||||
self.certificate()
|
self.certificate()
|
||||||
|
|
||||||
self.conf('1', 'applications/mirror/processes')
|
self.conf('1', 'applications/mirror/processes')
|
||||||
@@ -515,6 +526,7 @@ basicConstraints = critical,CA:TRUE"""
|
|||||||
},
|
},
|
||||||
start=True,
|
start=True,
|
||||||
body='0123456789',
|
body='0123456789',
|
||||||
|
read_timeout=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
app_id = self.findall(r'(\d+)#\d+ "mirror" application started')[0]
|
app_id = self.findall(r'(\d+)#\d+ "mirror" application started')[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user