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


Python TestUtils.startNodeUsingAPI方法代码示例

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


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

示例1: testDisconnectedBootstraps

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import startNodeUsingAPI [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

示例2: buildNetwork

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import startNodeUsingAPI [as 别名]
    def buildNetwork(self):
        global startingPort

        
        # Create Bootstrap
        port = 12345
        bootstrapNodeLocation = NodeLocation(None, self.myIP, port)
        self.allNodeObservers = []
        self.allNetworkAPIs = []
        self.allClientAPIs = []

        # Start a bootstrap node
        log.msg("building BS node...")
        (status, clientAPI, networkAPI) = yield TestUtils.startNodeUsingAPI(self.myIP, port, None, 'theEnclave', False, True)
        self.assertTrue(status, 'Could not build bootstrap node')
        
        node = networkAPI.chordNode # This is very highly coupled -- bad
        MetricsMessageObserver(node)
        self.observer = TestMessageObserver(node, networkAPI)
        self.bsNode = node

        
        log.msg("building client nodes...")
        
        # Add X nodes to each enclave
        for _ in range(numNodes):
            # Add a node to the enclave
            (status, clientAPI, networkAPI) = yield TestUtils.startNodeUsingAPI(self.myIP, startingPort, bootstrapNodeLocation, 'theEnclave', False, False)
            self.assertTrue(status, 'Could not startupClientNode')
            
            node = networkAPI.chordNode # This is very highly coupled -- bad
            MetricsMessageObserver(node)
            observer = TestMessageObserver(node, networkAPI)
            
            startingPort += 1
            self.allNetworkAPIs.append(networkAPI)
            self.allNodeObservers.append(observer)
            self.allClientAPIs.append(clientAPI)
                        
        # Wait for flooding to reach all the nodes
        waiter = ConnectivityCounter()
        yield waiter.waitForConnectivity(numNodes+1, self.bsNode) # Does count bsNode itself.

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

示例3: testReBootstrap

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import startNodeUsingAPI [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.startNodeUsingAPI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。