summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_asgi_application.py50
-rw-r--r--test/test_python_application.py54
-rw-r--r--test/unit/applications/lang/python.py22
3 files changed, 37 insertions, 89 deletions
diff --git a/test/test_asgi_application.py b/test/test_asgi_application.py
index b382e2f2..2e73e529 100644
--- a/test/test_asgi_application.py
+++ b/test/test_asgi_application.py
@@ -137,23 +137,17 @@ custom-header: BLAH
), '204 header transfer encoding'
def test_asgi_application_shm_ack_handle(self):
- self.load('mirror')
-
# Minimum possible limit
shm_limit = 10 * 1024 * 1024
- assert (
- 'success' in self.conf('{"shm": ' + str(shm_limit) + '}',
- 'applications/mirror/limits')
- )
+ self.load('mirror', limits={"shm": shm_limit})
# Should exceed shm_limit
max_body_size = 12 * 1024 * 1024
- assert (
- 'success' in self.conf('{"http":{"max_body_size": '
- + str(max_body_size) + ' }}',
- 'settings')
+ assert 'success' in self.conf(
+ '{"http":{"max_body_size": ' + str(max_body_size) + ' }}',
+ 'settings'
)
assert self.get()['status'] == 200, 'init'
@@ -204,11 +198,6 @@ custom-header: BLAH
assert resp['body'] == body, 'keep-alive 2'
def test_asgi_keepalive_reconfigure(self):
- skip_alert(
- r'pthread_mutex.+failed',
- r'failed to apply',
- r'process \d+ exited on signal',
- )
self.load('mirror')
assert self.get()['status'] == 200, 'init'
@@ -230,9 +219,8 @@ custom-header: BLAH
)
assert resp['body'] == body, 'keep-alive open'
- assert 'success' in self.conf(
- str(i + 1), 'applications/mirror/processes'
- ), 'reconfigure'
+
+ self.load('mirror', processes=i + 1)
socks.append(sock)
@@ -250,9 +238,8 @@ custom-header: BLAH
)
assert resp['body'] == body, 'keep-alive request'
- assert 'success' in self.conf(
- str(i + 1), 'applications/mirror/processes'
- ), 'reconfigure 2'
+
+ self.load('mirror', processes=i + 1)
for i in range(conns):
resp = self.post(
@@ -266,9 +253,8 @@ custom-header: BLAH
)
assert resp['body'] == body, 'keep-alive close'
- assert 'success' in self.conf(
- str(i + 1), 'applications/mirror/processes'
- ), 'reconfigure 3'
+
+ self.load('mirror', processes=i + 1)
def test_asgi_keepalive_reconfigure_2(self):
self.load('mirror')
@@ -347,11 +333,7 @@ Connection: close
assert resp['status'] == 200, 'reconfigure 3'
def test_asgi_process_switch(self):
- self.load('delayed')
-
- assert 'success' in self.conf(
- '2', 'applications/delayed/processes'
- ), 'configure 2 processes'
+ self.load('delayed', processes=2)
self.get(
headers={
@@ -382,9 +364,7 @@ Connection: close
def test_asgi_application_loading_error(self):
skip_alert(r'Python failed to import module "blah"')
- self.load('empty')
-
- assert 'success' in self.conf('"blah"', 'applications/empty/module')
+ self.load('empty', module="blah")
assert self.get()['status'] == 503, 'loading error'
@@ -403,11 +383,7 @@ Connection: close
), 'last thread finished'
def test_asgi_application_threads(self):
- self.load('threads')
-
- assert 'success' in self.conf(
- '2', 'applications/threads/threads'
- ), 'configure 2 threads'
+ self.load('threads', threads=2)
socks = []
diff --git a/test/test_python_application.py b/test/test_python_application.py
index 780b836a..871d8bc0 100644
--- a/test/test_python_application.py
+++ b/test/test_python_application.py
@@ -197,11 +197,6 @@ custom-header: BLAH
assert resp['body'] == body, 'keep-alive 2'
def test_python_keepalive_reconfigure(self):
- skip_alert(
- r'pthread_mutex.+failed',
- r'failed to apply',
- r'process \d+ exited on signal',
- )
self.load('mirror')
assert self.get()['status'] == 200, 'init'
@@ -223,9 +218,8 @@ custom-header: BLAH
)
assert resp['body'] == body, 'keep-alive open'
- assert 'success' in self.conf(
- str(i + 1), 'applications/mirror/processes'
- ), 'reconfigure'
+
+ self.load('mirror', processes=i + 1)
socks.append(sock)
@@ -243,9 +237,8 @@ custom-header: BLAH
)
assert resp['body'] == body, 'keep-alive request'
- assert 'success' in self.conf(
- str(i + 1), 'applications/mirror/processes'
- ), 'reconfigure 2'
+
+ self.load('mirror', processes=i + 1)
for i in range(conns):
resp = self.post(
@@ -259,9 +252,8 @@ custom-header: BLAH
)
assert resp['body'] == body, 'keep-alive close'
- assert 'success' in self.conf(
- str(i + 1), 'applications/mirror/processes'
- ), 'reconfigure 3'
+
+ self.load('mirror', processes=i + 1)
def test_python_keepalive_reconfigure_2(self):
self.load('mirror')
@@ -351,11 +343,7 @@ Connection: close
assert self.wait_for_record(r'At exit called\.') is not None, 'atexit'
def test_python_process_switch(self):
- self.load('delayed')
-
- assert 'success' in self.conf(
- '2', 'applications/delayed/processes'
- ), 'configure 2 processes'
+ self.load('delayed', processes=2)
self.get(
headers={
@@ -541,9 +529,7 @@ last line: 987654321
def test_python_application_loading_error(self):
skip_alert(r'Python failed to import module "blah"')
- self.load('empty')
-
- assert 'success' in self.conf('"blah"', 'applications/empty/module')
+ self.load('empty', module="blah")
assert self.get()['status'] == 503, 'loading error'
@@ -811,34 +797,16 @@ last line: 987654321
assert self.get()['status'] == 204, 'default application response'
- assert 'success' in self.conf(
- '"app"', 'applications/callable/callable'
- )
+ self.load('callable', callable="app")
assert self.get()['status'] == 200, 'callable response'
- assert 'success' in self.conf(
- '"blah"', 'applications/callable/callable'
- )
+ self.load('callable', callable="blah")
assert self.get()['status'] not in [200, 204], 'callable response inv'
- assert 'success' in self.conf(
- '"app"', 'applications/callable/callable'
- )
-
- assert self.get()['status'] == 200, 'callable response 2'
-
- assert 'success' in self.conf_delete('applications/callable/callable')
-
- assert self.get()['status'] == 204, 'default response 2'
-
def test_python_application_threads(self):
- self.load('threads')
-
- assert 'success' in self.conf(
- '4', 'applications/threads/threads'
- ), 'configure 4 threads'
+ self.load('threads', threads=4)
socks = []
diff --git a/test/unit/applications/lang/python.py b/test/unit/applications/lang/python.py
index 374b0f9c..20d4f257 100644
--- a/test/unit/applications/lang/python.py
+++ b/test/unit/applications/lang/python.py
@@ -34,20 +34,24 @@ class TestApplicationPython(TestApplicationProto):
script_path = '/app/python/' + name
+ app = {
+ "type": self.get_application_type(),
+ "processes": kwargs.pop('processes', {"spare": 0}),
+ "path": script_path,
+ "working_directory": script_path,
+ "module": module,
+ }
+
+ for attr in ('callable', 'home', 'limits', 'path', 'threads'):
+ if attr in kwargs:
+ app[attr] = kwargs.pop(attr)
+
self._load_conf(
{
"listeners": {
"*:7080": {"pass": "applications/" + quote(name, '')}
},
- "applications": {
- name: {
- "type": self.get_application_type(),
- "processes": {"spare": 0},
- "path": script_path,
- "working_directory": script_path,
- "module": module,
- }
- },
+ "applications": {name: app},
},
**kwargs
)