def test_reconfigure_too_many_replicas(rdb_conn, db_name, db_conn): from bigchaindb.backend.rethinkdb.admin import reconfigure from bigchaindb.backend.exceptions import OperationError replicas = _count_rethinkdb_servers() + 1 with pytest.raises(OperationError) as exc: reconfigure(db_conn, table='backlog', shards=1, replicas=replicas) assert isinstance(exc.value.__cause__, r.ReqlOpFailedError)
def test_reconfigure(rdb_conn, db_name, db_conn): from bigchaindb.backend.rethinkdb.admin import reconfigure table_config = r.db(db_name).table('backlog').config().run(rdb_conn) replicas_before = table_config['shards'][0]['replicas'] assert len(replicas_before) == 1 reconfigure(db_conn, table='backlog', shards=2, replicas=2) table_config = r.db(db_name).table('backlog').config().run(rdb_conn) assert len(table_config['shards'][0]['replicas']) == 2 assert (table_config['shards'][0]['replicas'][0] != table_config['shards'][0]['replicas'][1])
def test_reconfigure_replicas_without_nonvoting_replica_tags( rdb_conn, db_name, db_conn): from bigchaindb.backend.rethinkdb.admin import reconfigure from bigchaindb.backend.exceptions import OperationError with pytest.raises(OperationError) as exc: reconfigure(db_conn, table='backlog', shards=1, replicas={'default': 1}, primary_replica_tag='default') assert isinstance(exc.value.__cause__, r.ReqlQueryLogicError)
def test_reconfigure_shards_dry_run(rdb_conn, db_name, db_conn): from bigchaindb.backend.rethinkdb.admin import reconfigure table_config = r.db(db_name).table('backlog').config().run(rdb_conn) replicas_before = table_config['shards'][0]['replicas'] assert len(replicas_before) == 1 assert len(table_config['shards']) == 1 what_happened = reconfigure( db_conn, table='backlog', shards=2, replicas={'default': 1}, primary_replica_tag='default', nonvoting_replica_tags=('default', ), dry_run=True, ) assert what_happened['reconfigured'] == 0 assert len(what_happened['config_changes']) == 1 assert len(what_happened['config_changes'][0]['new_val']['shards']) == 2 table_config = r.db(db_name).table('backlog').config().run(rdb_conn) assert len(table_config['shards']) == 1