当前位置: 首页>>代码示例>>Python>>正文


Python TestUtils.waitForConnectionCache方法代码示例

本文整理汇总了Python中TestUtils.waitForConnectionCache方法的典型用法代码示例。如果您正苦于以下问题:Python TestUtils.waitForConnectionCache方法的具体用法?Python TestUtils.waitForConnectionCache怎么用?Python TestUtils.waitForConnectionCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestUtils的用法示例。


在下文中一共展示了TestUtils.waitForConnectionCache方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testStartAutoDiscoveryClient

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import waitForConnectionCache [as 别名]
    def testStartAutoDiscoveryClient(self):
        '''Try to start a bootstrap node with autodiscovery on.
        '''
        
        log.msg("---------------------- BEGIN testStartAutoDiscoveryClient -------------- ")
        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 try and join with autodiscovery
        yield self.startClientNodeAutoDiscovery(None, self.myIP, port+1, enclaveStr, bootstrapNodeList)

        # Shut it all down
        for (clientAPI, networkAPI) in self.allNodes:
            yield networkAPI.disconnect()
            
        yield self.bsNetwork.disconnect()     
        
        # Try and wait for connection cache to finish disconnects (just in case).
        yield TestUtils.waitForConnectionCache()        
开发者ID:danfleck,项目名称:Class-Chord,代码行数:30,代码来源:AutoDiscoveryTest.py

示例2: testStartAutoDiscoveryClientTimeout

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import waitForConnectionCache [as 别名]
    def testStartAutoDiscoveryClientTimeout(self):
        '''Try to start a bootstrap node with autodiscovery on.
           This should show a failure notice.
        '''
        
        log.msg("---------------------- BEGIN testStartAutoDiscoveryClientTimeout -------------- ")
        self.allNodes = []
        self.allMetricsObservers = []
        self.allTestObservers = []

        # Create Bootstrap
        port = 12345
        enclaveStr = 'testclave'
        
        # Now try and join with autodiscovery
        d = defer.Deferred()
        
        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.shouldFailCallback(result, payload, d)
        networkAPI.start(callFunc, nodeID, enclaveStr, "authenticate:succeed", None, False, True)
        
        yield d
        
        yield TestUtils.waitForConnectionCache()        
开发者ID:danfleck,项目名称:Class-Chord,代码行数:30,代码来源:AutoDiscoveryTest.py

示例3: testMultipleBSNodesAutoDiscoveryClient

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import waitForConnectionCache [as 别名]
    def testMultipleBSNodesAutoDiscoveryClient(self):
        '''Try to start multiple bootstrap nodes then a client and make sure it connects to one of them.
        '''
        
        log.msg("---------------------- BEGIN testMultipleBSNodesAutoDiscoveryClient -------------- ")
        self.allNodes = []
        self.allMetricsObservers = []
        self.allTestObservers = []


        
        # Create Bootstrap
        port = 12345
        enclaveStr = 'testclave'
        bootstrapNodeList = [ NodeLocation(None, self.myIP, port), NodeLocation(None, self.myIP, port+1)]
        
        (self.bsClient1, self.bsNetwork1, d) = self.startBootstrapNode(enclaveStr, self.myIP, port, "authenticate:succeed", bootstrapNodeList)
        yield d

        (self.bsClient2, self.bsNetwork2, d) = self.startBootstrapNode(enclaveStr, self.myIP, port+1, "authenticate:succeed", None)
        yield d
                
        # Now try and join with autodiscovery
        yield self.startClientNodeAutoDiscovery(None, self.myIP, port+2, enclaveStr, bootstrapNodeList)

        # Shut it all down
        for (clientAPI, networkAPI) in self.allNodes:
            yield networkAPI.disconnect()
            
        yield self.bsNetwork1.disconnect()
        yield self.bsNetwork2.disconnect()  
                        
        yield TestUtils.waitForConnectionCache()        
开发者ID:danfleck,项目名称:Class-Chord,代码行数:35,代码来源:AutoDiscoveryTest.py

