Example #1
0
def testConsecutiveAddSameNodeWithoutAnyChange(be, do, newStewardCli,
                                               newNodeVals, newNodeAdded):
    be(newStewardCli)
    doSendNodeCmd(do,
                  newNodeVals,
                  expMsgs=['node already has the same data as requested'])
    exitFromCli(do)
Example #2
0
def testConsecutiveAddSameNodeWithOnlyAliasChange(be, do,
                                                  newStewardCli, newNodeVals,
                                                  newNodeAdded):
    be(newStewardCli)
    newNodeVals['newNodeData'][ALIAS] = randomString(6)
    doSendNodeCmd(do, newNodeVals,
              expMsgs=['existing data has conflicts with request data'])
    exitFromCli(do)
Example #3
0
def testConsecutiveAddSameNodeWithOnlyAliasChange(be, do, newStewardCli,
                                                  newNodeVals, newNodeAdded):
    be(newStewardCli)
    newNodeVals['newNodeData'][ALIAS] = randomString(6)
    doSendNodeCmd(do,
                  newNodeVals,
                  expMsgs=['existing data has conflicts with request data'])
    exitFromCli(do)
Example #4
0
def testConsecutiveAddSameNodeWithNonAliasChange(be, do, newStewardCli,
                                                 newNodeVals, newNodeAdded):
    be(newStewardCli)
    nodeIp, nodePort = genHa()
    clientIp, clientPort = genHa()
    newNodeVals['newNodeData'][NODE_IP] = nodeIp
    newNodeVals['newNodeData'][NODE_PORT] = nodePort
    newNodeVals['newNodeData'][CLIENT_IP] = nodeIp
    newNodeVals['newNodeData'][CLIENT_PORT] = clientPort
    doSendNodeCmd(do, newNodeVals)
    exitFromCli(do)
Example #5
0
def testConsecutiveAddSameNodeWithNonAliasChange(be, do, newStewardCli,
                                                 newNodeVals, newNodeAdded):
    be(newStewardCli)
    nodeIp, nodePort = genHa()
    clientIp, clientPort = genHa()
    newNodeVals['newNodeData'][NODE_IP] = nodeIp
    newNodeVals['newNodeData'][NODE_PORT] = nodePort
    newNodeVals['newNodeData'][CLIENT_IP] = nodeIp
    newNodeVals['newNodeData'][CLIENT_PORT] = clientPort
    doSendNodeCmd(do, newNodeVals)
    exitFromCli(do)
Example #6
0
def testConsecutiveAddSameNodeWithNodeAndClientPortSame(be, do, newStewardCli,
                                                        newNodeVals,
                                                        newNodeAdded):
    be(newStewardCli)
    nodeIp, nodePort = genHa()
    newNodeVals['newNodeData'][NODE_IP] = nodeIp
    newNodeVals['newNodeData'][NODE_PORT] = nodePort
    newNodeVals['newNodeData'][CLIENT_IP] = nodeIp
    newNodeVals['newNodeData'][CLIENT_PORT] = nodePort
    doSendNodeCmd(do, newNodeVals,
              expMsgs=["node and client ha cannot be same"])
    exitFromCli(do)
Example #7
0
def testConsecutiveAddSameNodeWithNodeAndClientPortSame(
        be, do, newStewardCli, newNodeVals, newNodeAdded):
    be(newStewardCli)
    nodeIp, nodePort = genHa()
    newNodeVals['newNodeData'][NODE_IP] = nodeIp
    newNodeVals['newNodeData'][NODE_PORT] = nodePort
    newNodeVals['newNodeData'][CLIENT_IP] = nodeIp
    newNodeVals['newNodeData'][CLIENT_PORT] = nodePort
    doSendNodeCmd(do,
                  newNodeVals,
                  expMsgs=["node and client ha can't be same"])
    exitFromCli(do)
