Esempio n. 1
0
    def testDualConnectThrows(self):
        server1 = SimpleServer.SimpleServer(port = Setup.config().testPort)

        thread1 = threading.Thread(target=suppressExceptionLogging(server1.runListenLoop))
        thread1.start()
        server1.blockUntilListening()

        server2 = SimpleServer.SimpleServer(port = Setup.config().testPort)
        thread2 = threading.Thread(target=suppressExceptionLogging(server2.runListenLoop))
        thread2.start()

        self.assertRaises(Exception, server2.blockUntilListening)
        server1.stop()
        server2.stop()

        thread1.join()
        thread2.join()
Esempio n. 2
0
    def __init__(self, numKeys, keySize):
        self.q = Queue.Queue()
        self.port = Setup.config().testPort
        self.server = SimpleServer.SimpleServer(self.port)
        self.server._onConnect = lambda sock, address : self.q.put(sock)

        self.serverThread = ManagedThread.ManagedThread(target=self.server.start)
        self.serverThread.daemon = True
        self.serverThread.start()
        ChannelTester.__init__(self, self.createSocketChannels, numKeys, keySize)
Esempio n. 3
0
    def testRapidOpenClose(self):
        for ix in range(100):
            server = SimpleServer.SimpleServer(port=Setup.config().testPort)

            thread = threading.Thread(target=suppressExceptionLogging(server.runListenLoop))
            thread.start()

            server.blockUntilListening()

            server.stop()

            thread.join()
Esempio n. 4
0
    def __init__(self, port, portScanIncrement=0):
        assert isinstance(port, int)
        assert isinstance(portScanIncrement, int)

        self.requestedPort = port
        self.port = port
        self.portScanIncrement = portScanIncrement
        self.socketServer = SimpleServer.SimpleServer(self.port)
        self.boundEvent_ = threading.Event()
        self.tornDown = False
        self.onPortBound = None
        self.socketConnectCallback = None
        self.socketServer._onConnect = self.onSocketConnect
        self.listenerThread = ManagedThread.ManagedThread(
            target=self.socketServer.start)
Esempio n. 5
0
 def __init__(self,
              machinesInCluster,
              ownAddress,
              testId,
              testDir,
              timeout=None):
     super(MultiMachineMasterRunner,
           self).__init__(machinesInCluster, ownAddress, testDir, testDir,
                          timeout)
     self.testControlServer = SimpleServer.SimpleServer(
         MultiMachineMasterRunner.TestControlPort)
     self.testControlServer._onConnect = self.onConnect
     self.serverThread = None
     self.lock = threading.Lock()
     self.allWorkersConnectedEvent = threading.Event()
     if len(self.machinesInCluster) == 1:
         self.allWorkersConnectedEvent.set()
     self.connectedWorkers = []
Esempio n. 6
0
    def __init__(self, callbackScheduler, cachePathOverride=None, port=None):
        self.callbackScheduler = callbackScheduler
        port = Setup.config().sharedStatePort
        logging.info("Initializing SharedStateService with port = %s", port)

        self.cachePath = cachePathOverride if cachePathOverride is not None else \
                         Setup.config().sharedStateCache

        if self.cachePath != '' and not os.path.exists(self.cachePath):
            os.makedirs(self.cachePath)

        CloudService.Service.__init__(self)
        self.socketServer = SimpleServer.SimpleServer(port)
        self.keyspaceManager = KeyspaceManager(
            0, 1, pingInterval=120, cachePathOverride=cachePathOverride)

        self.socketServer._onConnect = self.onConnect
        self.socketServerThread = ManagedThread.ManagedThread(
            target=self.socketServer.start)
        self.logfilePruneThread = ManagedThread.ManagedThread(
            target=self.logFilePruner)

        self.stoppedFlag = threading.Event()