示例4: testDisconnectedBootstraps

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import waitForConnectionCache [as 别名]
    def testDisconnectedBootstraps(self):
        '''Create a BS node and some clients. Create another bootstrap node and some clients (so we essentially have two rings). 
           Verify, that the bootstrap nodes autodiscover each other and connect together            
        '''
        global startingPort
        
        # Create Bootstrap
        port = 12345
        bootstrapNodeLocation = NodeLocation(None, self.myIP, port)
        bootstrapNodeLocation2 = NodeLocation(None, self.myIP, port+1)
        self.allNodes = []
        self.allMetricsObservers = []
        self.allTestObservers = []

        # Build the BS node
        (status, bsClientAPI, bsNetworkAPI) = yield TestUtils.startNodeUsingAPI(bootstrapNodeLocation.ip, bootstrapNodeLocation.port, None, 'theEnclave', True, True)
        self.allMetricsObservers.append(MetricsMessageObserver(bsNetworkAPI.chordNode))
        self.assertTrue(status, 'Could not build bootstrap node')

        # Build second BS node
        (status, bsClientAPI2, bsNetworkAPI2) = yield TestUtils.startNodeUsingAPI(bootstrapNodeLocation2.ip, bootstrapNodeLocation2.port, None, 'theEnclave', True, True)
        self.allMetricsObservers.append(MetricsMessageObserver(bsNetworkAPI2.chordNode))
        self.assertTrue(status, 'Could not build bootstrap node 2')

                
        # Build the client node
        (status, clClientAPI, clNetworkAPI) = yield TestUtils.startNodeUsingAPI(self.myIP, port+2, bootstrapNodeLocation, 'theEnclave', False, False)
        self.allMetricsObservers.append(MetricsMessageObserver(clNetworkAPI.chordNode))        
        self.assertTrue(status, 'Could not build client node')
                
        # Build the client node
        (status, clClientAPI2, clNetworkAPI2) = yield TestUtils.startNodeUsingAPI(self.myIP, port+3, bootstrapNodeLocation2, 'theEnclave', False, False)
        self.allMetricsObservers.append(MetricsMessageObserver(clNetworkAPI2.chordNode))
        self.assertTrue(status, 'Could not build client node')


        # Wait for flooding to reach all the nodes
        waiter = ConnectivityCounter()
        yield waiter.waitForConnectivity(3, clNetworkAPI.chordNode) # Does not count clNode itself.
        
                
        # Now shut everything down
        yield clNetworkAPI.disconnect()
        yield clNetworkAPI2.disconnect()
        yield bsNetworkAPI.disconnect()
        yield bsNetworkAPI2.disconnect()
        
        if Config.USE_CONNECTION_CACHE:
            yield TestUtils.waitForConnectionCache()
        else:        
            yield TestUtils.wait(5)
            
        defer.returnValue(True)
开发者ID:danfleck,项目名称:Class-Chord,代码行数:55,代码来源:BootstrapTests.py

示例5: testStartAutoDiscoverySameNodeError

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import waitForConnectionCache [as 别名]
 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()        
开发者ID:danfleck,项目名称:Class-Chord,代码行数:54,代码来源:AutoDiscoveryTest.py

示例6: testNodeAuth

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import waitForConnectionCache [as 别名]
 def testNodeAuth(self):
     log.msg("---> Starting BootstrapNode")
     yield self.startBootStrapNode()
     
     log.msg("---> Creating Good Client")
     yield self.startClientNode(self.myIP, 12350, self.bootstrapNodeLocation, self.enclaveStr)
     
     log.msg("---> Creating Bad Client")
     yield self.startBadClientNode(self.myIP, 12351, self.bootstrapNodeLocation, self.enclaveStr)
                 
     # Shut it all down
     for (clientAPI, networkAPI) in self.allNodes:
         yield networkAPI.disconnect()
     
     yield self.bsNetwork.disconnect()
     
     if Config.USE_CONNECTION_CACHE:
         yield TestUtils.waitForConnectionCache()
     else:
         yield TestUtils.wait(2)
     
     defer.returnValue(True)
开发者ID:danfleck,项目名称:Class-Chord,代码行数:24,代码来源:NodeAuthTest.py

示例7: testAutoDiscoveryRebootstrap

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import waitForConnectionCache [as 别名]
    def testAutoDiscoveryRebootstrap(self):
        '''Try to start a bootstrap node and client with autodiscovery on.
           Then start another bootstrap node.
           Then kill first bootstrap node and have client try to re-bootstrap to
           new bootstrap node.            
        '''
        
        log.msg("---------------------- BEGIN testAutoDiscoveryRebootstrap -------------- ")
        self.allNodes = []
        self.allMetricsObservers = []
        self.allTestObservers = []

        # Create Bootstrap
        port = 12345
        enclaveStr = 'testclave'
        bsNodeLocation = NodeLocation(None, self.myIP, port)
        bootstrapNodeList = [ bsNodeLocation ]

        log.msg("Starting bootstrap... \n\n")
        (self.bsClient, self.bsNetwork, d) = self.startBootstrapNode(enclaveStr, self.myIP, port, "authenticate:succeed", bootstrapNodeList)
        yield d
        
        # Now try and join with autodiscovery
        yield TestUtils.wait(1)
        log.msg("Starting client... \n\n")
        yield self.startClientNodeAutoDiscovery(None, self.myIP, port+1, enclaveStr, bootstrapNodeList)

        # Now start a second bootstrap node
        #NOT DONE YET
        log.msg("Shutting down client... \n\n")
        
        # Shut it all down
        for (clientAPI, networkAPI) in self.allNodes:
            yield networkAPI.disconnect()
            
        yield self.bsNetwork.disconnect()  
                        
        # Try and wait for connection cache to finish disconnects (just in case).
        yield TestUtils.waitForConnectionCache()        
