Beispiel #1
0
    def make_IPCMasterService(self, workers=None, run_loop=False):
        master = IPCMasterService(
            reactor, workers=workers, socket_path=self.ipc_path)

        if not run_loop:
            # Prevent the update loop from running.
            loop = MagicMock()
            loop.start.return_value = succeed(None)
            loop.running = True
            master.updateLoop = loop

        return master
Beispiel #2
0
    def make_IPCMasterService(self, workers=None):
        master = IPCMasterService(reactor,
                                  workers=workers,
                                  socket_path=self.ipc_path)

        dv_connected = DeferredValue()
        original_registerWorker = master.registerWorker

        def mock_registerWorker(*args, **kwargs):
            original_registerWorker(*args, **kwargs)
            dv_connected.set(None)

        new_registerWorker = self.patch(master, 'registerWorker')
        new_registerWorker.side_effect = mock_registerWorker

        dv_disconnected = DeferredValue()
        original_unregisterWorker = master.unregisterWorker

        def mock_unregisterWorker(*args, **kwargs):
            original_unregisterWorker(*args, **kwargs)
            dv_disconnected.set(None)

        new_unregisterWorker = self.patch(master, 'unregisterWorker')
        new_unregisterWorker.side_effect = mock_unregisterWorker

        return master, dv_connected, dv_disconnected
Beispiel #3
0
def make_IPCMasterService(workers=None):
    from maasserver.ipc import IPCMasterService
    return IPCMasterService(reactor, workers)