summaryrefslogtreecommitdiff
path: root/oslo_middleware/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-11-13 03:41:12 +0000
committerGerrit Code Review <review@openstack.org>2015-11-13 03:41:12 +0000
commitae44f8ce5085130de9315bbcd8c4d8623812d780 (patch)
treee2217906a615d17f9e95694992727265c0f44385 /oslo_middleware/tests
parente11c08eef8587518010ce2dbbeb8b450886b09bf (diff)
parentff3cfe054bc31937376228a6a4830face6f3914b (diff)
downloadoslo-middleware-ae44f8ce5085130de9315bbcd8c4d8623812d780.tar.gz
Merge "Add a disabled by ports -> files healthcheck plugin"2.11.0
Diffstat (limited to 'oslo_middleware/tests')
-rw-r--r--oslo_middleware/tests/test_healthcheck.py41
1 files changed, 38 insertions, 3 deletions
diff --git a/oslo_middleware/tests/test_healthcheck.py b/oslo_middleware/tests/test_healthcheck.py
index 144d274..3ffb03f 100644
--- a/oslo_middleware/tests/test_healthcheck.py
+++ b/oslo_middleware/tests/test_healthcheck.py
@@ -29,18 +29,21 @@ class HealthcheckTests(test_base.BaseTestCase):
return 'Hello, World!!!'
def _do_test_request(self, conf={}, path='/healthcheck',
- accept='text/plain', method='GET'):
+ accept='text/plain', method='GET',
+ server_port=80):
self.app = healthcheck.Healthcheck(self.application, conf)
req = webob.Request.blank(path, accept=accept, method=method)
+ req.server_port = server_port
res = req.get_response(self.app)
return res
def _do_test(self, conf={}, path='/healthcheck',
expected_code=webob.exc.HTTPOk.code,
expected_body=b'', accept='text/plain',
- method='GET'):
+ method='GET', server_port=80):
res = self._do_test_request(conf=conf, path=path,
- accept=accept, method=method)
+ accept=accept, method=method,
+ server_port=server_port)
self.assertEqual(expected_code, res.status_int)
self.assertEqual(expected_body, res.body)
@@ -125,3 +128,35 @@ class HealthcheckTests(test_base.BaseTestCase):
expected_code=webob.exc.HTTPServiceUnavailable.code,
expected_body=b'DISABLED BY FILE\nDISABLED BY FILE')
self.assertIn('disable_by_file', self.app._backends.names())
+
+ def test_disable_by_port_file(self):
+ filename = self.create_tempfiles([('test', 'foobar')])[0]
+ conf = {'backends': 'disable_by_files_ports',
+ 'disable_by_file_paths': "80:%s" % filename}
+ self._do_test(conf,
+ expected_code=webob.exc.HTTPServiceUnavailable.code,
+ expected_body=b'DISABLED BY FILE')
+ self.assertIn('disable_by_files_ports', self.app._backends.names())
+
+ def test_no_disable_by_port_file(self):
+ filename = self.create_tempfiles([('test', 'foobar')])[0]
+ conf = {'backends': 'disable_by_files_ports',
+ 'disable_by_file_paths': "8000:%s" % filename}
+ self._do_test(conf,
+ expected_code=webob.exc.HTTPOk.code,
+ expected_body=b'OK')
+ self.assertIn('disable_by_files_ports', self.app._backends.names())
+
+ def test_disable_by_port_many_files(self):
+ filename = self.create_tempfiles([('test', 'foobar')])[0]
+ filename2 = self.create_tempfiles([('test2', 'foobar2')])[0]
+ conf = {'backends': 'disable_by_files_ports',
+ 'disable_by_file_paths': "80:%s,81:%s" % (filename, filename2)}
+ self._do_test(conf,
+ expected_code=webob.exc.HTTPServiceUnavailable.code,
+ expected_body=b'DISABLED BY FILE')
+ self._do_test(conf,
+ expected_code=webob.exc.HTTPServiceUnavailable.code,
+ expected_body=b'DISABLED BY FILE',
+ server_port=81)
+ self.assertIn('disable_by_files_ports', self.app._backends.names())