示例#1
0
 def test_disables_database_connections_in_reactor(self):
     self.assertConnectionsEnabled()
     service_maker = RegionWorkerServiceMaker("Harry", "Hill")
     # Disable _configureThreads() as it's too invasive right now.
     self.patch_autospec(service_maker, "_configureThreads")
     service_maker.makeService(Options())
     self.assertConnectionsDisabled()
示例#2
0
 def test_makeService_configures_pserv_debug(self):
     options = Options()
     service_maker = RegionWorkerServiceMaker("Harry", "Hill")
     mock_pserv = self.patch(service_maker, "_configurePservSettings")
     # Disable _configureThreads() as it's too invasive right now.
     self.patch_autospec(service_maker, "_configureThreads")
     service_maker.makeService(options)
     self.assertThat(mock_pserv, MockCalledOnceWith())
示例#3
0
 def test_configures_thread_pool(self):
     # Patch and restore where it's visible because patching a running
     # reactor is potentially fairly harmful.
     patcher = monkey.MonkeyPatcher()
     patcher.add_patch(reactor, "threadpool", None)
     patcher.add_patch(reactor, "threadpoolForDatabase", None)
     patcher.patch()
     try:
         service_maker = RegionWorkerServiceMaker("Harry", "Hill")
         service_maker.makeService(Options())
         threadpool = reactor.getThreadPool()
         self.assertThat(threadpool, IsInstance(ThreadPool))
     finally:
         patcher.restore()
示例#4
0
 def test_makeService_without_import_services(self):
     options = Options()
     service_maker = RegionWorkerServiceMaker("Harry", "Hill")
     # Disable _configureThreads() as it's too invasive right now.
     self.patch_autospec(service_maker, "_configureThreads")
     service = service_maker.makeService(options)
     self.assertIsInstance(service, MultiService)
     expected_services = [
         "database-tasks",
         "postgres-listener-worker",
         "rack-controller",
         "rpc",
         "status-worker",
         "web",
         "ipc-worker",
     ]
     self.assertItemsEqual(expected_services, service.namedServices.keys())
     self.assertEqual(
         len(service.namedServices),
         len(service.services),
         "Not all services are named.",
     )
     self.assertThat(
         logger.configure,
         MockCalledOnceWith(
             options["verbosity"], logger.LoggingMode.TWISTD
         ),
     )
     self.assertThat(crochet.no_setup, MockCalledOnceWith())
示例#5
0
 def test_makeService_with_import_services(self):
     options = Options()
     service_maker = RegionWorkerServiceMaker("Harry", "Hill")
     # Disable _configureThreads() as it's too invasive right now.
     self.patch_autospec(service_maker, "_configureThreads")
     # Set the environment variable to create the import services.
     self.useFixture(
         EnvironmentVariableFixture(
             'MAAS_REGIOND_RUN_IMPORTER_SERVICE', 'true'))
     service = service_maker.makeService(options)
     self.assertIsInstance(service, MultiService)
     expected_services = [
         "database-tasks",
         "postgres-listener-worker",
         "rack-controller",
         "rpc",
         "status-worker",
         "web",
         "ipc-worker",
         "import-resources",
         "import-resources-progress",
     ]
     self.assertItemsEqual(expected_services, service.namedServices.keys())
     self.assertEqual(
         len(service.namedServices), len(service.services),
         "Not all services are named.")
     self.assertThat(
         logger.configure, MockCalledOnceWith(
             options["verbosity"], logger.LoggingMode.TWISTD))
     self.assertThat(crochet.no_setup, MockCalledOnceWith())