def test_upgrade_does_not_get_into_loop_if_reinstall(
        looper,
        tconf,
        nodeSet,
        validUpgrade,
        trustee,
        trusteeWallet,
        monkeypatch):
    new_version = bumpedVersion()
    upgr1 = deepcopy(validUpgrade)
    upgr1[VERSION] = new_version
    upgr1[REINSTALL] = True

    # An upgrade scheduled, it should pass
    ensureUpgradeSent(looper, trustee, trusteeWallet, upgr1)
    looper.run(
        eventually(
            checkUpgradeScheduled,
            nodeSet,
            upgr1[VERSION],
            retryWait=1,
            timeout=waits.expectedUpgradeScheduled()))

    # here we make nodes think they have upgraded successfully
    monkeypatch.setattr(sovrin_node.__metadata__, '__version__', new_version)
    check_no_loop(nodeSet, UpgradeLog.UPGRADE_SUCCEEDED)
Beispiel #2
0
def validUpgrade(nodeIds, tconf):
    schedule = {}
    unow = datetime.utcnow().replace(tzinfo=dateutil.tz.tzutc())
    startAt = unow + timedelta(seconds=90)
    acceptableDiff = tconf.MinSepBetweenNodeUpgrades + 1
    for i in nodeIds:
        schedule[i] = datetime.isoformat(startAt)
        startAt = startAt + timedelta(seconds=acceptableDiff + 3)
    return dict(name='upgrade-13', version=bumpedVersion(), action=START,
                schedule=schedule, sha256='aad1242', timeout=10)
Beispiel #3
0
def testOnlyTrusteeCanSendPoolUpgrade(looper, steward, validUpgrade):
    # A steward sending POOL_UPGRADE but txn fails
    stClient, stWallet = steward
    validUpgrade = deepcopy(validUpgrade)
    validUpgrade[NAME] = 'upgrade-20'
    validUpgrade[VERSION] = bumpedVersion()
    _, req = sendUpgrade(stClient, stWallet, validUpgrade)
    timeout = plenumWaits.expectedReqNAckQuorumTime()
    looper.run(eventually(checkRejects, stClient, req.reqId,
                          'cannot do', retryWait=1, timeout=timeout))
def testOnlyTrusteeCanSendPoolUpgrade(looper, steward, validUpgrade):
    # A steward sending POOL_UPGRADE but txn fails
    stClient, stWallet = steward
    validUpgrade = deepcopy(validUpgrade)
    validUpgrade[NAME] = 'upgrade-20'
    validUpgrade[VERSION] = bumpedVersion()
    _, req = sendUpgrade(stClient, stWallet, validUpgrade)
    timeout = plenumWaits.expectedReqNAckQuorumTime()
    looper.run(eventually(checkRejects, stClient, req.reqId,
                          'cannot do', retryWait=1, timeout=timeout))
Beispiel #5
0
def invalidUpgrade(nodeIds, tconf):
    schedule = {}
    unow = datetime.utcnow().replace(tzinfo=dateutil.tz.tzutc())
    startAt = unow + timedelta(seconds=60)
    acceptableDiff = tconf.MinSepBetweenNodeUpgrades + 1
    for i in nodeIds:
        schedule[i] = datetime.isoformat(startAt)
        startAt = startAt + timedelta(seconds=acceptableDiff - 3)
    return dict(name='upgrade-14', version=bumpedVersion(), action=START,
                schedule=schedule,
                # sha256=get_valid_code_hash(),
                sha256='46c715a90b1067142d548cb1f1405b0486b32b1a27d418ef3a52bd976e9fae50',
                timeout=10)
Beispiel #6
0
def validUpgrade(nodeIds, tconf):
    schedule = {}
    unow = datetime.utcnow().replace(tzinfo=dateutil.tz.tzutc())
    startAt = unow + timedelta(seconds=30)
    acceptableDiff = tconf.MinSepBetweenNodeUpgrades + 1
    for i in nodeIds:
        schedule[i] = datetime.isoformat(startAt)
        startAt = startAt + timedelta(seconds=acceptableDiff + 3)
    return dict(name='upgrade-13', version=bumpedVersion(), action=START,
                schedule=schedule,
                # sha256=get_valid_code_hash(),
                sha256='db34a72a90d026dae49c3b3f0436c8d3963476c77468ad955845a1ccf7b03f55',
                timeout=1)
Beispiel #7
0
def validUpgrade(nodeIds, tconf):
    schedule = {}
    unow = datetime.utcnow().replace(tzinfo=dateutil.tz.tzutc())
    startAt = unow + timedelta(seconds=30)
    acceptableDiff = tconf.MinSepBetweenNodeUpgrades + 1
    for i in nodeIds:
        schedule[i] = datetime.isoformat(startAt)
        startAt = startAt + timedelta(seconds=acceptableDiff + 3)
    return dict(
        name='upgrade-13',
        version=bumpedVersion(),
        action=START,
        schedule=schedule,
        # sha256=get_valid_code_hash(),
        sha256=
        'db34a72a90d026dae49c3b3f0436c8d3963476c77468ad955845a1ccf7b03f55',
        timeout=1)
