mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge remote-tracking branch 'origin/master' into tx-validation-cleanup
This commit is contained in:
commit
1e2080bf47
@ -9,15 +9,11 @@ import copy
|
|||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import logstats
|
|
||||||
|
|
||||||
from bigchaindb.common import crypto
|
from bigchaindb.common import crypto
|
||||||
from bigchaindb.common.exceptions import (StartupError,
|
from bigchaindb.common.exceptions import (StartupError,
|
||||||
DatabaseAlreadyExists,
|
DatabaseAlreadyExists,
|
||||||
KeypairNotFoundException)
|
KeypairNotFoundException)
|
||||||
import bigchaindb
|
import bigchaindb
|
||||||
from bigchaindb.models import Transaction
|
|
||||||
from bigchaindb.utils import ProcessGroup
|
|
||||||
from bigchaindb import backend, processes
|
from bigchaindb import backend, processes
|
||||||
from bigchaindb.backend import schema
|
from bigchaindb.backend import schema
|
||||||
from bigchaindb.backend.admin import (set_replicas, set_shards, add_replicas,
|
from bigchaindb.backend.admin import (set_replicas, set_shards, add_replicas,
|
||||||
@ -206,39 +202,6 @@ def run_start(args):
|
|||||||
processes.start()
|
processes.start()
|
||||||
|
|
||||||
|
|
||||||
def _run_load(tx_left, stats):
|
|
||||||
logstats.thread.start(stats)
|
|
||||||
b = bigchaindb.Bigchain()
|
|
||||||
|
|
||||||
while True:
|
|
||||||
tx = Transaction.create([b.me], [([b.me], 1)])
|
|
||||||
tx = tx.sign([b.me_private])
|
|
||||||
b.write_transaction(tx)
|
|
||||||
|
|
||||||
stats['transactions'] += 1
|
|
||||||
|
|
||||||
if tx_left is not None:
|
|
||||||
tx_left -= 1
|
|
||||||
if tx_left == 0:
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
@configure_bigchaindb
|
|
||||||
def run_load(args):
|
|
||||||
logger.info('Starting %s processes', args.multiprocess)
|
|
||||||
stats = logstats.Logstats()
|
|
||||||
logstats.thread.start(stats)
|
|
||||||
|
|
||||||
tx_left = None
|
|
||||||
if args.count > 0:
|
|
||||||
tx_left = int(args.count / args.multiprocess)
|
|
||||||
|
|
||||||
workers = ProcessGroup(concurrency=args.multiprocess,
|
|
||||||
target=_run_load,
|
|
||||||
args=(tx_left, stats.get_child()))
|
|
||||||
workers.start()
|
|
||||||
|
|
||||||
|
|
||||||
@configure_bigchaindb
|
@configure_bigchaindb
|
||||||
def run_set_shards(args):
|
def run_set_shards(args):
|
||||||
conn = backend.connect()
|
conn = backend.connect()
|
||||||
@ -373,25 +336,6 @@ def create_parser():
|
|||||||
help='A list of space separated hosts to '
|
help='A list of space separated hosts to '
|
||||||
'remove from the replicaset. Each host '
|
'remove from the replicaset. Each host '
|
||||||
'should be in the form `host:port`.')
|
'should be in the form `host:port`.')
|
||||||
|
|
||||||
load_parser = subparsers.add_parser('load',
|
|
||||||
help='Write transactions to the backlog')
|
|
||||||
|
|
||||||
load_parser.add_argument('-m', '--multiprocess',
|
|
||||||
nargs='?',
|
|
||||||
type=int,
|
|
||||||
default=False,
|
|
||||||
help='Spawn multiple processes to run the command, '
|
|
||||||
'if no value is provided, the number of processes '
|
|
||||||
'is equal to the number of cores of the host machine')
|
|
||||||
|
|
||||||
load_parser.add_argument('-c', '--count',
|
|
||||||
default=0,
|
|
||||||
type=int,
|
|
||||||
help='Number of transactions to push. If the parameter -m '
|
|
||||||
'is set, the count is distributed equally to all the '
|
|
||||||
'processes')
|
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,16 +69,6 @@ e.g. `bigchaindb --dev-start-rethinkdb start`. Note that this will also shutdown
|
|||||||
The option `--dev-allow-temp-keypair` will generate a keypair on the fly if no keypair is found, this is useful when you want to run a temporary instance of BigchainDB in a Docker container, for example.
|
The option `--dev-allow-temp-keypair` will generate a keypair on the fly if no keypair is found, this is useful when you want to run a temporary instance of BigchainDB in a Docker container, for example.
|
||||||
|
|
||||||
|
|
||||||
## bigchaindb load
|
|
||||||
|
|
||||||
Write transactions to the backlog (for benchmarking tests). You can learn more about it using:
|
|
||||||
```text
|
|
||||||
$ bigchaindb load -h
|
|
||||||
```
|
|
||||||
|
|
||||||
Note: This command uses the Python Server API to write transactions to the database. It _doesn't_ use the HTTP API or a driver that wraps the HTTP API.
|
|
||||||
|
|
||||||
|
|
||||||
## bigchaindb set-shards
|
## bigchaindb set-shards
|
||||||
|
|
||||||
This command is specific to RethinkDB so it will only run if BigchainDB is
|
This command is specific to RethinkDB so it will only run if BigchainDB is
|
||||||
|
@ -21,7 +21,6 @@ def test_make_sure_we_dont_remove_any_command():
|
|||||||
assert parser.parse_args(['start']).command
|
assert parser.parse_args(['start']).command
|
||||||
assert parser.parse_args(['set-shards', '1']).command
|
assert parser.parse_args(['set-shards', '1']).command
|
||||||
assert parser.parse_args(['set-replicas', '1']).command
|
assert parser.parse_args(['set-replicas', '1']).command
|
||||||
assert parser.parse_args(['load']).command
|
|
||||||
assert parser.parse_args(['add-replicas', 'localhost:27017']).command
|
assert parser.parse_args(['add-replicas', 'localhost:27017']).command
|
||||||
assert parser.parse_args(['remove-replicas', 'localhost:27017']).command
|
assert parser.parse_args(['remove-replicas', 'localhost:27017']).command
|
||||||
|
|
||||||
@ -382,27 +381,6 @@ def test_calling_main(start_mock, base_parser_mock, parse_args_mock,
|
|||||||
help='Number of replicas (i.e. '
|
help='Number of replicas (i.e. '
|
||||||
'the replication factor)')
|
'the replication factor)')
|
||||||
|
|
||||||
subparsers.add_parser.assert_any_call('load',
|
|
||||||
help='Write transactions to the '
|
|
||||||
'backlog')
|
|
||||||
|
|
||||||
subsubparsers.add_argument.assert_any_call('-m', '--multiprocess',
|
|
||||||
nargs='?', type=int,
|
|
||||||
default=False,
|
|
||||||
help='Spawn multiple processes '
|
|
||||||
'to run the command, if no '
|
|
||||||
'value is provided, the number '
|
|
||||||
'of processes is equal to the '
|
|
||||||
'number of cores of the host '
|
|
||||||
'machine')
|
|
||||||
subsubparsers.add_argument.assert_any_call('-c', '--count',
|
|
||||||
default=0,
|
|
||||||
type=int,
|
|
||||||
help='Number of transactions '
|
|
||||||
'to push. If the parameter -m '
|
|
||||||
'is set, the count is '
|
|
||||||
'distributed equally to all '
|
|
||||||
'the processes')
|
|
||||||
assert start_mock.called is True
|
assert start_mock.called is True
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user