开发者ID:danfleck,项目名称:Class-Chord,代码行数:41,代码来源:AutoDiscoveryTest.py

示例8: testStartAutoDiscoveryMultipleClients

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import waitForConnectionCache [as 别名]
    def testStartAutoDiscoveryMultipleClients(self):
        '''Try to start a bootstrap node and the many many clients all at once with autodiscovery on.        '''
        
        log.msg("---------------------- BEGIN testStartAutoDiscoveryMultipleClients -------------- ")
        self.allNodes = []
        self.allMetricsObservers = []
        self.allTestObservers = []
        
        numNodes = 15

        # Create Bootstrap
        port = 12345
        enclaveStr = 'testclave'
        bootstrapNodeList = [ NodeLocation(None, self.myIP, port) ]
        (self.bsClient, self.bsNetwork, d) = self.startBootstrapNode(enclaveStr, self.myIP, port, "authenticate:succeed", bootstrapNodeList)
        yield d
        
        # Now try and join a bunch of nodes with autodiscovery
        allDefs = [] # A list of deferreds
        for counter in range(numNodes):
            allDefs.append(self.startClientNodeAutoDiscovery(None, self.myIP, port+1+counter, enclaveStr, bootstrapNodeList))
            
        dl = defer.DeferredList(allDefs)
        yield dl # Wait for all deferred joins to complete
        
        # Shut it all down
        for (clientAPI, networkAPI) in self.allNodes:
            yield networkAPI.disconnect()
            
        yield self.bsNetwork.disconnect()    

        if Config.USE_CONNECTION_CACHE:
            # Try and wait for connection cache to finish disconnects (just in case).
            yield TestUtils.waitForConnectionCache()        
        else:
            # Wait a few seconds for network timeouts
            yield TestUtils.wait(5)
开发者ID:danfleck,项目名称:Class-Chord,代码行数:39,代码来源:AutoDiscoveryTest.py

示例9: testReBootstrap

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import waitForConnectionCache [as 别名]
    def testReBootstrap(self):
        '''Create a BS node, then a client node, then kill the BS Node, wait, restart a BS node and 
           check for re-Bootstrap
        '''
        global startingPort
        
        # Create Bootstrap
        port = 12345
        bootstrapNodeLocation = NodeLocation(None, self.myIP, port)
        self.allNodes = []
        self.allMetricsObservers = []
        self.allTestObservers = []

        # Build the BS node
        log.msg("building BS node...")
        (status, bsClientAPI, bsNetworkAPI) = yield TestUtils.startNodeUsingAPI(self.myIP, port, None, 'theEnclave', False, True)
        self.assertTrue(status, 'Could not build bootstrap node')
                
        # Build the client node
        log.msg("building client node...")
        (status, clClientAPI, clNetworkAPI) = yield TestUtils.startNodeUsingAPI(self.myIP, port+1, bootstrapNodeLocation, 'theEnclave', False, False)
        self.assertTrue(status, 'Could not build client node')
        
        # Check that the client is connected to something
        connected = yield clNetworkAPI.isConnected()
        self.assertTrue(connected, "Client did not connect to the bootstrap node in testReBootstrap!")
        
        # Now kill the BS node
        yield bsNetworkAPI.disconnect()
        bsNetworkAPI = None
        bsClientAPI = None
        
        # Gotta wait for disconnect to really finish
        yield TestUtils.waitForConnectionCache()
        
        # Check that the client is connected to something
        connected = yield clNetworkAPI.isConnected()
        self.assertTrue(not connected, "Client remains connected to the bootstrap node in testReBootstrap after killing BS node!")
        
        # Now startup another bootstrap node
        log.msg("building BS node...")
        (status, bsClientAPI, bsNetworkAPI) = yield TestUtils.startNodeUsingAPI(self.myIP, port, None, 'theEnclave', False, True)
        self.assertTrue(status, 'Could not build second bootstrap node')
         
        # Wait for it to connect or fail -- basically waiting for the
        # maintenance call to run correctly.
        for _ in range(10):
            # Check that the client is connected to something
            connected = yield clNetworkAPI.isConnected()
            if connected:
                break
            yield TestUtils.wait(1)
   
        self.assertTrue(connected, "Client could not re-bootstrap!")

        
        # Now shut everything down
        
        log.msg("\n\ntestReBootstrap: Shutting down now...\n\n")
        yield clNetworkAPI.disconnect()
        yield bsNetworkAPI.disconnect()

        if Config.USE_CONNECTION_CACHE:
            yield TestUtils.waitForConnectionCache()
        else:        
            yield TestUtils.wait(5)

        defer.returnValue(True)
开发者ID:danfleck,项目名称:Class-Chord,代码行数:70,代码来源:BootstrapTests.py


注:本文中的TestUtils.waitForConnectionCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。