]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Override osapi_volume_listen_port for test_workers
authorMitsuhiro Tanino <mitsuhiro.tanino@hds.com>
Fri, 18 Dec 2015 16:02:27 +0000 (11:02 -0500)
committerMitsuhiro Tanino <mitsuhiro.tanino@hds.com>
Fri, 18 Dec 2015 16:02:27 +0000 (11:02 -0500)
After removing WSGI from Cinder, following test cases hit
"socket.error: [Errno 98] Address already in use" error.

- test_workers_set_default
- test_workers_set_good_user_setting
- test_workers_set_zero_user_setting

The root cause is that these test cases try to use 8776 port,
but the port is used by c-api if the service exists.
This patch override default port number to avoid the error.

Change-Id: I8e2b505c2aff511969cd55851272b10c013aef6c
Closes-Bug: #1527566

cinder/tests/unit/test_service.py

index 7dee67b8a0dc7ba980b06ff1bfd43127fb7aa284..ee8f02099a370df378356b5281726060d50434f6 100644 (file)
@@ -278,17 +278,20 @@ class TestWSGIService(test.TestCase):
 
     @mock.patch('oslo_service.wsgi.Server')
     def test_workers_set_default(self, wsgi_server):
+        self.override_config('osapi_volume_listen_port', 0)
         test_service = service.WSGIService("osapi_volume")
         self.assertEqual(processutils.get_worker_count(), test_service.workers)
 
     @mock.patch('oslo_service.wsgi.Server')
     def test_workers_set_good_user_setting(self, wsgi_server):
+        self.override_config('osapi_volume_listen_port', 0)
         self.override_config('osapi_volume_workers', 8)
         test_service = service.WSGIService("osapi_volume")
         self.assertEqual(8, test_service.workers)
 
     @mock.patch('oslo_service.wsgi.Server')
     def test_workers_set_zero_user_setting(self, wsgi_server):
+        self.override_config('osapi_volume_listen_port', 0)
         self.override_config('osapi_volume_workers', 0)
         test_service = service.WSGIService("osapi_volume")
         # If a value less than 1 is used, defaults to number of procs available