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 4 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
2 changes: 2 additions & 0 deletions plenum/test/instances/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from plenum.test.pool_transactions.conftest import looper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is a good practice to use conftest for imports only.
move imports to files where they are needed and remove this conftest if it is empty

from plenum.test.node_request.conftest import *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to avoid imports like "*". use explicit entities only

Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from plenum.test.test_stack import CONNECTED, JOINED_NOT_ALLOWED
from plenum.test import waits


whitelist = ['discarding message']

logger = getlogger()


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

timeout = waits.expectedNodeStartUpTimeout() + \
waits.expectedPoolInterconnectionTime(len(nodeSet))
waits.expectedPoolInterconnectionTime(len(nodeSet))
looper.run(eventually(checkNodeStatusRemotesAndF,
expectedStatus,
nodeIdx,
Expand Down
11 changes: 5 additions & 6 deletions plenum/test/instances/test_msgs_from_slow_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,25 @@
from plenum.test.test_node import TestNode
from plenum.test import waits


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 +40,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))
14 changes: 6 additions & 8 deletions plenum/test/instances/test_multiple_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@
from plenum.test.test_node import getNonPrimaryReplicas, getPrimaryReplica
from plenum.test import waits

whitelist = [Suspicions.DUPLICATE_CM_SENT.reason,
'cannot process incoming COMMIT']


@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 +29,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 +51,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
15 changes: 3 additions & 12 deletions plenum/test/instances/test_multiple_pre_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@
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']


@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
14 changes: 5 additions & 9 deletions plenum/test/instances/test_multiple_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@
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']


@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 +30,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 +46,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
11 changes: 3 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 @@ -15,14 +14,10 @@
from plenum.test import waits


whitelist = [Suspicions.PPR_DIGEST_WRONG.reason,
'cannot process incoming PRE-PREPARE']


@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
17 changes: 5 additions & 12 deletions plenum/test/instances/test_prepare_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@
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']


@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 +37,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