Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INDY-1001] Move plenum/test/instances tests to sdk #563

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
checkNodeRemotes
from plenum.test.test_stack import CONNECTED, JOINED_NOT_ALLOWED
from plenum.test import waits


whitelist = ['discarding message']
from plenum.test.pool_transactions.conftest import looper

logger = getlogger()

Expand Down Expand Up @@ -59,7 +57,7 @@ def addNodeBackAndCheck(nodeIdx: int, expectedStatus: Status):
addNodeBack(nodeSet, looper, nodeNames[nodeIdx])

timeout = waits.expectedNodeStartUpTimeout() + \
waits.expectedPoolInterconnectionTime(len(nodeSet))
waits.expectedPoolInterconnectionTime(len(nodeSet))
# TODO: Probably it's better to modify waits.* functions
timeout *= 1.5
looper.run(eventually(checkNodeStatusRemotesAndF,
Expand Down
15 changes: 9 additions & 6 deletions plenum/test/instances/test_msgs_from_slow_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,30 @@
from plenum.test.delayers import delayerMsgTuple
from plenum.test.test_node import TestNode
from plenum.test import waits

from plenum.test.pool_transactions.conftest import looper
from plenum.test.node_request.conftest import committed1, \
prepared1, preprepared1, propagated1, reqAcked1, \
sent1, noRetryReq, faultyNodes

nodeCount = 4

faultyNodes = 1


@pytest.fixture()
def configNodeSet(nodeSet):
A, B, C, D = nodeSet.nodes.values()
def configNodeSet(txnPoolNodeSet):
A, B, C, D = txnPoolNodeSet
# Nodes C and D delay Commit request from node A for protocol instance 0
for n in [C, D]:
n.nodeIbStasher.delay(delayerMsgTuple(30,
Commit,
senderFilter=A.name,
instFilter=0))
return nodeSet
return txnPoolNodeSet


def testMsgFromInstanceDelay(configNodeSet, looper, prepared1):
A, B, C, D = configNodeSet.nodes.values()
A, B, C, D = configNodeSet

def getCommits(node: TestNode, instId: int):
replica = node.replicas[instId] # type: Replica
Expand All @@ -41,6 +44,6 @@ def checkPresence():
assert len(commReqs) > 0
assert Replica.generateName(A.name, 1) in commReqs[0][0]

numOfNodes = len(configNodeSet.nodes)
numOfNodes = len(configNodeSet)
timeout = waits.expectedClientRequestPropagationTime(numOfNodes)
looper.run(eventually(checkPresence, retryWait=.5, timeout=timeout))
18 changes: 10 additions & 8 deletions plenum/test/instances/test_multiple_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
sendDuplicate3PhaseMsg
from plenum.test.test_node import getNonPrimaryReplicas, getPrimaryReplica
from plenum.test import waits

whitelist = [Suspicions.DUPLICATE_CM_SENT.reason,
'cannot process incoming COMMIT']
from plenum.test.pool_transactions.conftest import looper
from plenum.test.node_request.conftest import committed1, \
prepared1, preprepared1, propagated1, reqAcked1, \
sent1, noRetryReq, faultyNodes


@pytest.fixture("module")
def setup(nodeSet, up):
primaryRep, nonPrimaryReps = getPrimaryReplica(nodeSet, 0), \
getNonPrimaryReplicas(nodeSet, 0)
def setup(txnPoolNodeSet):
primaryRep, nonPrimaryReps = getPrimaryReplica(txnPoolNodeSet, 0), \
getNonPrimaryReplicas(txnPoolNodeSet, 0)

faultyRep = nonPrimaryReps[0]
makeNodeFaulty(faultyRep.node, partial(sendDuplicate3PhaseMsg,
Expand All @@ -32,13 +33,14 @@ def setup(nodeSet, up):
# want to check for a particular suspicion

whitelistNode(faultyRep.node.name,
[node for node in nodeSet if node != faultyRep.node],
[node for node in txnPoolNodeSet if node != faultyRep.node],
Suspicions.DUPLICATE_CM_SENT.code)

# If the request is ordered then COMMIT will be rejected much earlier
for r in [primaryRep, *nonPrimaryReps]:
def do_nothing(self, commit):
pass

r.doOrder = types.MethodType(do_nothing, r)

return adict(primaryRep=primaryRep, nonPrimaryReps=nonPrimaryReps,
Expand All @@ -53,7 +55,7 @@ def testMultipleCommit(setup, looper, sent1):
should count only one COMMIT from that sender
"""
primaryRep, nonPrimaryReps, faultyRep = setup.primaryRep, \
setup.nonPrimaryReps, setup.faultyRep
setup.nonPrimaryReps, setup.faultyRep

def chkSusp():
for r in (primaryRep, *nonPrimaryReps):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from plenum.test.spy_helpers import getAllArgs
from plenum.test import waits


nodeCount = 7


Expand Down
19 changes: 7 additions & 12 deletions plenum/test/instances/test_multiple_pre_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,16 @@
sendDuplicate3PhaseMsg
from plenum.test.test_node import getNonPrimaryReplicas, getPrimaryReplica
from plenum.test import waits


whitelist = [Suspicions.DUPLICATE_PPR_SENT.reason,
'cannot process incoming PRE-PREPARE',
Suspicions.UNKNOWN_PR_SENT.reason,
'Invalid prepare message received',
'cannot process incoming PREPARE',
Suspicions.UNKNOWN_CM_SENT.reason,
'cannot process incoming COMMIT']
from plenum.test.pool_transactions.conftest import looper
from plenum.test.node_request.conftest import committed1, \
prepared1, preprepared1, propagated1, reqAcked1, \
sent1, noRetryReq, faultyNodes


@pytest.fixture("module")
def setup(nodeSet, up):
primaryRep, nonPrimaryReps = getPrimaryReplica(nodeSet, 0), \
getNonPrimaryReplicas(nodeSet, 0)
def setup(txnPoolNodeSet):
primaryRep, nonPrimaryReps = getPrimaryReplica(txnPoolNodeSet, 0), \
getNonPrimaryReplicas(txnPoolNodeSet, 0)

# The primary replica would send 3 duplicate PRE-PREPARE requests to
# non primary replicas
Expand Down
18 changes: 9 additions & 9 deletions plenum/test/instances/test_multiple_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
sendDuplicate3PhaseMsg
from plenum.test.test_node import getNonPrimaryReplicas, getPrimaryReplica
from plenum.test import waits

whitelist = [Suspicions.DUPLICATE_PR_SENT.reason,
'Invalid prepare message received',
'cannot process incoming PREPARE']
from plenum.test.pool_transactions.conftest import looper
from plenum.test.node_request.conftest import committed1, \
prepared1, preprepared1, propagated1, reqAcked1, \
sent1, noRetryReq, faultyNodes


@pytest.fixture("module")
def setup(nodeSet, up):
primaryRep, nonPrimaryReps = getPrimaryReplica(nodeSet, 0), \
getNonPrimaryReplicas(nodeSet, 0)
def setup(txnPoolNodeSet):
primaryRep, nonPrimaryReps = getPrimaryReplica(txnPoolNodeSet, 0), \
getNonPrimaryReplicas(txnPoolNodeSet, 0)

# A non primary replica sends duplicate PREPARE requests to all other
# replicas
Expand All @@ -34,7 +34,7 @@ def setup(nodeSet, up):
# want to check for a particular suspicion

whitelistNode(faultyRep.node.name,
[node for node in nodeSet if node != faultyRep.node],
[node for node in txnPoolNodeSet if node != faultyRep.node],
Suspicions.DUPLICATE_PR_SENT.code)

return adict(primaryRep=primaryRep, nonPrimaryReps=nonPrimaryReps,
Expand All @@ -50,7 +50,7 @@ def testMultiplePrepare(setup, looper, sent1):
"""

primaryRep, nonPrimaryReps, faultyRep = setup.primaryRep, \
setup.nonPrimaryReps, setup.faultyRep
setup.nonPrimaryReps, setup.faultyRep

def chkSusp():
for r in (primaryRep, *nonPrimaryReps):
Expand Down
15 changes: 7 additions & 8 deletions plenum/test/instances/test_pre_prepare_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from stp_core.loop.eventually import eventually
from plenum.common.messages.node_messages import PrePrepare
from plenum.common.util import adict
from stp_core.common.util import adict
from plenum.server.suspicion_codes import Suspicions
from plenum.test.helper import getNodeSuspicions
Expand All @@ -13,16 +12,16 @@
send3PhaseMsgWithIncorrectDigest
from plenum.test.test_node import getNonPrimaryReplicas, getPrimaryReplica
from plenum.test import waits


whitelist = [Suspicions.PPR_DIGEST_WRONG.reason,
'cannot process incoming PRE-PREPARE']
from plenum.test.pool_transactions.conftest import looper
from plenum.test.node_request.conftest import committed1, \
prepared1, preprepared1, propagated1, reqAcked1, \
sent1, noRetryReq, faultyNodes


@pytest.fixture("module")
def setup(nodeSet, up):
primaryRep, nonPrimaryReps = getPrimaryReplica(nodeSet, 0), \
getNonPrimaryReplicas(nodeSet, 0)
def setup(txnPoolNodeSet):
primaryRep, nonPrimaryReps = getPrimaryReplica(txnPoolNodeSet, 0), \
getNonPrimaryReplicas(txnPoolNodeSet, 0)

# The primary replica would send PRE-PREPARE messages with incorrect digest
makeNodeFaulty(primaryRep.node, partial(send3PhaseMsgWithIncorrectDigest,
Expand Down
21 changes: 9 additions & 12 deletions plenum/test/instances/test_prepare_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@
send3PhaseMsgWithIncorrectDigest
from plenum.test.test_node import getNonPrimaryReplicas, getPrimaryReplica
from plenum.test import waits


whitelist = [Suspicions.PR_DIGEST_WRONG.reason,
'Invalid prepare message received',
'cannot process incoming PREPARE',
Suspicions.CM_DIGEST_WRONG.reason,
'cannot process incoming COMMIT']
from plenum.test.pool_transactions.conftest import looper
from plenum.test.node_request.conftest import committed1, \
prepared1, preprepared1, propagated1, reqAcked1, \
sent1, noRetryReq, faultyNodes


@pytest.fixture("module")
def setup(nodeSet, up):
primaryRep, nonPrimaryReps = getPrimaryReplica(nodeSet, 0), \
getNonPrimaryReplicas(nodeSet, 0)
def setup(txnPoolNodeSet):
primaryRep, nonPrimaryReps = getPrimaryReplica(txnPoolNodeSet, 0), \
getNonPrimaryReplicas(txnPoolNodeSet, 0)

# A non primary replica sends PREPARE messages with incorrect digest

Expand All @@ -44,8 +41,8 @@ def testPrepareDigest(setup, looper, sent1):
"""

primaryRep, nonPrimaryReps, faultyRep = setup.primaryRep, \
setup.nonPrimaryReps, \
setup.faultyRep
setup.nonPrimaryReps, \
setup.faultyRep

def chkSusp():
for r in (primaryRep, *nonPrimaryReps):
Expand Down