Esempio n. 1
0
def test_check_replica_set_name_mismatch(mongodb_connection,
                                         mock_cmd_line_opts):
    from bigchaindb.backend.localmongodb.connection import _check_replica_set
    from bigchaindb.common.exceptions import ConfigurationError

    # change the replica set name so it does not match the bigchaindb config
    mock_cmd_line_opts['parsed']['replication']['replSet'] = 'rs0'

    with mock.patch.object(Database,
                           'command',
                           return_value=mock_cmd_line_opts):
        with pytest.raises(ConfigurationError):
            _check_replica_set(mongodb_connection)
Esempio n. 2
0
def test_check_replica_set_not_enabled(mongodb_connection):
    from bigchaindb.backend.localmongodb.connection import _check_replica_set
    from bigchaindb.common.exceptions import ConfigurationError

    # no replSet option set
    cmd_line_opts = {
        'argv': ['mongod', '--dbpath=/data'],
        'ok': 1.0,
        'parsed': {
            'storage': {
                'dbPath': '/data'
            }
        }
    }
    with mock.patch.object(Database, 'command', return_value=cmd_line_opts):
        with pytest.raises(ConfigurationError):
            _check_replica_set(mongodb_connection)
Esempio n. 3
0
def test_check_replica_set_command_line(mongodb_connection,
                                        mock_cmd_line_opts):
    from bigchaindb.backend.localmongodb.connection import _check_replica_set

    # replSet option set through the command line
    with mock.patch.object(Database,
                           'command',
                           return_value=mock_cmd_line_opts):
        assert _check_replica_set(mongodb_connection) is None