Exemplo n.º 1
0
 def test_peer(self, mock_check_peer, mock_helm_install, mock_helm_upgrade):
     OPTS = deepcopy(self.OPTS)
     setup_peer(OPTS)
     mock_helm_install.assert_has_calls([
         call('a-repo',
              'hlf-couchdb',
              'cdb-peer0',
              'peer-namespace',
              config_yaml='./a_dir/hlf-couchdb/cdb-peer0.yaml',
              verbose=False),
         call('a-repo',
              'hlf-peer',
              'peer0',
              'peer-namespace',
              config_yaml='./a_dir/hlf-peer/peer0.yaml',
              verbose=False),
         call('a-repo',
              'hlf-couchdb',
              'cdb-peer1',
              'peer-namespace',
              config_yaml='./a_dir/hlf-couchdb/cdb-peer1.yaml',
              verbose=False),
         call('a-repo',
              'hlf-peer',
              'peer1',
              'peer-namespace',
              config_yaml='./a_dir/hlf-peer/peer1.yaml',
              verbose=False),
     ])
     mock_helm_upgrade.assert_not_called()
     mock_check_peer.assert_has_calls([
         call('peer-namespace', 'peer0', verbose=False),
         call('peer-namespace', 'peer1', verbose=False)
     ])
Exemplo n.º 2
0
 def test_peer_upgrade(
     self,
     mock_check_peer,
     mock_get_version,
     mock_helm_check,
     mock_helm_extra_vars,
     mock_helm_install,
     mock_helm_upgrade,
     mock_get_peers,
 ):
     OPTS = deepcopy(self.OPTS)
     OPTS["msps"]["BetaMSP"]["peers"]["nodes"] = {"peer0": {}}
     mock_get_version.side_effect = ["cdb-version", "peer-version"]
     mock_get_peers.side_effect = [["peer0"]]
     mock_helm_extra_vars.side_effect = [
         "extra-vars-cdb-peer0", "extra-vars-peer0"
     ]
     setup_peer(OPTS, upgrade=True)
     mock_get_peers.assert_called_once_with(opts=OPTS, msp="BetaMSP")
     mock_helm_extra_vars.assert_has_calls([
         call(
             version="cdb-version",
             config_yaml="./a_dir/BetaMSP/hlf-couchdb/cdb-peer0.yaml",
             preserve=(
                 HelmPreserve(
                     "peer-namespace",
                     "cdb-peer0-hlf-couchdb",
                     "COUCHDB_USERNAME",
                     "couchdbUsername",
                 ),
                 HelmPreserve(
                     "peer-namespace",
                     "cdb-peer0-hlf-couchdb",
                     "COUCHDB_PASSWORD",
                     "couchdbPassword",
                 ),
             ),
         ),
         call(
             version="peer-version",
             config_yaml="./a_dir/BetaMSP/hlf-peer/peer0.yaml",
         ),
     ])
     mock_helm_install.assert_not_called()
     mock_helm_upgrade.assert_has_calls([
         call(
             "a-repo",
             "hlf-couchdb",
             "cdb-peer0",
             extra_vars="extra-vars-cdb-peer0",
         ),
         call("a-repo", "hlf-peer", "peer0", extra_vars="extra-vars-peer0"),
     ])
     mock_helm_check.assert_has_calls([
         call("hlf-couchdb", "cdb-peer0", "peer-namespace"),
         call("hlf-peer", "peer0", "peer-namespace"),
     ])
     mock_check_peer.assert_called_once_with("peer-namespace", "peer0")
Exemplo n.º 3
0
def runner_peer(opts, upgrade=False):
    """Deploy Hyperledger Fabric Peers.

    Args:
        opts (dict): Nephos options dict.
        upgrade (bool): Do we upgrade the deployment? False by default.
        
    """
    setup_peer(opts, upgrade=upgrade)
    create_channel(opts)
Exemplo n.º 4
0
 def test_peer_upgrade(self, mock_check_peer, mock_helm_install,
                       mock_helm_upgrade):
     OPTS = deepcopy(self.OPTS)
     OPTS['peers']['names'] = ['peer0']
     setup_peer(OPTS, upgrade=True)
     mock_helm_install.assert_not_called()
     mock_helm_upgrade.assert_called_once_with(
         'a-repo',
         'hlf-peer',
         'peer0',
         'peer-namespace',
         config_yaml='./a_dir/hlf-peer/peer0.yaml',
         verbose=False)
     mock_check_peer.assert_called_once_with('peer-namespace',
                                             'peer0',
                                             verbose=False)
Exemplo n.º 5
0
def fabric(ctx):  # pragma: no cover
    opts = load_config(ctx.obj['settings_file'])
    # Setup CA
    setup_ca(opts, upgrade=ctx.obj['upgrade'], verbose=ctx.obj['verbose'])
    # Crypto material
    admin_msp(opts, opts['orderers']['msp'], verbose=ctx.obj['verbose'])
    admin_msp(opts, opts['peers']['msp'], verbose=ctx.obj['verbose'])
    genesis_block(opts, verbose=ctx.obj['verbose'])
    channel_tx(opts, verbose=ctx.obj['verbose'])
    setup_nodes(opts, 'orderer', verbose=ctx.obj['verbose'])
    setup_nodes(opts, 'peer', verbose=ctx.obj['verbose'])
    # Orderers
    setup_ord(opts, upgrade=ctx.obj['upgrade'], verbose=ctx.obj['verbose'])
    # Peers
    setup_peer(opts, upgrade=ctx.obj['upgrade'], verbose=ctx.obj['verbose'])
    setup_channel(opts, verbose=ctx.obj['verbose'])
