summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2019-04-09 20:59:35 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2019-04-09 20:59:35 +0300
commit29b4e4431fe43f9ac969a1cdb67478da8c5dcc1e (patch)
treef1b8944daa883776d672e3ffb7d37009f0004462
parent549f0873c2beed9517fb4006e1f0a63e0019abb3 (diff)
downloadunit-29b4e4431fe43f9ac969a1cdb67478da8c5dcc1e.tar.gz
unit-29b4e4431fe43f9ac969a1cdb67478da8c5dcc1e.tar.bz2
Tests: speed up tests.
Diffstat (limited to '')
-rw-r--r--test/python/mirror/wsgi.py1
-rw-r--r--test/test_access_log.py15
-rw-r--r--test/test_go_application.py3
-rw-r--r--test/test_java_application.py5
-rw-r--r--test/test_node_application.py3
-rw-r--r--test/test_perl_application.py3
-rw-r--r--test/test_php_application.py3
-rw-r--r--test/test_python_application.py15
-rw-r--r--test/test_ruby_application.py3
-rw-r--r--test/test_settings.py4
-rw-r--r--test/test_tls.py12
11 files changed, 59 insertions, 8 deletions
diff --git a/test/python/mirror/wsgi.py b/test/python/mirror/wsgi.py
index e4df67ec..eb1fb922 100644
--- a/test/python/mirror/wsgi.py
+++ b/test/python/mirror/wsgi.py
@@ -4,7 +4,6 @@ def application(environ, start_response):
body = bytes(environ['wsgi.input'].read(content_length))
start_response('200', [
- ('Content-Type', environ.get('CONTENT_TYPE')),
('Content-Length', str(len(body)))
])
return [body]
diff --git a/test/test_access_log.py b/test/test_access_log.py
index b5bfff7a..ad47c971 100644
--- a/test/test_access_log.py
+++ b/test/test_access_log.py
@@ -19,6 +19,8 @@ class TestAccessLog(TestApplicationPython):
def test_access_log_keepalive(self):
self.load('mirror')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -27,6 +29,7 @@ class TestAccessLog(TestApplicationPython):
},
start=True,
body='01234',
+ read_timeout=1,
)
self.assertIsNotNone(
@@ -174,7 +177,7 @@ Connection: close
def test_access_log_partial(self):
self.load('empty')
- self.http(b"""GE""", raw=True)
+ self.http(b"""GE""", raw=True, no_recv=True)
self.stop()
@@ -185,7 +188,7 @@ Connection: close
def test_access_log_partial_2(self):
self.load('empty')
- self.http(b"""GET /\n""", raw=True)
+ self.http(b"""GET /\n""", raw=True, no_recv=True)
self.stop()
@@ -196,7 +199,7 @@ Connection: close
def test_access_log_partial_3(self):
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()
@@ -207,7 +210,7 @@ Connection: close
def test_access_log_partial_4(self):
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()
@@ -219,7 +222,9 @@ Connection: close
def test_access_log_partial_5(self):
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()
diff --git a/test/test_go_application.py b/test/test_go_application.py
index 0f66a730..373fcdf3 100644
--- a/test/test_go_application.py
+++ b/test/test_go_application.py
@@ -88,6 +88,8 @@ class TestGoApplication(TestApplicationGo):
def test_go_keepalive_body(self):
self.load('mirror')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -96,6 +98,7 @@ class TestGoApplication(TestApplicationGo):
},
start=True,
body='0123456789' * 500,
+ read_timeout=1,
)
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
diff --git a/test/test_java_application.py b/test/test_java_application.py
index 18538f57..7ccaadd5 100644
--- a/test/test_java_application.py
+++ b/test/test_java_application.py
@@ -1031,6 +1031,8 @@ class TestJavaApplication(TestApplicationJava):
def test_java_application_keepalive_body(self):
self.load('mirror')
+ self.assertEqual(self.post()['status'], 200, 'init')
+
(resp, sock) = self.post(
headers={
'Connection': 'keep-alive',
@@ -1039,6 +1041,7 @@ class TestJavaApplication(TestApplicationJava):
},
start=True,
body='0123456789' * 500,
+ read_timeout=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):
self.load('get_header_names')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
self.assertNotIn(
'X-Reply-0',
self.get(headers={}, read_timeout=1)['headers'],
diff --git a/test/test_node_application.py b/test/test_node_application.py
index c55e4fde..901717c0 100644
--- a/test/test_node_application.py
+++ b/test/test_node_application.py
@@ -110,6 +110,8 @@ class TestNodeApplication(TestApplicationNode):
def test_node_keepalive_body(self):
self.load('mirror')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -118,6 +120,7 @@ class TestNodeApplication(TestApplicationNode):
},
start=True,
body='0123456789' * 500,
+ read_timeout=1,
)
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
diff --git a/test/test_perl_application.py b/test/test_perl_application.py
index df037155..d77ac29d 100644
--- a/test/test_perl_application.py
+++ b/test/test_perl_application.py
@@ -196,6 +196,8 @@ class TestPerlApplication(TestApplicationPerl):
def test_perl_keepalive_body(self):
self.load('variables')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -204,6 +206,7 @@ class TestPerlApplication(TestApplicationPerl):
},
start=True,
body='0123456789' * 500,
+ read_timeout=1,
)
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
diff --git a/test/test_php_application.py b/test/test_php_application.py
index 7e75a73d..08c50075 100644
--- a/test/test_php_application.py
+++ b/test/test_php_application.py
@@ -116,6 +116,8 @@ class TestPHPApplication(TestApplicationPHP):
def test_php_application_keepalive_body(self):
self.load('mirror')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -124,6 +126,7 @@ class TestPHPApplication(TestApplicationPHP):
},
start=True,
body='0123456789' * 500,
+ read_timeout=1,
)
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
diff --git a/test/test_python_application.py b/test/test_python_application.py
index d66a6555..6c310ecc 100644
--- a/test/test_python_application.py
+++ b/test/test_python_application.py
@@ -134,6 +134,8 @@ class TestPythonApplication(TestApplicationPython):
def test_python_keepalive_body(self):
self.load('mirror')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -142,6 +144,7 @@ class TestPythonApplication(TestApplicationPython):
},
start=True,
body='0123456789' * 500,
+ read_timeout=1,
)
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
@@ -168,6 +171,8 @@ class TestPythonApplication(TestApplicationPython):
)
self.load('mirror')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
body = '0123456789'
conns = 3
socks = []
@@ -181,6 +186,7 @@ class TestPythonApplication(TestApplicationPython):
},
start=True,
body=body,
+ read_timeout=1,
)
self.assertEqual(resp['body'], body, 'keep-alive open')
@@ -202,6 +208,7 @@ class TestPythonApplication(TestApplicationPython):
start=True,
sock=socks[i],
body=body,
+ read_timeout=1,
)
self.assertEqual(resp['body'], body, 'keep-alive request')
@@ -232,6 +239,8 @@ class TestPythonApplication(TestApplicationPython):
def test_python_keepalive_reconfigure_2(self):
self.load('mirror')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
body = '0123456789'
(resp, sock) = self.post(
@@ -242,12 +251,15 @@ class TestPythonApplication(TestApplicationPython):
},
start=True,
body=body,
+ read_timeout=1,
)
self.assertEqual(resp['body'], body, 'reconfigure 2 keep-alive 1')
self.load('empty')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -275,11 +287,14 @@ class TestPythonApplication(TestApplicationPython):
def test_python_keepalive_reconfigure_3(self):
self.load('empty')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
(resp, sock) = self.http(
b"""GET / HTTP/1.1
""",
start=True,
raw=True,
+ read_timeout=1,
)
self.assertIn(
diff --git a/test/test_ruby_application.py b/test/test_ruby_application.py
index 924fe1ee..f5e24e2e 100644
--- a/test/test_ruby_application.py
+++ b/test/test_ruby_application.py
@@ -321,6 +321,8 @@ class TestRubyApplication(TestApplicationRuby):
def test_ruby_keepalive_body(self):
self.load('mirror')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -329,6 +331,7 @@ class TestRubyApplication(TestApplicationRuby):
},
start=True,
body='0123456789' * 500,
+ read_timeout=1,
)
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
diff --git a/test/test_settings.py b/test/test_settings.py
index 4e604f21..47c891c9 100644
--- a/test/test_settings.py
+++ b/test/test_settings.py
@@ -42,7 +42,6 @@ Connection: close
b"""GET / HTTP/1.1
""",
start=True,
- read_timeout=1,
raw=True,
no_recv=True,
)
@@ -54,7 +53,6 @@ Connection: close
""",
start=True,
sock=sock,
- read_timeout=1,
raw=True,
no_recv=True,
)
@@ -189,6 +187,8 @@ Connection: close
def test_settings_idle_timeout(self):
self.load('empty')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
self.conf({'http': {'idle_timeout': 2}}, 'settings')
(resp, sock) = self.get(
diff --git a/test/test_tls.py b/test/test_tls.py
index dc570c34..573e4ae1 100644
--- a/test/test_tls.py
+++ b/test/test_tls.py
@@ -411,11 +411,14 @@ basicConstraints = critical,CA:TRUE"""
def test_tls_reconfigure(self):
self.load('empty')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
self.certificate()
(resp, sock) = self.get(
headers={'Host': 'localhost', 'Connection': 'keep-alive'},
start=True,
+ read_timeout=1,
)
self.assertEqual(resp['status'], 200, 'initial status')
@@ -432,6 +435,8 @@ basicConstraints = critical,CA:TRUE"""
def test_tls_keepalive(self):
self.load('mirror')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
self.certificate()
self.add_tls(application='mirror')
@@ -444,6 +449,7 @@ basicConstraints = critical,CA:TRUE"""
},
start=True,
body='0123456789',
+ read_timeout=1,
)
self.assertEqual(resp['body'], '0123456789', 'keepalive 1')
@@ -464,6 +470,8 @@ basicConstraints = critical,CA:TRUE"""
def test_tls_keepalive_certificate_remove(self):
self.load('empty')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
self.certificate()
self.add_tls()
@@ -471,6 +479,7 @@ basicConstraints = critical,CA:TRUE"""
(resp, sock) = self.get_ssl(
headers={'Host': 'localhost', 'Connection': 'keep-alive'},
start=True,
+ read_timeout=1,
)
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.load('mirror')
+ self.assertEqual(self.get()['status'], 200, 'init')
+
self.certificate()
self.conf('1', 'applications/mirror/processes')
@@ -515,6 +526,7 @@ basicConstraints = critical,CA:TRUE"""
},
start=True,
body='0123456789',
+ read_timeout=1,
)
app_id = self.findall(r'(\d+)#\d+ "mirror" application started')[0]