test_configuration.py (1041:9bdd46610ea9) test_configuration.py (1064:75a64629661f)
1import unittest
2from unit.control import TestControl
3
4
5class TestConfiguration(TestControl):
6 prerequisites = ['python']
7
8 def test_json_empty(self):

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

84 )
85
86 def test_applications_open_brace(self):
87 self.assertIn('error', self.conf('{', 'applications'), 'open brace')
88
89 def test_applications_string(self):
90 self.assertIn('error', self.conf('"{}"', 'applications'), 'string')
91
1import unittest
2from unit.control import TestControl
3
4
5class TestConfiguration(TestControl):
6 prerequisites = ['python']
7
8 def test_json_empty(self):

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

84 )
85
86 def test_applications_open_brace(self):
87 self.assertIn('error', self.conf('{', 'applications'), 'open brace')
88
89 def test_applications_string(self):
90 self.assertIn('error', self.conf('"{}"', 'applications'), 'string')
91
92 @unittest.skip('not yet, unsafe')
92 def test_applications_type_only(self):
93 def test_applications_type_only(self):
93 self.skip_alerts.extend(
94 [
95 r'python module is empty',
96 r'failed to apply new conf',
97 r'process \d+ exited on signal',
98 ]
99 )
100
101 self.assertIn(
102 'error',
103 self.conf({"app": {"type": "python"}}, 'applications'),
104 'type only',
105 )
106
107 def test_applications_miss_quote(self):
108 self.assertIn(

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

178 "module": "wsgi",
179 }
180 },
181 'applications',
182 ),
183 'relative path',
184 )
185
94 self.assertIn(
95 'error',
96 self.conf({"app": {"type": "python"}}, 'applications'),
97 'type only',
98 )
99
100 def test_applications_miss_quote(self):
101 self.assertIn(

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

171 "module": "wsgi",
172 }
173 },
174 'applications',
175 ),
176 'relative path',
177 )
178
186 @unittest.expectedFailure
179 @unittest.skip('not yet, unsafe')
187 def test_listeners_empty(self):
180 def test_listeners_empty(self):
188 self.skip_sanitizer = True
189 self.skip_alerts.extend(
190 [
191 r'failed to apply previous configuration',
192 r'process \d+ exited on signal',
193 ]
194 )
195
196 self.assertIn(
197 'error', self.conf({"*:7080": {}}, 'listeners'), 'listener empty'
198 )
199
200 def test_listeners_no_app(self):
201 self.assertIn(
202 'error',
203 self.conf({"*:7080": {"pass": "applications/app"}}, 'listeners'),

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

256 "module": "wsgi",
257 }
258 },
259 }
260 ),
261 'explicit ipv6',
262 )
263
181 self.assertIn(
182 'error', self.conf({"*:7080": {}}, 'listeners'), 'listener empty'
183 )
184
185 def test_listeners_no_app(self):
186 self.assertIn(
187 'error',
188 self.conf({"*:7080": {"pass": "applications/app"}}, 'listeners'),

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

241 "module": "wsgi",
242 }
243 },
244 }
245 ),
246 'explicit ipv6',
247 )
248
249 @unittest.skip('not yet, unsafe')
264 def test_listeners_no_port(self):
250 def test_listeners_no_port(self):
265 self.skip_alerts.extend(
266 [
267 r'invalid listener "127\.0\.0\.1"',
268 r'failed to apply new conf',
269 r'process \d+ exited on signal',
270 ]
271 )
272
273 self.assertIn(
274 'error',
275 self.conf(
276 {
277 "listeners": {"127.0.0.1": {"pass": "applications/app"}},
278 "applications": {
279 "app": {
280 "type": "python",

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

303 "path": "/app",
304 "module": "wsgi",
305 }
306 },
307 }
308 ),
309 )
310
251 self.assertIn(
252 'error',
253 self.conf(
254 {
255 "listeners": {"127.0.0.1": {"pass": "applications/app"}},
256 "applications": {
257 "app": {
258 "type": "python",

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

281 "path": "/app",
282 "module": "wsgi",
283 }
284 },
285 }
286 ),
287 )
288
311 @unittest.expectedFailure
289 @unittest.skip('not yet')
312 def test_json_application_many(self):
290 def test_json_application_many(self):
313 self.skip_alerts.extend(
314 [r'eventfd.+failed', r'epoll.+failed', r'failed to apply']
315 )
316 apps = 999
317
318 conf = {
319 "applications": {
320 "app-"
321 + str(a): {
322 "type": "python",
323 "processes": {"spare": 0},

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

330 "*:" + str(7000 + a): {"pass": "applications/app-" + str(a)}
331 for a in range(apps)
332 },
333 }
334
335 self.assertIn('success', self.conf(conf))
336
337 def test_json_application_many2(self):
291 apps = 999
292
293 conf = {
294 "applications": {
295 "app-"
296 + str(a): {
297 "type": "python",
298 "processes": {"spare": 0},

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

305 "*:" + str(7000 + a): {"pass": "applications/app-" + str(a)}
306 for a in range(apps)
307 },
308 }
309
310 self.assertIn('success', self.conf(conf))
311
312 def test_json_application_many2(self):
338 self.skip_alerts.extend(
339 [r'eventfd.+failed', r'epoll.+failed', r'failed to apply']
340 )
341
342 conf = {
343 "applications": {
344 "app-"
345 + str(a): {
346 "type": "python",
347 "processes": {"spare": 0},
348 "path": "/app",
349 "module": "wsgi",
350 }
351 for a in range(999)
352 },
353 "listeners": {"*:7001": {"pass": "applications/app-1"}},
354 }
355
356 self.assertIn('success', self.conf(conf))
357
358
359if __name__ == '__main__':
360 TestConfiguration.main()
313 conf = {
314 "applications": {
315 "app-"
316 + str(a): {
317 "type": "python",
318 "processes": {"spare": 0},
319 "path": "/app",
320 "module": "wsgi",
321 }
322 for a in range(999)
323 },
324 "listeners": {"*:7001": {"pass": "applications/app-1"}},
325 }
326
327 self.assertIn('success', self.conf(conf))
328
329
330if __name__ == '__main__':
331 TestConfiguration.main()