Exemplo n.º 6
0
 def test_peer(self, mock_check_peer, mock_helm_install, mock_helm_upgrade):
     OPTS = deepcopy(self.OPTS)
     setup_peer(OPTS)
     mock_helm_install.assert_has_calls([
         call(
             "a-repo",
             "hlf-couchdb",
             "cdb-peer0",
             "peer-namespace",
             config_yaml="./a_dir/hlf-couchdb/cdb-peer0.yaml",
             verbose=False,
         ),
         call(
             "a-repo",
             "hlf-peer",
             "peer0",
             "peer-namespace",
             config_yaml="./a_dir/hlf-peer/peer0.yaml",
             verbose=False,
         ),
         call(
             "a-repo",
             "hlf-couchdb",
             "cdb-peer1",
             "peer-namespace",
             config_yaml="./a_dir/hlf-couchdb/cdb-peer1.yaml",
             verbose=False,
         ),
         call(
             "a-repo",
             "hlf-peer",
             "peer1",
             "peer-namespace",
             config_yaml="./a_dir/hlf-peer/peer1.yaml",
             verbose=False,
         ),
     ])
     mock_helm_upgrade.assert_not_called()
     mock_check_peer.assert_has_calls([
         call("peer-namespace", "peer0", verbose=False),
         call("peer-namespace", "peer1", verbose=False),
     ])
Exemplo n.º 7
0
 def test_peer_upgrade(self, mock_check_peer, mock_helm_install,
                       mock_helm_upgrade):
     OPTS = deepcopy(self.OPTS)
     OPTS["peers"]["names"] = ["peer0"]
     setup_peer(OPTS, upgrade=True)
     mock_helm_install.assert_not_called()
     mock_helm_upgrade.assert_has_calls([
         call(
             "a-repo",
             "hlf-couchdb",
             "cdb-peer0",
             "peer-namespace",
             config_yaml="./a_dir/hlf-couchdb/cdb-peer0.yaml",
             preserve=(
                 HelmPreserve(
                     "cdb-peer0-hlf-couchdb",
                     "COUCHDB_USERNAME",
                     "couchdbUsername",
                 ),
                 HelmPreserve(
                     "cdb-peer0-hlf-couchdb",
                     "COUCHDB_PASSWORD",
                     "couchdbPassword",
                 ),
             ),
             verbose=False,
         ),
         call(
             "a-repo",
             "hlf-peer",
             "peer0",
             "peer-namespace",
             config_yaml="./a_dir/hlf-peer/peer0.yaml",
             verbose=False,
         ),
     ])
     mock_check_peer.assert_called_once_with("peer-namespace",
                                             "peer0",
                                             verbose=False)
Exemplo n.º 8
0
 def test_peer(
     self,
     mock_check_peer,
     mock_get_version,
     mock_helm_check,
     mock_helm_extra_vars,
     mock_helm_install,
     mock_helm_upgrade,
 ):
     OPTS = deepcopy(self.OPTS)
     mock_get_version.side_effect = [
         "cdb-version",
         "peer-version",
         "cdb-version",
         "peer-version",
     ]
     mock_helm_extra_vars.side_effect = [
         "extra-vars-cdb-peer0",
         "extra-vars-peer0",
         "extra-vars-cdb-peer1",
         "extra-vars-peer1",
     ]
     setup_peer(OPTS)
     mock_helm_extra_vars.assert_has_calls(
         [
             call(
                 version="cdb-version",
                 config_yaml="./a_dir/hlf-couchdb/cdb-peer0.yaml",
             ),
             call(version="peer-version", config_yaml="./a_dir/hlf-peer/peer0.yaml"),
             call(
                 version="cdb-version",
                 config_yaml="./a_dir/hlf-couchdb/cdb-peer1.yaml",
             ),
             call(version="peer-version", config_yaml="./a_dir/hlf-peer/peer1.yaml"),
         ]
     )
     mock_helm_install.assert_has_calls(
         [
             call(
                 "a-repo",
                 "hlf-couchdb",
                 "cdb-peer0",
                 "peer-namespace",
                 extra_vars="extra-vars-cdb-peer0",
                 verbose=False,
             ),
             call(
                 "a-repo",
                 "hlf-peer",
                 "peer0",
                 "peer-namespace",
                 extra_vars="extra-vars-peer0",
                 verbose=False,
             ),
             call(
                 "a-repo",
                 "hlf-couchdb",
                 "cdb-peer1",
                 "peer-namespace",
                 extra_vars="extra-vars-cdb-peer1",
                 verbose=False,
             ),
             call(
                 "a-repo",
                 "hlf-peer",
                 "peer1",
                 "peer-namespace",
                 extra_vars="extra-vars-peer1",
                 verbose=False,
             ),
         ]
     )
     mock_helm_upgrade.assert_not_called()
     mock_helm_check.assert_has_calls(
         [
             call("hlf-couchdb", "cdb-peer0", "peer-namespace"),
             call("hlf-peer", "peer0", "peer-namespace"),
             call("hlf-couchdb", "cdb-peer1", "peer-namespace"),
             call("hlf-peer", "peer1", "peer-namespace"),
         ]
     )
     mock_check_peer.assert_has_calls(
         [
             call("peer-namespace", "peer0", verbose=False),
             call("peer-namespace", "peer1", verbose=False),
         ]
     )
Exemplo n.º 9
0
def peer(ctx):  # pragma: no cover
    opts = load_config(ctx.obj['settings_file'])
    setup_peer(opts, upgrade=ctx.obj['upgrade'], verbose=ctx.obj['verbose'])
    setup_channel(opts, verbose=ctx.obj['verbose'])