mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge remote-tracking branch 'remotes/origin/master' into test-template
This commit is contained in:
commit
2c0887c633
@ -13,6 +13,7 @@ import builtins
|
||||
|
||||
import logstats
|
||||
|
||||
import rethinkdb as r
|
||||
|
||||
import bigchaindb
|
||||
import bigchaindb.config_utils
|
||||
@ -203,6 +204,12 @@ def run_load(args):
|
||||
workers.start()
|
||||
|
||||
|
||||
def run_set_shards(args):
|
||||
b = bigchaindb.Bigchain()
|
||||
r.table('bigchain').reconfigure(shards=args.num_shards, replicas=1).run(b.conn)
|
||||
r.table('backlog').reconfigure(shards=args.num_shards, replicas=1).run(b.conn)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Control your BigchainDB node.',
|
||||
@ -243,6 +250,13 @@ def main():
|
||||
subparsers.add_parser('start',
|
||||
help='Start BigchainDB')
|
||||
|
||||
# parser for configuring the number of shards
|
||||
sharding_parser = subparsers.add_parser('set-shards',
|
||||
help='Configure number of shards')
|
||||
|
||||
sharding_parser.add_argument('num_shards', metavar='num_shards', type=int, default=1,
|
||||
help='Number of shards')
|
||||
|
||||
load_parser = subparsers.add_parser('load',
|
||||
help='Write transactions to the backlog')
|
||||
|
||||
|
@ -131,6 +131,7 @@ if [ "$WHAT_TO_DEPLOY" == "servers" ]; then
|
||||
# this will only be sent to one of the nodes, see the
|
||||
# definition of init_bigchaindb() in fabfile.py to see why.
|
||||
fab init_bigchaindb
|
||||
fab set_shards:$NUM_NODES
|
||||
else
|
||||
# Deploying clients
|
||||
# The only thing to configure on clients is the api_endpoint
|
||||
|
7
deploy-cluster-aws/fabfile.py
vendored
7
deploy-cluster-aws/fabfile.py
vendored
@ -166,6 +166,13 @@ def init_bigchaindb():
|
||||
run('bigchaindb init', pty=False)
|
||||
|
||||
|
||||
# Set the number of shards (in the backlog and bigchain tables)
|
||||
@task
|
||||
@hosts(public_dns_names[0])
|
||||
def set_shards(num_shards):
|
||||
run('bigchaindb set-shards {}'.format(num_shards))
|
||||
|
||||
|
||||
# Start BigchainDB using screen
|
||||
@task
|
||||
@parallel
|
||||
|
@ -43,3 +43,10 @@ This command is used to run benchmarking tests. You can learn more about it usin
|
||||
```text
|
||||
$ bigchaindb load -h
|
||||
```
|
||||
|
||||
### bigchaindb set-shards
|
||||
|
||||
This command is used to set the number of shards in the underlying datastore. For example, the following command will set the number of shards to four:
|
||||
```text
|
||||
$ bigchaindb set-shards 4
|
||||
```
|
@ -1,11 +1,12 @@
|
||||
import json
|
||||
from unittest.mock import Mock, patch
|
||||
from argparse import Namespace
|
||||
from pprint import pprint
|
||||
import copy
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.db.conftest import setup_database
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_run_configure(monkeypatch):
|
||||
@ -225,3 +226,22 @@ def test_start_rethinkdb_exits_when_cannot_start(mock_popen):
|
||||
with pytest.raises(exceptions.StartupError):
|
||||
utils.start_rethinkdb()
|
||||
|
||||
|
||||
def test_set_shards(b):
|
||||
import rethinkdb as r
|
||||
from bigchaindb.commands.bigchain import run_set_shards
|
||||
|
||||
# set the number of shards
|
||||
args = Namespace(num_shards=3)
|
||||
run_set_shards(args)
|
||||
|
||||
# retrieve table configuration
|
||||
table_config = list(r.db('rethinkdb')
|
||||
.table('table_config')
|
||||
.filter(r.row['db'] == b.dbname)
|
||||
.run(b.conn))
|
||||
|
||||
# check that the number of shards got set to the correct value
|
||||
for table in table_config:
|
||||
if table['name'] in ['backlog', 'bigchain']:
|
||||
assert len(table['shards']) == 3
|
||||
|
Loading…
x
Reference in New Issue
Block a user