Exemple #1
0
 def test_service_random_port(self, mock_find_config):
     with mock.patch.object(wsgi.Loader, 'load_app') as mock_load_app:
         test_service = service.WSGIService("test_service")
         self.assertEqual(0, test_service.port)
         test_service.start()
         self.assertNotEqual(0, test_service.port)
         test_service.stop()
         self.assertTrue(mock_load_app.called)
Exemple #2
0
    def test_reset_pool_size_to_default(self, mock_find_config):
        with mock.patch.object(wsgi.Loader, 'load_app') as mock_load_app:
            test_service = service.WSGIService("test_service")
            test_service.start()

            # Stopping the service, which in turn sets pool size to 0
            test_service.stop()
            self.assertEqual(0, test_service.server._pool.size)

            # Resetting pool size to default
            test_service.reset()
            test_service.start()
            self.assertEqual(1000, test_service.server._pool.size)
            self.assertTrue(mock_load_app.called)
Exemple #3
0
 def test_workers_set_zero_user_setting(self, wsgi_server, mock_load_app,
                                        mock_find_config):
     self.override_config('osapi_smaug_workers', 0)
     test_service = service.WSGIService("osapi_smaug")
     # If a value less than 1 is used, defaults to number of procs available
     self.assertEqual(processutils.get_worker_count(), test_service.workers)
Exemple #4
0
 def test_workers_set_good_user_setting(self, wsgi_server, mock_load_app,
                                        mock_find_config):
     self.override_config('osapi_smaug_workers', 8)
     test_service = service.WSGIService("osapi_smaug")
     self.assertEqual(8, test_service.workers)
Exemple #5
0
 def test_workers_set_default(self, wsgi_server, mock_load_app,
                              mock_find_config):
     test_service = service.WSGIService("osapi_smaug")
     self.assertEqual(processutils.get_worker_count(), test_service.workers)