Пример #1
0
def testCorrectNumOfProtocolInstances(pool):
    fValue = getMaxFailures(len(pool.nodeSet))
    for node in pool.nodeSet:
        # num of protocol instances running on a node must be f + 1
        assert len(getProtocolInstanceNums(node)) == fValue + 1
        # There should be one running and up master Instance
        assert node.masterInst is not None
        # There should be exactly f non master instances
        assert len(node.nonMasterInsts) == fValue
Пример #2
0
def testCorrectNumOfReplicas(pool):
    fValue = getMaxFailures(len(pool.nodeSet))
    for node in pool.nodeSet:
        # num of replicas running on a single node must be f + 1
        assert len(node.replicas) == fValue + 1
        # num of primary nodes is <= 1
        numberOfPrimary = len([r for r in node.replicas if r.isPrimary])
        assert numberOfPrimary <= 1
        for instId in getProtocolInstanceNums(node):
            # num of replicas for a instance on a node must be 1
            assert len([node.replicas[instId]]) == 1 and \
                   node.replicas[instId].instId == instId
            # num of primary on every protocol instance is 1
            numberOfPrimary = len([node for node in pool.nodeSet
                                   if node.replicas[instId].isPrimary])
            assert numberOfPrimary == 1