Example #8
0
def testSuspendNode(be, do, trusteeCli, newNodeAdded):
    """
    Suspend a node and then cancel suspension. Suspend while suspended
    to test that there is no error
    """
    newNodeVals = newNodeAdded

    be(trusteeCli)

    newNodeVals['newNodeData'][SERVICES] = []
    doSendNodeCmd(do, newNodeVals)
    # Re-suspend node
    newNodeVals['newNodeData'][SERVICES] = []
    doSendNodeCmd(do,
                  newNodeVals,
                  expMsgs=['node already has the same data as requested'])

    # Cancel suspension
    newNodeVals['newNodeData'][SERVICES] = [VALIDATOR]
    doSendNodeCmd(do, newNodeVals)

    # Re-cancel suspension
    newNodeVals['newNodeData'][SERVICES] = [VALIDATOR]
    doSendNodeCmd(do,
                  nodeVals=newNodeVals,
                  expMsgs=['node already has the same data as requested'])
Example #9
0
def testSuspendNodeWhichWasNeverActive(be, do, trusteeCli, nymAddedOut,
                                       poolNodesStarted, trusteeMap):
    """
    Add a node without services field and check that the ledger does not
    contain the `services` field and check that it can be blacklisted and
    the ledger has `services` as empty list
    """
    newStewardSeed = '0000000000000000000KellySteward2'
    newStewardIdr = 'DqCx7RFEpSUMZbV2mH89XPH6JT3jMvDNU55NTnBHsQCs'
    be(trusteeCli)
    do('send NYM dest={{remote}} role={role}'.format(role=Roles.STEWARD.name),
       within=5,
       expect=nymAddedOut,
       mapper={'remote': newStewardIdr})
    do('new key with seed {}'.format(newStewardSeed))
    nport, cport = (_[1] for _ in genHa(2))
    nodeId = '6G9QhQa3HWjRKeRmEvEkLbWWf2t7cw6KLtafzi494G4G'
    newNodeVals = {
        'newNodeIdr': nodeId,
        'newNodeData': {
            'client_port': cport,
            'client_ip': '127.0.0.1',
            'alias': 'Node6',
            'node_ip': '127.0.0.1',
            'node_port': nport
        }
    }
    doSendNodeCmd(do, newNodeVals)

    for node in poolNodesStarted.nodes.values():
        txn = list(node.poolLedger.getAllTxn().values())[-1]
        assert txn[TARGET_NYM] == nodeId
        assert SERVICES not in txn[DATA]

    do('new key with seed {}'.format(trusteeMap['trusteeSeed']))
    newNodeVals['newNodeData'][SERVICES] = []
    doSendNodeCmd(do, newNodeVals)

    for node in poolNodesStarted.nodes.values():
        txn = list(node.poolLedger.getAllTxn().values())[-1]
        assert txn[TARGET_NYM] == nodeId
        assert SERVICES in txn[DATA] and txn[DATA][SERVICES] == []
def testSuspendNodeWhichWasNeverActive(be, do, trusteeCli, nymAddedOut,
                                       poolNodesStarted, trusteeMap):
    """
    Add a node without services field and check that the ledger does not
    contain the `services` field and check that it can be blacklisted and
    the ledger has `services` as empty list
    """
    newStewardSeed = '0000000000000000000KellySteward2'
    newStewardIdr = 'DqCx7RFEpSUMZbV2mH89XPH6JT3jMvDNU55NTnBHsQCs'
    be(trusteeCli)
    do('send NYM dest={{remote}} role={role}'.format(
        role=Roles.STEWARD.name),
       within=5,
       expect=nymAddedOut, mapper={'remote': newStewardIdr})
    do('new key with seed {}'.format(newStewardSeed))
    nport, cport = (_[1] for _ in genHa(2))
    nodeId = '6G9QhQa3HWjRKeRmEvEkLbWWf2t7cw6KLtafzi494G4G'
    newNodeVals = {
        'newNodeIdr': nodeId,
        'newNodeData': {'client_port': cport,
                        'client_ip': '127.0.0.1',
                        'alias': 'Node6',
                        'node_ip': '127.0.0.1',
                        'node_port': nport
                        }
    }
    doSendNodeCmd(do, newNodeVals)

    for node in poolNodesStarted.nodes.values():
        txn = [t for _, t in node.poolLedger.getAllTxn()][-1]
        assert txn[TARGET_NYM] == nodeId
        assert SERVICES not in txn[DATA]

    do('new key with seed {}'.format(trusteeMap['trusteeSeed']))
    newNodeVals['newNodeData'][SERVICES] = []
    doSendNodeCmd(do, newNodeVals)

    for node in poolNodesStarted.nodes.values():
        txn = [t for _, t in node.poolLedger.getAllTxn()][-1]
        assert txn[TARGET_NYM] == nodeId
        assert SERVICES in txn[DATA] and txn[DATA][SERVICES] == []
