Tests: minor fixes and style.
This commit is contained in:
@@ -89,6 +89,7 @@ class TestGoApplication(TestApplicationGo):
|
||||
|
||||
self.assertEqual(self.get()['status'], 200, 'init')
|
||||
|
||||
body = '0123456789' * 500
|
||||
(resp, sock) = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -96,12 +97,13 @@ class TestGoApplication(TestApplicationGo):
|
||||
'Content-Type': 'text/html',
|
||||
},
|
||||
start=True,
|
||||
body='0123456789' * 500,
|
||||
body=body,
|
||||
read_timeout=1,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 1')
|
||||
|
||||
body = '0123456789'
|
||||
resp = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -109,10 +111,10 @@ class TestGoApplication(TestApplicationGo):
|
||||
'Connection': 'close',
|
||||
},
|
||||
sock=sock,
|
||||
body='0123456789',
|
||||
body=body,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 2')
|
||||
|
||||
def test_go_application_cookies(self):
|
||||
self.load('cookies')
|
||||
|
||||
@@ -1085,6 +1085,7 @@ class TestJavaApplication(TestApplicationJava):
|
||||
|
||||
self.assertEqual(self.post()['status'], 200, 'init')
|
||||
|
||||
body = '0123456789' * 500
|
||||
(resp, sock) = self.post(
|
||||
headers={
|
||||
'Connection': 'keep-alive',
|
||||
@@ -1092,12 +1093,13 @@ class TestJavaApplication(TestApplicationJava):
|
||||
'Host': 'localhost',
|
||||
},
|
||||
start=True,
|
||||
body='0123456789' * 500,
|
||||
body=body,
|
||||
read_timeout=1,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 1')
|
||||
|
||||
body = '0123456789'
|
||||
resp = self.post(
|
||||
headers={
|
||||
'Connection': 'close',
|
||||
@@ -1105,10 +1107,10 @@ class TestJavaApplication(TestApplicationJava):
|
||||
'Host': 'localhost',
|
||||
},
|
||||
sock=sock,
|
||||
body='0123456789',
|
||||
body=body,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 2')
|
||||
|
||||
def test_java_application_http_10(self):
|
||||
self.load('empty')
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
)
|
||||
|
||||
def close_connection(self, sock):
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_CLOSE, self.ws.serialize_close())
|
||||
|
||||
@@ -441,12 +441,12 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
_, sock, _ = self.ws.upgrade()
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_PONG, '')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', '2_7')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '2_7')
|
||||
|
||||
# 2_8
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_PONG, 'unsolicited pong payload')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', '2_8')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '2_8')
|
||||
|
||||
# 2_9
|
||||
|
||||
@@ -512,7 +512,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
|
||||
self.check_close(sock, 1002, no_close=True)
|
||||
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_2')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_2')
|
||||
sock.close()
|
||||
|
||||
# 3_3
|
||||
@@ -530,7 +530,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
|
||||
self.check_close(sock, 1002, no_close=True)
|
||||
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_3')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_3')
|
||||
sock.close()
|
||||
|
||||
# 3_4
|
||||
@@ -548,7 +548,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
|
||||
self.check_close(sock, 1002, no_close=True)
|
||||
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_4')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_4')
|
||||
sock.close()
|
||||
|
||||
# 3_5
|
||||
@@ -734,7 +734,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
# 5_4
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_TEXT, 'fragment1', fin=False)
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_4')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_4')
|
||||
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment2', fin=True)
|
||||
|
||||
frame = self.ws.frame_read(sock)
|
||||
@@ -771,7 +771,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
ping_payload = 'ping payload'
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_TEXT, 'fragment1', fin=False)
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_7')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_7')
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_PING, ping_payload)
|
||||
|
||||
@@ -955,7 +955,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
frame = self.ws.frame_read(sock)
|
||||
self.check_frame(frame, True, self.ws.OP_PONG, 'pongme 2!')
|
||||
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_20')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_20')
|
||||
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment5')
|
||||
|
||||
self.check_frame(
|
||||
@@ -1088,7 +1088,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
self.check_close(sock, no_close=True)
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_PING, '')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
|
||||
|
||||
sock.close()
|
||||
|
||||
@@ -1100,7 +1100,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
self.check_close(sock, no_close=True)
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_TEXT, payload)
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
|
||||
|
||||
sock.close()
|
||||
|
||||
@@ -1113,7 +1113,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
self.check_close(sock, no_close=True)
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment2')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
|
||||
|
||||
sock.close()
|
||||
|
||||
@@ -1128,7 +1128,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
||||
self.recvall(sock, read_timeout=1)
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_PING, '')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
|
||||
|
||||
sock.close()
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@ class TestNodeApplication(TestApplicationNode):
|
||||
|
||||
self.assertEqual(self.get()['status'], 200, 'init')
|
||||
|
||||
body = '0123456789' * 500
|
||||
(resp, sock) = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -119,12 +120,13 @@ class TestNodeApplication(TestApplicationNode):
|
||||
'Content-Type': 'text/html',
|
||||
},
|
||||
start=True,
|
||||
body='0123456789' * 500,
|
||||
body=body,
|
||||
read_timeout=1,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||
|
||||
body = '0123456789'
|
||||
resp = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -132,10 +134,10 @@ class TestNodeApplication(TestApplicationNode):
|
||||
'Content-Type': 'text/html',
|
||||
},
|
||||
sock=sock,
|
||||
body='0123456789',
|
||||
body=body,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 2')
|
||||
|
||||
def test_node_application_write_buffer(self):
|
||||
self.load('write_buffer')
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
)
|
||||
|
||||
def close_connection(self, sock):
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_CLOSE, self.ws.serialize_close())
|
||||
|
||||
@@ -460,12 +460,12 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
_, sock, _ = self.ws.upgrade()
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_PONG, '')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', '2_7')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '2_7')
|
||||
|
||||
# 2_8
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_PONG, 'unsolicited pong payload')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', '2_8')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '2_8')
|
||||
|
||||
# 2_9
|
||||
|
||||
@@ -531,7 +531,7 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
|
||||
self.check_close(sock, 1002, no_close=True)
|
||||
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_2')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_2')
|
||||
sock.close()
|
||||
|
||||
# 3_3
|
||||
@@ -549,7 +549,7 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
|
||||
self.check_close(sock, 1002, no_close=True)
|
||||
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_3')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_3')
|
||||
sock.close()
|
||||
|
||||
# 3_4
|
||||
@@ -567,7 +567,7 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
|
||||
self.check_close(sock, 1002, no_close=True)
|
||||
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_4')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_4')
|
||||
sock.close()
|
||||
|
||||
# 3_5
|
||||
@@ -753,7 +753,7 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
# 5_4
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_TEXT, 'fragment1', fin=False)
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_4')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_4')
|
||||
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment2', fin=True)
|
||||
|
||||
frame = self.ws.frame_read(sock)
|
||||
@@ -790,7 +790,7 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
ping_payload = 'ping payload'
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_TEXT, 'fragment1', fin=False)
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_7')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_7')
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_PING, ping_payload)
|
||||
|
||||
@@ -974,7 +974,7 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
frame = self.ws.frame_read(sock)
|
||||
self.check_frame(frame, True, self.ws.OP_PONG, 'pongme 2!')
|
||||
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_20')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_20')
|
||||
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment5')
|
||||
|
||||
self.check_frame(
|
||||
@@ -1107,7 +1107,7 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
self.check_close(sock, no_close=True)
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_PING, '')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
|
||||
|
||||
sock.close()
|
||||
|
||||
@@ -1119,7 +1119,7 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
self.check_close(sock, no_close=True)
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_TEXT, payload)
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
|
||||
|
||||
sock.close()
|
||||
|
||||
@@ -1132,7 +1132,7 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
self.check_close(sock, no_close=True)
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment2')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
|
||||
|
||||
sock.close()
|
||||
|
||||
@@ -1147,7 +1147,7 @@ class TestNodeWebsockets(TestApplicationNode):
|
||||
self.recvall(sock, read_timeout=1)
|
||||
|
||||
self.ws.frame_write(sock, self.ws.OP_PING, '')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
|
||||
self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
|
||||
|
||||
sock.close()
|
||||
|
||||
|
||||
@@ -197,6 +197,7 @@ class TestPerlApplication(TestApplicationPerl):
|
||||
|
||||
self.assertEqual(self.get()['status'], 200, 'init')
|
||||
|
||||
body = '0123456789' * 500
|
||||
(resp, sock) = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -204,12 +205,13 @@ class TestPerlApplication(TestApplicationPerl):
|
||||
'Content-Type': 'text/html',
|
||||
},
|
||||
start=True,
|
||||
body='0123456789' * 500,
|
||||
body=body,
|
||||
read_timeout=1,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 1')
|
||||
|
||||
body = '0123456789'
|
||||
resp = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -217,10 +219,10 @@ class TestPerlApplication(TestApplicationPerl):
|
||||
'Content-Type': 'text/html',
|
||||
},
|
||||
sock=sock,
|
||||
body='0123456789',
|
||||
body=body,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 2')
|
||||
|
||||
def test_perl_body_io_fake(self):
|
||||
self.load('body_io_fake')
|
||||
|
||||
@@ -183,6 +183,7 @@ class TestPHPApplication(TestApplicationPHP):
|
||||
|
||||
self.assertEqual(self.get()['status'], 200, 'init')
|
||||
|
||||
body = '0123456789' * 500
|
||||
(resp, sock) = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -190,12 +191,13 @@ class TestPHPApplication(TestApplicationPHP):
|
||||
'Content-Type': 'text/html',
|
||||
},
|
||||
start=True,
|
||||
body='0123456789' * 500,
|
||||
body=body,
|
||||
read_timeout=1,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 1')
|
||||
|
||||
body = '0123456789'
|
||||
resp = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -203,10 +205,10 @@ class TestPHPApplication(TestApplicationPHP):
|
||||
'Content-Type': 'text/html',
|
||||
},
|
||||
sock=sock,
|
||||
body='0123456789',
|
||||
body=body,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 2')
|
||||
|
||||
def test_php_application_conditional(self):
|
||||
self.load('conditional')
|
||||
|
||||
@@ -37,9 +37,6 @@ class TestPHPBasic(TestControl):
|
||||
'applications',
|
||||
)
|
||||
|
||||
def test_php_get_applications_prefix(self):
|
||||
self.conf(self.conf_app, 'applications')
|
||||
|
||||
self.assertEqual(
|
||||
self.conf_get('applications'),
|
||||
{
|
||||
@@ -53,9 +50,6 @@ class TestPHPBasic(TestControl):
|
||||
'applications prefix',
|
||||
)
|
||||
|
||||
def test_php_get_applications_prefix_2(self):
|
||||
self.conf(self.conf_app, 'applications')
|
||||
|
||||
self.assertEqual(
|
||||
self.conf_get('applications/app'),
|
||||
{
|
||||
@@ -67,9 +61,6 @@ class TestPHPBasic(TestControl):
|
||||
'applications prefix 2',
|
||||
)
|
||||
|
||||
def test_php_get_applications_prefix_3(self):
|
||||
self.conf(self.conf_app, 'applications')
|
||||
|
||||
self.assertEqual(self.conf_get('applications/app/type'), 'php', 'type')
|
||||
self.assertEqual(
|
||||
self.conf_get('applications/app/processes/spare'),
|
||||
@@ -86,18 +77,12 @@ class TestPHPBasic(TestControl):
|
||||
'listeners',
|
||||
)
|
||||
|
||||
def test_php_get_listeners_prefix(self):
|
||||
self.conf(self.conf_basic)
|
||||
|
||||
self.assertEqual(
|
||||
self.conf_get('listeners'),
|
||||
{"*:7080": {"pass": "applications/app"}},
|
||||
'listeners prefix',
|
||||
)
|
||||
|
||||
def test_php_get_listeners_prefix_2(self):
|
||||
self.conf(self.conf_basic)
|
||||
|
||||
self.assertEqual(
|
||||
self.conf_get('listeners/*:7080'),
|
||||
{"pass": "applications/app"},
|
||||
@@ -147,49 +132,24 @@ class TestPHPBasic(TestControl):
|
||||
def test_php_delete(self):
|
||||
self.conf(self.conf_basic)
|
||||
|
||||
self.assertIn(
|
||||
'error',
|
||||
self.conf_delete('applications/app'),
|
||||
'delete app before listener',
|
||||
)
|
||||
self.assertIn(
|
||||
'success', self.conf_delete('listeners/*:7080'), 'delete listener'
|
||||
)
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf_delete('applications/app'),
|
||||
'delete app after listener',
|
||||
)
|
||||
self.assertIn(
|
||||
'error', self.conf_delete('applications/app'), 'delete app again'
|
||||
)
|
||||
self.assertIn('error', self.conf_delete('applications/app'))
|
||||
self.assertIn('success', self.conf_delete('listeners/*:7080'))
|
||||
self.assertIn('success', self.conf_delete('applications/app'))
|
||||
self.assertIn('error', self.conf_delete('applications/app'))
|
||||
|
||||
def test_php_delete_blocks(self):
|
||||
self.conf(self.conf_basic)
|
||||
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf_delete('listeners'),
|
||||
'listeners delete',
|
||||
)
|
||||
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf_delete('applications'),
|
||||
'applications delete',
|
||||
)
|
||||
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf(self.conf_app, 'applications'),
|
||||
'listeners restore',
|
||||
)
|
||||
self.assertIn('success', self.conf_delete('listeners'))
|
||||
self.assertIn('success', self.conf_delete('applications'))
|
||||
|
||||
self.assertIn('success', self.conf(self.conf_app, 'applications'))
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners'),
|
||||
'applications restore',
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
TestPHPBasic.main()
|
||||
|
||||
@@ -187,6 +187,7 @@ class TestPythonApplication(TestApplicationPython):
|
||||
|
||||
self.assertEqual(self.get()['status'], 200, 'init')
|
||||
|
||||
body = '0123456789' * 500
|
||||
(resp, sock) = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -194,12 +195,13 @@ class TestPythonApplication(TestApplicationPython):
|
||||
'Content-Type': 'text/html',
|
||||
},
|
||||
start=True,
|
||||
body='0123456789' * 500,
|
||||
body=body,
|
||||
read_timeout=1,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 1')
|
||||
|
||||
body = '0123456789'
|
||||
resp = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -207,10 +209,10 @@ class TestPythonApplication(TestApplicationPython):
|
||||
'Content-Type': 'text/html',
|
||||
},
|
||||
sock=sock,
|
||||
body='0123456789',
|
||||
body=body,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 2')
|
||||
|
||||
def test_python_keepalive_reconfigure(self):
|
||||
self.skip_alerts.extend(
|
||||
@@ -340,14 +342,16 @@ class TestPythonApplication(TestApplicationPython):
|
||||
|
||||
self.assertEqual(self.get()['status'], 200, 'init')
|
||||
|
||||
(resp, sock) = self.http(
|
||||
(_, sock) = self.http(
|
||||
b"""GET / HTTP/1.1
|
||||
""",
|
||||
start=True,
|
||||
raw=True,
|
||||
read_timeout=5,
|
||||
no_recv=True,
|
||||
)
|
||||
|
||||
self.assertEqual(self.get()['status'], 200)
|
||||
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf({"listeners": {}, "applications": {}}),
|
||||
|
||||
@@ -19,17 +19,9 @@ class TestPythonBasic(TestControl):
|
||||
}
|
||||
|
||||
def test_python_get_empty(self):
|
||||
self.assertEqual(
|
||||
self.conf_get(), {'listeners': {}, 'applications': {}}, 'empty'
|
||||
)
|
||||
|
||||
def test_python_get_prefix_listeners(self):
|
||||
self.assertEqual(self.conf_get('listeners'), {}, 'listeners prefix')
|
||||
|
||||
def test_python_get_prefix_applications(self):
|
||||
self.assertEqual(
|
||||
self.conf_get('applications'), {}, 'applications prefix'
|
||||
)
|
||||
self.assertEqual(self.conf_get(), {'listeners': {}, 'applications': {}})
|
||||
self.assertEqual(self.conf_get('listeners'), {})
|
||||
self.assertEqual(self.conf_get('applications'), {})
|
||||
|
||||
def test_python_get_applications(self):
|
||||
self.conf(self.conf_app, 'applications')
|
||||
@@ -50,9 +42,6 @@ class TestPythonBasic(TestControl):
|
||||
'applications',
|
||||
)
|
||||
|
||||
def test_python_get_applications_prefix(self):
|
||||
self.conf(self.conf_app, 'applications')
|
||||
|
||||
self.assertEqual(
|
||||
self.conf_get('applications'),
|
||||
{
|
||||
@@ -66,9 +55,6 @@ class TestPythonBasic(TestControl):
|
||||
'applications prefix',
|
||||
)
|
||||
|
||||
def test_python_get_applications_prefix_2(self):
|
||||
self.conf(self.conf_app, 'applications')
|
||||
|
||||
self.assertEqual(
|
||||
self.conf_get('applications/app'),
|
||||
{
|
||||
@@ -80,9 +66,6 @@ class TestPythonBasic(TestControl):
|
||||
'applications prefix 2',
|
||||
)
|
||||
|
||||
def test_python_get_applications_prefix_3(self):
|
||||
self.conf(self.conf_app, 'applications')
|
||||
|
||||
self.assertEqual(
|
||||
self.conf_get('applications/app/type'), 'python', 'type'
|
||||
)
|
||||
@@ -99,18 +82,12 @@ class TestPythonBasic(TestControl):
|
||||
'listeners',
|
||||
)
|
||||
|
||||
def test_python_get_listeners_prefix(self):
|
||||
self.conf(self.conf_basic)
|
||||
|
||||
self.assertEqual(
|
||||
self.conf_get('listeners'),
|
||||
{"*:7080": {"pass": "applications/app"}},
|
||||
'listeners prefix',
|
||||
)
|
||||
|
||||
def test_python_get_listeners_prefix_2(self):
|
||||
self.conf(self.conf_basic)
|
||||
|
||||
self.assertEqual(
|
||||
self.conf_get('listeners/*:7080'),
|
||||
{"pass": "applications/app"},
|
||||
@@ -160,44 +137,18 @@ class TestPythonBasic(TestControl):
|
||||
def test_python_delete(self):
|
||||
self.conf(self.conf_basic)
|
||||
|
||||
self.assertIn(
|
||||
'error',
|
||||
self.conf_delete('applications/app'),
|
||||
'delete app before listener',
|
||||
)
|
||||
self.assertIn(
|
||||
'success', self.conf_delete('listeners/*:7080'), 'delete listener'
|
||||
)
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf_delete('applications/app'),
|
||||
'delete app after listener',
|
||||
)
|
||||
self.assertIn(
|
||||
'error', self.conf_delete('applications/app'), 'delete app again'
|
||||
)
|
||||
self.assertIn('error', self.conf_delete('applications/app'))
|
||||
self.assertIn('success', self.conf_delete('listeners/*:7080'))
|
||||
self.assertIn('success', self.conf_delete('applications/app'))
|
||||
self.assertIn('error', self.conf_delete('applications/app'))
|
||||
|
||||
def test_python_delete_blocks(self):
|
||||
self.conf(self.conf_basic)
|
||||
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf_delete('listeners'),
|
||||
'listeners delete',
|
||||
)
|
||||
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf_delete('applications'),
|
||||
'applications delete',
|
||||
)
|
||||
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf(self.conf_app, 'applications'),
|
||||
'listeners restore',
|
||||
)
|
||||
self.assertIn('success', self.conf_delete('listeners'))
|
||||
self.assertIn('success', self.conf_delete('applications'))
|
||||
|
||||
self.assertIn('success', self.conf(self.conf_app, 'applications'))
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners'),
|
||||
|
||||
@@ -196,7 +196,7 @@ class TestPythonProcman(TestApplicationPython):
|
||||
)
|
||||
self.assertIn(
|
||||
'error',
|
||||
self.conf({"idle_timeout": -1}, self.app_proc,),
|
||||
self.conf({"idle_timeout": -1}, self.app_proc),
|
||||
'negative idle_timeout',
|
||||
)
|
||||
self.assertIn(
|
||||
@@ -206,12 +206,12 @@ class TestPythonProcman(TestApplicationPython):
|
||||
)
|
||||
self.assertIn(
|
||||
'error',
|
||||
self.conf({"spare": 2, "max": 1}, self.app_proc,),
|
||||
self.conf({"spare": 2, "max": 1}, self.app_proc),
|
||||
'spare gt max',
|
||||
)
|
||||
self.assertIn(
|
||||
'error',
|
||||
self.conf({"spare": 0, "max": 0}, self.app_proc,),
|
||||
self.conf({"spare": 0, "max": 0}, self.app_proc),
|
||||
'max zero',
|
||||
)
|
||||
|
||||
|
||||
@@ -605,7 +605,7 @@ class TestRouting(TestApplicationProto):
|
||||
self.assertIn(
|
||||
'success',
|
||||
self.conf_post(
|
||||
{"match": {"method": "POST"}, "action": {"return": 200},},
|
||||
{"match": {"method": "POST"}, "action": {"return": 200}},
|
||||
'routes',
|
||||
),
|
||||
'routes edit configure 6',
|
||||
|
||||
@@ -322,6 +322,7 @@ class TestRubyApplication(TestApplicationRuby):
|
||||
|
||||
self.assertEqual(self.get()['status'], 200, 'init')
|
||||
|
||||
body = '0123456789' * 500
|
||||
(resp, sock) = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -329,12 +330,13 @@ class TestRubyApplication(TestApplicationRuby):
|
||||
'Content-Type': 'text/html',
|
||||
},
|
||||
start=True,
|
||||
body='0123456789' * 500,
|
||||
body=body,
|
||||
read_timeout=1,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 1')
|
||||
|
||||
body = '0123456789'
|
||||
resp = self.post(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
@@ -342,10 +344,10 @@ class TestRubyApplication(TestApplicationRuby):
|
||||
'Content-Type': 'text/html',
|
||||
},
|
||||
sock=sock,
|
||||
body='0123456789',
|
||||
body=body,
|
||||
)
|
||||
|
||||
self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
|
||||
self.assertEqual(resp['body'], body, 'keep-alive 2')
|
||||
|
||||
def test_ruby_application_constants(self):
|
||||
self.load('constants')
|
||||
|
||||
@@ -521,7 +521,6 @@ basicConstraints = critical,CA:TRUE"""
|
||||
)
|
||||
|
||||
def test_tls_application_respawn(self):
|
||||
self.skip_alerts.append(r'process \d+ exited on signal 9')
|
||||
self.load('mirror')
|
||||
|
||||
self.certificate()
|
||||
@@ -530,7 +529,7 @@ basicConstraints = critical,CA:TRUE"""
|
||||
|
||||
self.add_tls(application='mirror')
|
||||
|
||||
(resp, sock) = self.post_ssl(
|
||||
(_, sock) = self.post_ssl(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'Connection': 'keep-alive',
|
||||
@@ -545,6 +544,8 @@ basicConstraints = critical,CA:TRUE"""
|
||||
|
||||
subprocess.call(['kill', '-9', app_id])
|
||||
|
||||
self.skip_alerts.append(r'process %s exited on signal 9' % app_id)
|
||||
|
||||
self.wait_for_record(
|
||||
re.compile(
|
||||
' (?!' + app_id + '#)(\d+)#\d+ "mirror" application started'
|
||||
|
||||
@@ -55,7 +55,7 @@ class TestUSR1(TestApplicationPython):
|
||||
self.load('log_body')
|
||||
|
||||
log_new = 'new.log'
|
||||
log_path = self.testdir + '/' + 'unit.log'
|
||||
log_path = self.testdir + '/unit.log'
|
||||
log_path_new = self.testdir + '/' + log_new
|
||||
|
||||
os.rename(log_path, log_path_new)
|
||||
|
||||
@@ -279,12 +279,8 @@ class TestHTTP(TestUnit):
|
||||
def _parse_json(self, resp):
|
||||
headers = resp['headers']
|
||||
|
||||
self.assertIn('Content-Type', headers, 'Content-Type header set')
|
||||
self.assertEqual(
|
||||
headers['Content-Type'],
|
||||
'application/json',
|
||||
'Content-Type header is application/json',
|
||||
)
|
||||
self.assertIn('Content-Type', headers)
|
||||
self.assertEqual(headers['Content-Type'], 'application/json')
|
||||
|
||||
resp['body'] = json.loads(resp['body'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user