diff options
author | Dmitry Tantsur <dtantsur@protonmail.com> | 2020-11-03 16:33:14 +0100 |
---|---|---|
committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2020-11-18 07:52:33 +0000 |
commit | 6c860c6bff2e08de8a8b0a0d63621335a25e3327 (patch) | |
tree | f6024599d1e2ccb02ae92852784b2960bdf58c3e /ironic/tests/unit | |
parent | 6da70f14ed2e634e9f527f52b3000c8158354a85 (diff) | |
download | ironic-6c860c6bff2e08de8a8b0a0d63621335a25e3327.tar.gz |
Limit the default value of [api]api_workers to 4
Each ironic-api process consumes non-negligible amount of RAM,
defaulting to CPU core count may result in many hundres of megabytes
occupied by ironic-api processes. Limit the default value to 4
and let people who actually need more than that pick their value.
Change-Id: I5aefa8c6c7aadc56aea151647e1c0a5af54ada4c
(cherry picked from commit c9c492725ed581db1ba49a1a5985bfcf4952e82d)
Diffstat (limited to 'ironic/tests/unit')
-rw-r--r-- | ironic/tests/unit/common/test_wsgi_service.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/ironic/tests/unit/common/test_wsgi_service.py b/ironic/tests/unit/common/test_wsgi_service.py index 5af26bf37..bc63c0dd2 100644 --- a/ironic/tests/unit/common/test_wsgi_service.py +++ b/ironic/tests/unit/common/test_wsgi_service.py @@ -23,12 +23,12 @@ CONF = cfg.CONF class TestWSGIService(base.TestCase): + @mock.patch.object(processutils, 'get_worker_count', lambda: 2) @mock.patch.object(wsgi_service.wsgi, 'Server', autospec=True) def test_workers_set_default(self, mock_server): service_name = "ironic_api" test_service = wsgi_service.WSGIService(service_name) - self.assertEqual(processutils.get_worker_count(), - test_service.workers) + self.assertEqual(2, test_service.workers) mock_server.assert_called_once_with(CONF, service_name, test_service.app, host='0.0.0.0', @@ -41,11 +41,19 @@ class TestWSGIService(base.TestCase): test_service = wsgi_service.WSGIService("ironic_api") self.assertEqual(8, test_service.workers) + @mock.patch.object(processutils, 'get_worker_count', lambda: 3) @mock.patch.object(wsgi_service.wsgi, 'Server', autospec=True) def test_workers_set_zero_setting(self, mock_server): self.config(api_workers=0, group='api') test_service = wsgi_service.WSGIService("ironic_api") - self.assertEqual(processutils.get_worker_count(), test_service.workers) + self.assertEqual(3, test_service.workers) + + @mock.patch.object(processutils, 'get_worker_count', lambda: 42) + @mock.patch.object(wsgi_service.wsgi, 'Server', autospec=True) + def test_workers_set_default_limit(self, mock_server): + self.config(api_workers=0, group='api') + test_service = wsgi_service.WSGIService("ironic_api") + self.assertEqual(4, test_service.workers) @mock.patch.object(wsgi_service.wsgi, 'Server', autospec=True) def test_workers_set_negative_setting(self, mock_server): |