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


Python TestUtils.didNotReceive方法代码示例

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


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

示例1: sendP2PMsg

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import didNotReceive [as 别名]
 def sendP2PMsg(self, src, dst, allNodeObservers):
     '''Send a P2P message from src to dst and verify it got there.
        Also check that no other nodes got it.
     '''
     
     goodCounter = 0
     
     for _ in range(numMessages):
         messageNum = random.randint(1,9999999)
         
         # Send the message
         status = yield TestUtils.sendP2P(src, dst, messageNum )
         self.assertTrue(status,"sendP2PMsg failed! [%s] [%s] to [%s]" % (status, src, dst))
 
         #yield TestUtils.wait(1) # Wait for the messages to send
         
         # Check receipt (both that one did and others did not)
         status = TestUtils.didNodeReceive(allNodeObservers,dst, messageNum)
         self.assertTrue(status,"Expected node did not receive the message!")
 
         status = TestUtils.didNotReceive(allNodeObservers, 'ALL', messageNum, len(allNodeObservers) - 1)
         self.assertTrue(status,"Extra nodes received message!") 
         
         goodCounter += 1
     
     self.assertTrue(goodCounter == numMessages, "sendP2P message did not finish all messages [%d][%d]" % (goodCounter, numMessages))
     defer.returnValue(True)       
开发者ID:danfleck,项目名称:Class-Chord,代码行数:29,代码来源:EnclaveP2PTest.py

示例2: testEnclaveBridge

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


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