test_python_application.py (1028:2201c3f83ae3) test_python_application.py (1029:687f7cc7aae2)
1import time
2import unittest
3from unit.applications.lang.python import TestApplicationPython
4
5
6class TestPythonApplication(TestApplicationPython):
7 prerequisites = ['python']
8

--- 120 unchanged lines hidden (view full) ---

129
130 self.assertIsNotNone(
131 self.wait_for_record(r'RuntimeError'), 'ctx iter atexit'
132 )
133
134 def test_python_keepalive_body(self):
135 self.load('mirror')
136
1import time
2import unittest
3from unit.applications.lang.python import TestApplicationPython
4
5
6class TestPythonApplication(TestApplicationPython):
7 prerequisites = ['python']
8

--- 120 unchanged lines hidden (view full) ---

129
130 self.assertIsNotNone(
131 self.wait_for_record(r'RuntimeError'), 'ctx iter atexit'
132 )
133
134 def test_python_keepalive_body(self):
135 self.load('mirror')
136
137 self.assertEqual(self.get()['status'], 200, 'init')
138
137 (resp, sock) = self.post(
138 headers={
139 'Host': 'localhost',
140 'Connection': 'keep-alive',
141 'Content-Type': 'text/html',
142 },
143 start=True,
144 body='0123456789' * 500,
139 (resp, sock) = self.post(
140 headers={
141 'Host': 'localhost',
142 'Connection': 'keep-alive',
143 'Content-Type': 'text/html',
144 },
145 start=True,
146 body='0123456789' * 500,
147 read_timeout=1,
145 )
146
147 self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
148
149 resp = self.post(
150 headers={
151 'Host': 'localhost',
152 'Connection': 'close',

--- 10 unchanged lines hidden (view full) ---

163 [
164 r'pthread_mutex.+failed',
165 r'failed to apply',
166 r'process \d+ exited on signal',
167 ]
168 )
169 self.load('mirror')
170
148 )
149
150 self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
151
152 resp = self.post(
153 headers={
154 'Host': 'localhost',
155 'Connection': 'close',

--- 10 unchanged lines hidden (view full) ---

166 [
167 r'pthread_mutex.+failed',
168 r'failed to apply',
169 r'process \d+ exited on signal',
170 ]
171 )
172 self.load('mirror')
173
174 self.assertEqual(self.get()['status'], 200, 'init')
175
171 body = '0123456789'
172 conns = 3
173 socks = []
174
175 for i in range(conns):
176 (resp, sock) = self.post(
177 headers={
178 'Host': 'localhost',
179 'Connection': 'keep-alive',
180 'Content-Type': 'text/html',
181 },
182 start=True,
183 body=body,
176 body = '0123456789'
177 conns = 3
178 socks = []
179
180 for i in range(conns):
181 (resp, sock) = self.post(
182 headers={
183 'Host': 'localhost',
184 'Connection': 'keep-alive',
185 'Content-Type': 'text/html',
186 },
187 start=True,
188 body=body,
189 read_timeout=1,
184 )
185
186 self.assertEqual(resp['body'], body, 'keep-alive open')
187 self.assertIn(
188 'success',
189 self.conf(str(i + 1), 'applications/mirror/processes'),
190 'reconfigure',
191 )

--- 5 unchanged lines hidden (view full) ---

197 headers={
198 'Host': 'localhost',
199 'Connection': 'keep-alive',
200 'Content-Type': 'text/html',
201 },
202 start=True,
203 sock=socks[i],
204 body=body,
190 )
191
192 self.assertEqual(resp['body'], body, 'keep-alive open')
193 self.assertIn(
194 'success',
195 self.conf(str(i + 1), 'applications/mirror/processes'),
196 'reconfigure',
197 )

--- 5 unchanged lines hidden (view full) ---

203 headers={
204 'Host': 'localhost',
205 'Connection': 'keep-alive',
206 'Content-Type': 'text/html',
207 },
208 start=True,
209 sock=socks[i],
210 body=body,
211 read_timeout=1,
205 )
206
207 self.assertEqual(resp['body'], body, 'keep-alive request')
208 self.assertIn(
209 'success',
210 self.conf(str(i + 1), 'applications/mirror/processes'),
211 'reconfigure 2',
212 )

--- 14 unchanged lines hidden (view full) ---

227 'success',
228 self.conf(str(i + 1), 'applications/mirror/processes'),
229 'reconfigure 3',
230 )
231
232 def test_python_keepalive_reconfigure_2(self):
233 self.load('mirror')
234
212 )
213
214 self.assertEqual(resp['body'], body, 'keep-alive request')
215 self.assertIn(
216 'success',
217 self.conf(str(i + 1), 'applications/mirror/processes'),
218 'reconfigure 2',
219 )

