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


Python TestUtils.sendFlood方法代码示例

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


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

示例1: getAggResponse

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import sendFlood [as 别名]
    def getAggResponse(self):
        '''Send a query and get an agg response from all the nodes.'''

        bsNode = self.bsNetwork.chordNode
        
        
        for aggNumber in range(1, numNodes + 5):
            # Reset the message counter
            obs = self.getObserver(bsNode, self.allTestObservers)
            obs.resetMessageCount()
                                           
            # Send the query asking for a response        
            messageNum = aggNumber # Just to keep it incrementing
            yield TestUtils.sendFlood(bsNode,messageNum,'localhost', data="SEND_AGG_RESPONSE:%d" % aggNumber)
            
            
            # Now check how many messages the bootstrap node got in return
            for _ in range(10): # 10 seconds
                recvCount = obs.getMessageCount()
    
                if recvCount >= numNodes+1:
                    break
                else:
                    yield TestUtils.wait(1)
            
            self.failUnless(recvCount == numNodes+1, "getAggResponse didn't get the correct number of messages back.Expected[%d] Got[%d]" % (numNodes+1, recvCount))
        
        defer.returnValue(True)
开发者ID:danfleck,项目名称:Class-Chord,代码行数:30,代码来源:APITest.py

示例2: testEnclaveBridge

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import sendFlood [as 别名]
    def testEnclaveBridge(self):
        '''Create a node that can bridge between the enclaves
        
           Send a flooding message from it to 1 enclave and verify only nodes in that one got it
           
        '''
        authenticationPayload = "This is a test"
        
  
        # Build the bridge node
        (status, bridgeNode, observer) = yield TestUtils.startupClientNode(self.myIP, 12500, allEnclaves[0], self.bsNode1.nodeLocation)
        self.failUnless(status, 'testEnclave bridge could not join first bootstrap [%s]' % status)
        
        # Join the other enclave also.
        enableAutoDiscovery = True
        bootstrapNodeList = [ self.bsNode2.nodeLocation ]
        status = yield bridgeNode.joinEnclave(bootstrapNodeList, enableAutoDiscovery,  authenticationPayload, False, None)
        self.failUnless(status, 'testEnclave bridge could not join second bootstrap [%s]' % status)

        self.bridgeNode = bridgeNode # Store a reference
        
        
        # Send a flooding message to one enclave and verify only one got it.
        messageNum = random.randint(1,9999999)
        status = yield TestUtils.sendFlood(bridgeNode,messageNum, allEnclaves[0] )
        self.assertTrue(status,"sendFlood failed!")

        yield TestUtils.wait(3) # Wait for the messages to send
        
        # Check message counts
        status = TestUtils.didReceive(self.allNodeObservers, allEnclaves[0], messageNum, numNodes)
        self.assertTrue(status,"Nodes in enclave %s didn't all recv message")

        status = TestUtils.didNotReceive(self.allNodeObservers, allEnclaves[1], messageNum, numNodes)
        self.assertTrue(status,"Some Nodes in enclave %s did recv message")
        
                
开发者ID:danfleck,项目名称:Class-Chord,代码行数:37,代码来源:EnclaveBridgeTest.py

示例3: testEnclaveFlooding

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import sendFlood [as 别名]
    def testEnclaveFlooding(self):
        """Build 2 enclaves and test flooding to each and all."""
        global startingPort

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

        # Start a bootstrap node
        (status, bsNode, observer) = yield TestUtils.startupBootstrapNode(self.myIP, port, allEnclaves[0])
        self.assertTrue(status, "Could not build bootstrap node")
        allBootstrapObservers.append(observer)

        self.bsNode = bsNode

        # Join another enclave
        bootstrapNodeList = None
        enableAutoDiscovery = True
        status = yield self.bsNode.joinEnclave(
            bootstrapNodeList, enableAutoDiscovery, None, isBootstrapNode=True, enclaveStr=allEnclaves[1]
        )

        # Add X nodes to each enclave
        for enclave in allEnclaves:
            for _ in range(numNodes):
                # Add a node to the enclave
                (status, node, observer) = yield TestUtils.startupClientNode(
                    self.myIP, startingPort, enclave, bootstrapNodeLocation
                )
                self.assertTrue(status, "Could not startupClientNode")
                startingPort += 1
                allNodes.append(node)
                allNodeObservers.append(observer)

        # Wait for flooding to reach all the nodes
        waiter = ConnectivityCounter()
        numberOfNodes = len(allEnclaves) * numNodes
        yield waiter.waitForConnectivity(numberOfNodes, bsNode)  # Does not count bsNode itself.

        # Flood from bootstrap to all
        messageNum = random.randint(1, 9999999)
        status = yield TestUtils.sendFlood(bsNode, messageNum, "ALL")
        self.assertTrue(status, "sendFlood failed!")

        yield TestUtils.wait(3)  # Wait for the messages to send

        # Check message counts
        status = TestUtils.didReceive(allNodeObservers, "ALL", messageNum, numberOfNodes)
        self.assertTrue(status, "All nodes did not receive message")

        # Flood from bootstrap to single enclave
        messageNum = random.randint(1, 9999999)
        status = yield TestUtils.sendFlood(bsNode, messageNum, allEnclaves[0])
        self.assertTrue(status, "sendFlood failed!")

        yield TestUtils.wait(3)  # Wait for the messages to send

        # Check message counts
        status = TestUtils.didReceive(allNodeObservers, allEnclaves[0], messageNum, numNodes)
        self.assertTrue(status, "Nodes in enclave %s didn't all recv message")

        status = TestUtils.didNotReceive(allNodeObservers, allEnclaves[1], messageNum, numNodes)
        self.assertTrue(status, "Some Nodes in enclave %s did recv message")

        log.msg("\n\n\n TEST ARE ALL DONE \n\n\n")
        yield TestUtils.wait(60)

        # Stop everything
        for node in self.allNodes:
            yield node.leave()
        yield self.bsNode.leave()

        # Wait for all network timeouts to finish
        yield TestUtils.wait(Config.CONNECTION_CACHE_DELAY + 3)
        # self.flushLoggedErrors()

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

示例4: sendFlood

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import sendFlood [as 别名]
 def sendFlood(self, _, chordNode,messageNum,enclave, data=""):
     return TestUtils.sendFlood(chordNode,messageNum,enclave, data)
开发者ID:danfleck,项目名称:Class-Chord,代码行数:4,代码来源:AggregationMessageTest.py


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