Example #11
0
def newNodeAdded(be, do, poolNodesStarted, philCli, newStewardCli,
                 connectedToTest, newNodeVals):
    be(philCli)

    if not philCli._isConnectedToAnyEnv():
        do('connect test', within=3,
           expect=connectedToTest)

    be(newStewardCli)
    doSendNodeCmd(do, newNodeVals)
    newNodeData = newNodeVals["newNodeData"]

    def checkClientConnected(client):
        name = newNodeData[ALIAS] + CLIENT_STACK_SUFFIX
        assert name in client.nodeReg

    def checkNodeConnected(nodes):
        for node in nodes:
            name = newNodeData[ALIAS]
            assert name in node.nodeReg

    timeout = waits.expectedClientToPoolConnectionTimeout(
        util.getMaxFailures(len(philCli.nodeReg))
    )

    newStewardCli.looper.run(eventually(checkClientConnected,
                                        newStewardCli.activeClient,
                                        timeout=timeout))

    philCli.looper.run(eventually(checkClientConnected,
                                  philCli.activeClient,
                                  timeout=timeout))

    poolNodesStarted.looper.run(eventually(checkNodeConnected,
                                           list(
                                               poolNodesStarted.nodes.values()),
                                           timeout=timeout))
    return newNodeVals
Example #12
0
def newNodeAdded(be, do, poolNodesStarted, philCli, newStewardCli,
                 connectedToTest, newNodeVals):
    be(philCli)

    if not philCli._isConnectedToAnyEnv():
        do('connect test', within=3,
           expect=connectedToTest)

    be(newStewardCli)
    doSendNodeCmd(do, newNodeVals)
    newNodeData = newNodeVals["newNodeData"]

    def checkClientConnected(client):
        name = newNodeData[ALIAS] + CLIENT_STACK_SUFFIX
        assert name in client.nodeReg

    def checkNodeConnected(nodes):
        for node in nodes:
            name = newNodeData[ALIAS]
            assert name in node.nodeReg

    timeout = waits.expectedClientToPoolConnectionTimeout(
        util.getMaxFailures(len(philCli.nodeReg))
    )

    newStewardCli.looper.run(eventually(checkClientConnected,
                                        newStewardCli.activeClient,
                                        timeout=timeout))

    philCli.looper.run(eventually(checkClientConnected,
                                  philCli.activeClient,
                                  timeout=timeout))

    poolNodesStarted.looper.run(eventually(checkNodeConnected,
                                           list(
                                               poolNodesStarted.nodes.values()),
                                           timeout=timeout))
    return newNodeVals
def testSuspendNode(be, do, trusteeCli, newNodeAdded):
    """
    Suspend a node and then cancel suspension. Suspend while suspended
    to test that there is no error
    """
    newNodeVals = newNodeAdded

    be(trusteeCli)

    newNodeVals['newNodeData'][SERVICES] = []
    doSendNodeCmd(do, newNodeVals)
    # Re-suspend node
    newNodeVals['newNodeData'][SERVICES] = []
    doSendNodeCmd(do, newNodeVals,
                  expMsgs=['node already has the same data as requested'])

    # Cancel suspension
    newNodeVals['newNodeData'][SERVICES] = [VALIDATOR]
    doSendNodeCmd(do, newNodeVals)

    # Re-cancel suspension
    newNodeVals['newNodeData'][SERVICES] = [VALIDATOR]
    doSendNodeCmd(do, nodeVals=newNodeVals,
              expMsgs=['node already has the same data as requested'])
Example #14
0
def testConsecutiveAddSameNodeWithoutAnyChange(be, do, newStewardCli,
                                               newNodeVals, newNodeAdded):
    be(newStewardCli)
    doSendNodeCmd(do, newNodeVals,
              expMsgs=['node already has the same data as requested'])
    exitFromCli(do)