--- 14 unchanged lines hidden (view full) ---

234 'success',
235 self.conf(str(i + 1), 'applications/mirror/processes'),
236 'reconfigure 3',
237 )
238
239 def test_python_keepalive_reconfigure_2(self):
240 self.load('mirror')
241
242 self.assertEqual(self.get()['status'], 200, 'init')
243
235 body = '0123456789'
236
237 (resp, sock) = self.post(
238 headers={
239 'Host': 'localhost',
240 'Connection': 'keep-alive',
241 'Content-Type': 'text/html',
242 },
243 start=True,
244 body=body,
244 body = '0123456789'
245
246 (resp, sock) = self.post(
247 headers={
248 'Host': 'localhost',
249 'Connection': 'keep-alive',
250 'Content-Type': 'text/html',
251 },
252 start=True,
253 body=body,
254 read_timeout=1,
245 )
246
247 self.assertEqual(resp['body'], body, 'reconfigure 2 keep-alive 1')
248
249 self.load('empty')
250
255 )
256
257 self.assertEqual(resp['body'], body, 'reconfigure 2 keep-alive 1')
258
259 self.load('empty')
260
261 self.assertEqual(self.get()['status'], 200, 'init')
262
251 (resp, sock) = self.post(
252 headers={
253 'Host': 'localhost',
254 'Connection': 'close',
255 'Content-Type': 'text/html',
256 },
257 start=True,
258 sock=sock,

--- 11 unchanged lines hidden (view full) ---

270
271 resp = self.get(sock=sock)
272
273 self.assertEqual(resp, {}, 'reconfigure 2 keep-alive 3')
274
275 def test_python_keepalive_reconfigure_3(self):
276 self.load('empty')
277
263 (resp, sock) = self.post(
264 headers={
265 'Host': 'localhost',
266 'Connection': 'close',
267 'Content-Type': 'text/html',
268 },
269 start=True,
270 sock=sock,

--- 11 unchanged lines hidden (view full) ---

282
283 resp = self.get(sock=sock)
284
285 self.assertEqual(resp, {}, 'reconfigure 2 keep-alive 3')
286
287 def test_python_keepalive_reconfigure_3(self):
288 self.load('empty')
289
290 self.assertEqual(self.get()['status'], 200, 'init')
291
278 (resp, sock) = self.http(
279 b"""GET / HTTP/1.1
280""",
281 start=True,
282 raw=True,
292 (resp, sock) = self.http(
293 b"""GET / HTTP/1.1
294""",
295 start=True,
296 raw=True,
297 read_timeout=1,
283 )
284
285 self.assertIn(
286 'success',
287 self.conf({"listeners": {}, "applications": {}}),
288 'reconfigure 3 clear configuration',
289 )
290

--- 164 unchanged lines hidden ---
298 )
299
300 self.assertIn(
301 'success',
302 self.conf({"listeners": {}, "applications": {}}),
303 'reconfigure 3 clear configuration',
304 )
305

--- 164 unchanged lines hidden ---