-
Notifications
You must be signed in to change notification settings - Fork 377
Fix primary selection after primary demotion (INDY-463) #354
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
Merged
ashcherbakov
merged 7 commits into
hyperledger:master
from
andkononykhin:bugfix/fix_break_after_restart
Aug 28, 2017
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c7a3471
modified rank routine, added test cases for primary demotion
andkononykhin 45da757
fixed pep8
andkononykhin 15c19cb
fixed nodes oreder initialization
andkononykhin d3707c4
Merge branch 'master' of https://github.com/hyperledger/indy-plenum i…
andkononykhin 406aab7
Merge branch 'master' of https://github.com/hyperledger/indy-plenum i…
andkononykhin 357a48d
added checks that pool is functional after recofigurations
andkononykhin 740ec4a
added additional view change to ensure original master is skipped
andkononykhin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
.../test/primary_selection/test_primary_selection_after_primary_demotion_and_pool_restart.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from stp_core.common.log import getlogger | ||
|
||
from plenum.common.constants import ALIAS, SERVICES | ||
from plenum.test.pool_transactions.conftest import looper | ||
from plenum.test.pool_transactions.helper import updateNodeData | ||
|
||
from plenum.test.test_node import TestNode, checkNodesConnected, \ | ||
ensureElectionsDone | ||
from plenum.test.helper import checkViewNoForNodes | ||
|
||
from plenum.test.primary_selection.helper import getPrimaryNodesIdxs | ||
|
||
logger = getlogger() | ||
|
||
def test_primary_selection_after_primary_demotion_and_pool_restart(looper, | ||
txnPoolNodeSet, stewardAndWalletForMasterNode, txnPoolMasterNodes, | ||
tconf, tdirWithPoolTxns): | ||
""" | ||
Demote primary and restart the pool. | ||
Pool should select new primary and have viewNo=0 after restart. | ||
""" | ||
|
||
logger.info("1. turn off the node which has primary replica for master instanse") | ||
master_node = txnPoolMasterNodes[0] | ||
client, wallet = stewardAndWalletForMasterNode | ||
|
||
node_data = { | ||
ALIAS: master_node.name, | ||
SERVICES: [] | ||
} | ||
updateNodeData(looper, client, wallet, master_node, node_data) | ||
|
||
restNodes = [node for node in txnPoolNodeSet if node.name != master_node.name] | ||
ensureElectionsDone(looper, restNodes) | ||
|
||
logger.info("2. restart pool") | ||
# Stopping existing nodes | ||
for node in txnPoolNodeSet: | ||
node.stop() | ||
looper.removeProdable(node) | ||
|
||
# Starting nodes again by creating `Node` objects since that simulates | ||
# what happens when starting the node with script | ||
restartedNodes = [] | ||
for node in txnPoolNodeSet: | ||
restartedNode = TestNode(node.name, basedirpath=tdirWithPoolTxns, | ||
config=tconf, ha=node.nodestack.ha, | ||
cliha=node.clientstack.ha) | ||
looper.add(restartedNode) | ||
restartedNodes.append(restartedNode) | ||
|
||
restNodes = [node for node in restartedNodes if node.name != master_node.name] | ||
|
||
looper.run(checkNodesConnected(restNodes)) | ||
ensureElectionsDone(looper, restNodes) | ||
checkViewNoForNodes(restNodes, 0) | ||
|
||
primariesIdxs = getPrimaryNodesIdxs(restNodes) | ||
assert restNodes[primariesIdxs[0]].name != master_node.name | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also check that pool is functional after this?