def test_disables_database_connections_in_reactor(self): self.assertConnectionsEnabled() service_maker = RegionAllInOneServiceMaker("Harry", "Hill") # Disable _ensureConnection() its not allowed in the reactor. self.patch_autospec(service_maker, "_ensureConnection") # Disable _configureThreads() as it's too invasive right now. self.patch_autospec(service_maker, "_configureThreads") service_maker.makeService(Options()) self.assertConnectionsDisabled()
def test_makeService_configures_pserv_debug(self): options = Options() service_maker = RegionAllInOneServiceMaker("Harry", "Hill") mock_pserv = self.patch(service_maker, "_configurePservSettings") # Disable _ensureConnection() its not allowed in the reactor. self.patch_autospec(service_maker, "_ensureConnection") # Disable _configureThreads() as it's too invasive right now. self.patch_autospec(service_maker, "_configureThreads") service_maker.makeService(options) self.assertThat(mock_pserv, MockCalledOnceWith())
def test_makeService(self): options = Options() service_maker = RegionAllInOneServiceMaker("Harry", "Hill") # Disable _ensureConnection() its not allowed in the reactor. self.patch_autospec(service_maker, "_ensureConnection") # 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 = [ # Worker services. "database-tasks", "postgres-listener-worker", "rack-controller", "rpc", "service-monitor", "status-worker", "web", "ipc-worker", # Master services. "region-controller", "nonce-cleanup", "dns-publication-cleanup", "status-monitor", "stats", "prometheus", "prometheus-exporter", "import-resources", "import-resources-progress", "postgres-listener-master", "networks-monitor", "active-discovery", "reverse-dns", "ntp", "syslog", # "workers", Prevented in all-in-one. "ipc-master", ] 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())
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 = RegionAllInOneServiceMaker("Harry", "Hill") # Disable _ensureConnection() its not allowed in the reactor. self.patch_autospec(service_maker, "_ensureConnection") service_maker.makeService(Options()) threadpool = reactor.getThreadPool() self.assertThat(threadpool, IsInstance(ThreadPool)) finally: patcher.restore()
def test_init(self): service_maker = RegionAllInOneServiceMaker("Harry", "Hill") self.assertEqual("Harry", service_maker.tapname) self.assertEqual("Hill", service_maker.description)
RegionMasterServiceMaker, RegionWorkerServiceMaker, ) except ImportError: pass else: # Regiond services that twisted could spawn. twistd_plugins.append( RegionMasterServiceMaker("maas-regiond-master", "The MAAS Region Controller master process.")) twistd_plugins.append( RegionWorkerServiceMaker("maas-regiond-worker", "The MAAS Region Controller worker process.")) twistd_plugins.append( RegionAllInOneServiceMaker( "maas-regiond-all", "The MAAS Region Controller all-in-one process.")) class Options(ServerOptions): """Override the plugins path for the server options.""" @staticmethod def _getPlugins(interface): return twistd_plugins def runService(service): """Run the `service`.""" config = Options() args = [ '--logger=provisioningserver.logger.EventLogger', '--nodaemon',