Beispiel #8
0
def invalidUpgrade(nodeIds, tconf):
    schedule = {}
    unow = datetime.utcnow().replace(tzinfo=dateutil.tz.tzutc())
    startAt = unow + timedelta(seconds=60)
    acceptableDiff = tconf.MinSepBetweenNodeUpgrades + 1
    for i in nodeIds:
        schedule[i] = datetime.isoformat(startAt)
        startAt = startAt + timedelta(seconds=acceptableDiff - 3)
    return dict(
        name='upgrade-14',
        version=bumpedVersion(),
        action=START,
        schedule=schedule,
        # sha256=get_valid_code_hash(),
        sha256=
        '46c715a90b1067142d548cb1f1405b0486b32b1a27d418ef3a52bd976e9fae50',
        timeout=10)
Beispiel #9
0
def test_upgrade_does_not_get_into_loop_if_failed(looper, tconf, nodeSet,
                                                  validUpgrade, trustee,
                                                  trusteeWallet, monkeypatch):
    new_version = bumpedVersion()
    upgr1 = deepcopy(validUpgrade)
    upgr1[VERSION] = new_version

    # An upgrade scheduled, it should pass
    ensureUpgradeSent(looper, trustee, trusteeWallet, upgr1)
    looper.run(
        eventually(
            checkUpgradeScheduled,
            nodeSet,
            upgr1[VERSION],
            retryWait=1,
            timeout=waits.expectedUpgradeScheduled()))

    # we have not patched sovrin_node version so nodes think the upgrade had
    # failed
    check_no_loop(nodeSet, UpgradeLog.UPGRADE_FAILED)
def testOnlyTrusteeCanSendPoolUpgrade(validUpgradeSent, looper, steward,
                                      validUpgrade):
    # A steward sending POOL_UPGRADE but txn fails
    stClient, stWallet = steward
    validUpgrade = deepcopy(validUpgrade)
    validUpgrade[NAME] = 'upgrade-20'
    validUpgrade[VERSION] = bumpedVersion()
    _, req = sendUpgrade(stClient, stWallet, validUpgrade)
    with pytest.raises(AssertionError):
        checkSufficientRepliesForRequests(looper,
                                          stClient, [
                                              req,
                                          ],
                                          timeoutPerReq=10)
    looper.run(
        eventually(checkNacks,
                   stClient,
                   req.reqId,
                   'cannot do',
                   retryWait=1,
                   timeout=5))
Beispiel #11
0
import pytest

import sovrin_node
from stp_core.loop.eventually import eventually
from plenum.common.constants import TXN_TYPE
from sovrin_common.constants import NODE_UPGRADE

from plenum.common.types import OPERATION, f
from sovrin_node.server.upgrade_log import UpgradeLog
from sovrin_node.test.upgrade.helper import bumpedVersion

oldVersion = sovrin_node.__metadata__.__version_info__
oldVersionStr = sovrin_node.__metadata__.__version__

# Increasing the version of code
newVer = bumpedVersion()
sovrin_node.__metadata__.__version__ = newVer
sovrin_node.__metadata__.__version_info__ = tuple(
    int(v) for v in newVer.split('.'))

from sovrin_node.test.conftest import tdirWithPoolTxns, poolTxnNodeNames

whitelist = ['unable to send message']
# TODO: Implement a client in node


@pytest.fixture(scope="module")
def tdirWithPoolTxns(tdirWithPoolTxns, poolTxnNodeNames, tconf):
    # For each node, adding a file with old version number which makes the node
    # think that an upgrade has been performed
    for nm in poolTxnNodeNames:
import pytest

from sovrin_common.constants import IN_PROGRESS, FAIL
from sovrin_node.test.upgrade.helper import populate_log_with_upgrade_events, check_node_set_acknowledges_upgrade, \
    bumpedVersion
from sovrin_node.server.upgrade_log import UpgradeLog

INVALID_VERSION = bumpedVersion()
whitelist = ['unable to send message', 'Failed to upgrade node']
# TODO: Implement a client in node


@pytest.fixture(scope="module")
def tdirWithPoolTxns(tdirWithPoolTxns, poolTxnNodeNames, tconf):
    # For each node, adding a file with he current version number which makes the node
    # think that an upgrade has been performed
    populate_log_with_upgrade_events(tdirWithPoolTxns, poolTxnNodeNames, tconf,
                                     INVALID_VERSION)
    return tdirWithPoolTxns


def test_node_handles_unsuccessful_upgrade(looper, nodeSet, nodeIds):
    check_node_set_acknowledges_upgrade(looper, nodeSet, nodeIds,
                                        [IN_PROGRESS, FAIL], INVALID_VERSION)

    for node in nodeSet:
        assert node.upgrader.scheduledUpgrade is None
        assert node.upgrader.lastUpgradeEventInfo[
            0] == UpgradeLog.UPGRADE_FAILED