-
Notifications
You must be signed in to change notification settings - Fork 374
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
Send ledger status to new nodes in all cases; test for node restart #567
Merged
Merged
Changes from all commits
Commits
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 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 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,70 @@ | ||
import pytest | ||
from plenum.test.test_node import ensure_node_disconnected, checkNodesConnected | ||
from plenum.test import waits | ||
from plenum.test.node_request.helper import sdk_ensure_pool_functional | ||
from plenum.common.config_helper import PNodeConfigHelper | ||
from plenum.test.test_node import TestNode | ||
|
||
from plenum.test.pool_transactions.conftest import looper | ||
|
||
|
||
def get_group(nodeSet, group_cnt, include_primary=False): | ||
if group_cnt >= len(nodeSet): | ||
return nodeSet | ||
|
||
ret_group = [] | ||
primary_name = nodeSet[0].master_primary_name | ||
primary_idx = next(i for i, _ in enumerate(nodeSet) if nodeSet[i].name == primary_name) | ||
if not include_primary: | ||
primary_idx += 1 | ||
|
||
while len(ret_group) < group_cnt: | ||
ret_group.append(nodeSet[primary_idx % len(nodeSet)]) | ||
primary_idx += 1 | ||
|
||
return ret_group | ||
|
||
|
||
def restart_nodes(looper, nodeSet, restart_set, tconf, tdir, allPluginsPath, | ||
after_restart_timeout=None, per_add_timeout=None): | ||
for node_to_stop in restart_set: | ||
node_to_stop.cleanupOnStopping = True | ||
node_to_stop.stop() | ||
looper.removeProdable(node_to_stop) | ||
|
||
rest_nodes = [n for n in nodeSet if n not in restart_set] | ||
for node_to_stop in restart_set: | ||
ensure_node_disconnected(looper, node_to_stop, nodeSet, timeout=2) | ||
|
||
if after_restart_timeout: | ||
looper.runFor(after_restart_timeout) | ||
|
||
for node_to_restart in restart_set: | ||
config_helper = PNodeConfigHelper(node_to_restart.name, tconf, chroot=tdir) | ||
restarted_node = TestNode(node_to_restart.name, config_helper=config_helper, config=tconf, | ||
pluginPaths=allPluginsPath, ha=node_to_restart.nodestack.ha, | ||
cliha=node_to_restart.clientstack.ha) | ||
looper.add(restarted_node) | ||
idx = nodeSet.index(node_to_restart) | ||
nodeSet[idx] = restarted_node | ||
if per_add_timeout: | ||
looper.run(checkNodesConnected(rest_nodes + [restarted_node], customTimeout=per_add_timeout)) | ||
rest_nodes += [restarted_node] | ||
|
||
if not per_add_timeout: | ||
looper.run(checkNodesConnected(nodeSet, customTimeout=after_restart_timeout)) | ||
|
||
|
||
nodeCount = 7 | ||
|
||
|
||
def test_restart_groups(looper, txnPoolNodeSet, tconf, tdir, | ||
sdk_pool_handle, sdk_wallet_client, allPluginsPath): | ||
|
||
tm = tconf.ToleratePrimaryDisconnection + waits.expectedPoolElectionTimeout(len(txnPoolNodeSet)) | ||
|
||
restart_group = get_group(txnPoolNodeSet, 4, include_primary=False) | ||
|
||
restart_nodes(looper, txnPoolNodeSet, restart_group, tconf, tdir, allPluginsPath, | ||
after_restart_timeout=tm, per_add_timeout=tm) | ||
sdk_ensure_pool_functional(looper, txnPoolNodeSet, sdk_wallet_client, sdk_pool_handle) |
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.
Are we also going to have the tests when the whole group is restarted at the same time?
Are we also going to have the tests when primary is also part of the group?