GithubHelp home page GithubHelp logo

dockerdb's People

Contributors

fabianelsmer avatar florianludwig avatar itsbjoern avatar marfri avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dockerdb's Issues

Mongo with Replica Set

The mongo fixture does not support using replica sets for the test. Sadly for some features of mongodb to work (like changeStreams) the mongod service needs to be started with a replica set, even if there is no second container.

  • dockerdb version: 0.2.0
  • Python version: 3.6.8
  • Operating System: Fedora 29

Exception when trying to drop admin and config database on mongo 3.6

  • docker mongodb version: 3.6.8
  • dockerdb version: 0.2.0
  • Python version: 3.6.8
  • Operating System: Fedora 29

Description

Using newer versions of mongodb (like 3.6.8) there are 2 exceptions while trying to factory_reset the databases, specifically while trying to drop the 'admin' database and the 'config' database.

When dropping 'admin':
pymongo.errors.OperationFailure: Dropping the 'admin' database is prohibited.

When dropping 'config':
pymongo.errors.OperationFailure: Direct writes against config.transactions cannot be performed using a transaction or on a session.

Traceback:
../../lnva2-ira6Ubzw/lib/python3.6/site-packages/dockerdb/pytest.py:30: in get_service
service.factory_reset()
../../lnva2-ira6Ubzw/lib/python3.6/site-packages/dockerdb/init.py:140: in factory_reset
client.drop_database(db)
../../lnva2-ira6Ubzw/lib/python3.6/site-packages/pymongo/mongo_client.py:1541: in drop_database
session=session)
../../lnva2-ira6Ubzw/lib/python3.6/site-packages/pymongo/database.py:439: in _command
client=self.__client)
../../lnva2-ira6Ubzw/lib/python3.6/site-packages/pymongo/pool.py:496: in command
collation=collation)
../../lnva2-ira6Ubzw/lib/python3.6/site-packages/pymongo/network.py:125: in command
parse_write_concern_error=parse_write_concern_error)

Mongorestore fails to restore data when called from within a docker container

  • py.test dockerdb version:
    0.5.1
  • Mongodb version
    3.5
  • Python version:
    2.7
  • Operating System:
    Fedora 29

Description

Dockerdb generally works even from within another docker container, as long as the docker.sock is mounted. It makes local testing a breeze, since the docker-compose / Dockerfile already encapsulates the project setup, independent of the host environment.

The restore option fails to set the data on the database when a pytest is executed from within a docker container. The dump path should exists, but the exec_run returns the following error:

('Exit code', 1, "2020-03-10T02:19:26.710+0000 Failed: mongorestore target 
'/tmp/tmpc_pieAtmp_1583806764_mongo_0/dump' invalid: stat 
/tmp/tmpc_pieAtmp_1583806764_mongo_0/dump: no such file or directory\n")

Executing the same test outside the docker container successfully restores the data. The problem seems to be related to the way the service shares data, using a shared volume. The problem can be locally reproduced but fixed by mounting /tmp in the main container.

What I Did

conftest.py

BASE_PATH = os.path.dirname(__file__)
DUMP_PATH = os.path.join(BASE_PATH, 'dump')
mongo = dockerdb.mongo_pytest.mongo_fixture(versions=["3.5"], restore=DUMP_PATH)
docker exec docker_container pytest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.