Exemplo n.º 1
0
 def testStartAutoDiscoverySameNodeError(self):
     '''Try to start a bootstrap node and then two clients on the same port with autodiscovery on.        
        Should log an error when the second node attempts to join.
     '''
     
     log.msg("---------------------- BEGIN testStartAutoDiscoverySameNodeError -------------- ")
     self.allNodes = []
     self.allMetricsObservers = []
     self.allTestObservers = []
     
     # Create Bootstrap
     port = 12345
     enclaveStr = 'testclave'
     bsNodeLocation = NodeLocation(None, self.myIP, port)
     bootstrapNodeList = [ bsNodeLocation ]
             
     (self.bsClient, self.bsNetwork, d) = self.startBootstrapNode(enclaveStr, self.myIP, port, "authenticate:succeed", bootstrapNodeList)
     yield d
     
     # Now startup one client which will succeed
     d2 = defer.Deferred()
     port = port + 1
     
     clientAPI = SampleClient(self.myIP, port, None)
     networkAPI = classChordNetworkChord(clientAPI, port, self.myIP)
     nodeID = networkAPI.generateNodeID(str(port), enclaveStr) # Get the ID with the bits on it we need. Use "port" because it'll be uniq for tests
     
     # Join the network
     callFunc = lambda result, payload: self.shouldSucceedCallback(result, payload, d2, networkAPI)
     networkAPI.start(callFunc, nodeID, enclaveStr, "authenticate:succeed", bootstrapNodeList, False, True)
     
     yield d2
             
     # Now startup one which should fail due to duplicate port
     d3 = defer.Deferred()
     
     clientAPI2 = SampleClient(self.myIP, port, None)
     networkAPI2 = classChordNetworkChord(clientAPI2, port, self.myIP)
     nodeID = networkAPI.generateNodeID(str(port), enclaveStr) # Get the ID with the bits on it we need. Use "port" because it'll be uniq for tests
     
     # Join the network
     callFunc2 = lambda result, payload: self.shouldFailureCallback(result, payload, d3)
     networkAPI2.start(callFunc2, nodeID, enclaveStr, "authenticate:succeed",bootstrapNodeList, False, True)
     
     yield d3
     
     yield networkAPI.disconnect()
     #yield networkAPI2.disconnect()
     yield self.bsNetwork.disconnect()
     
     # Try and wait for connection cache to finish disconnects (just in case).
     yield TestUtils.waitForConnectionCache()