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')
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
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')
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
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')
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
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')
290 def test_json_application_many(self):
313 self.skip_alerts.extend(
314 [r'eventfd.+failed', r'epoll.+failed', r'failed to apply']
315 )
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
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()