mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge pull request #1032 from bigchaindb/fix-tests-readme
Update tests readme
This commit is contained in:
commit
ec14389080
@ -2,9 +2,10 @@ version: '2'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
mdb:
|
mdb:
|
||||||
image: mongo
|
image: mongo:3.4.1
|
||||||
ports:
|
ports:
|
||||||
- "27017"
|
- "27017"
|
||||||
|
command: mongod --replSet=rs0
|
||||||
|
|
||||||
rdb:
|
rdb:
|
||||||
image: rethinkdb
|
image: rethinkdb
|
||||||
@ -15,7 +16,7 @@ services:
|
|||||||
- rdb-data
|
- rdb-data
|
||||||
|
|
||||||
rdb-data:
|
rdb-data:
|
||||||
image: rethinkdb
|
image: rethinkdb:2.3.5
|
||||||
volumes:
|
volumes:
|
||||||
- /data
|
- /data
|
||||||
command: "true"
|
command: "true"
|
||||||
|
@ -8,7 +8,8 @@ A few notes:
|
|||||||
|
|
||||||
- [`tests/common/`](./common/) contains self-contained tests only testing
|
- [`tests/common/`](./common/) contains self-contained tests only testing
|
||||||
[`bigchaindb/common/`](../bigchaindb/common/)
|
[`bigchaindb/common/`](../bigchaindb/common/)
|
||||||
- [`tests/db/`](./db/) contains tests requiring the database backend (e.g. RethinkDB)
|
- [`tests/backend/`](./backend/) contains tests requiring
|
||||||
|
the database backend (RethinkDB or MongoDB)
|
||||||
|
|
||||||
|
|
||||||
## Writing Tests
|
## Writing Tests
|
||||||
@ -20,9 +21,24 @@ We write unit and integration tests for our Python code using the [pytest](http:
|
|||||||
|
|
||||||
### Running Tests Directly
|
### Running Tests Directly
|
||||||
|
|
||||||
If you installed BigchainDB Server using `pip install bigchaindb`, then you didn't install the tests. Before you can run all the tests, you must install BigchainDB from source. The [`CONTRIBUTING.md` file](../CONTRIBUTING.md) has instructions for how to do that.
|
If you installed BigchainDB Server using `pip install bigchaindb`, then you
|
||||||
|
didn't install the tests. Before you can run all the tests, you must install
|
||||||
|
BigchainDB from source. The [`CONTRIBUTING.md` file](../CONTRIBUTING.md) has
|
||||||
|
instructions for how to do that.
|
||||||
|
|
||||||
Next, make sure you have RethinkDB running in the background (e.g. using `rethinkdb --daemon`).
|
Next, make sure you have RethinkDB or MongoDB running in the background. You
|
||||||
|
can run RethinkDB using `rethinkdb --daemon` or MongoDB using `mongod
|
||||||
|
--replSet=rs0`.
|
||||||
|
|
||||||
|
The `pytest` command has many options. If you want to learn about all the
|
||||||
|
things you can do with pytest, see [the pytest
|
||||||
|
documentation](http://pytest.org/latest/). We've also added a customization to
|
||||||
|
pytest:
|
||||||
|
|
||||||
|
`--database-backend`: Defines the backend to use for the tests. It defaults to
|
||||||
|
`rethinkdb`
|
||||||
|
It must be one of the backends available in the [server
|
||||||
|
configuration](https://docs.bigchaindb.com/projects/server/en/latest/server-reference/configuration.html).
|
||||||
|
|
||||||
Now you can run all tests using:
|
Now you can run all tests using:
|
||||||
```text
|
```text
|
||||||
@ -39,18 +55,21 @@ or:
|
|||||||
python setup.py test
|
python setup.py test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note**: the above pytest commands default to use RethinkDB as the backend. If
|
||||||
|
you wish to run the tests against MongoDB add the `--database-backend=mongodb`
|
||||||
|
to the `pytest` command.
|
||||||
|
|
||||||
How does `python setup.py test` work? The documentation for [pytest-runner](https://pypi.python.org/pypi/pytest-runner) explains.
|
How does `python setup.py test` work? The documentation for [pytest-runner](https://pypi.python.org/pypi/pytest-runner) explains.
|
||||||
|
|
||||||
The `pytest` command has many options. If you want to learn about all the things you can do with pytest, see [the pytest documentation](http://pytest.org/latest/). We've also added a customization to pytest:
|
The `pytest` command has many options. If you want to learn about all the things you can do with pytest, see [the pytest documentation](http://pytest.org/latest/). We've also added a customization to pytest:
|
||||||
|
|
||||||
`--database-backend`: Defines the backend to use for the tests.
|
|
||||||
It must be one of the backends available in the [server configuration](https://docs.bigchaindb.com/projects/server/en/latest/server-reference/configuration.html).
|
|
||||||
|
|
||||||
|
|
||||||
### Running Tests with Docker Compose
|
### Running Tests with Docker Compose
|
||||||
|
|
||||||
You can also use [Docker Compose](https://docs.docker.com/compose/) to run all the tests.
|
You can also use [Docker Compose](https://docs.docker.com/compose/) to run all the tests.
|
||||||
|
|
||||||
|
#### With RethinkDB as the backend
|
||||||
|
|
||||||
First, start `RethinkDB` in the background:
|
First, start `RethinkDB` in the background:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
@ -63,14 +82,29 @@ then run the tests using:
|
|||||||
$ docker-compose run --rm bdb py.test -v
|
$ docker-compose run --rm bdb py.test -v
|
||||||
```
|
```
|
||||||
|
|
||||||
If you've upgraded to a newer version of BigchainDB, you might have to rebuild the images before
|
#### With MongoDB as the backend
|
||||||
being able to run the tests. Run:
|
|
||||||
|
First, start `MongoDB` in the background:
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ docker-compose up -d mdb
|
||||||
|
```
|
||||||
|
|
||||||
|
then run the tests using:
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ docker-compose run --rm bdb-mdb py.test -v
|
||||||
|
```
|
||||||
|
|
||||||
|
If you've upgraded to a newer version of BigchainDB, you might have to rebuild
|
||||||
|
the images before being able to run the tests. Run:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
$ docker-compose build
|
$ docker-compose build
|
||||||
```
|
```
|
||||||
|
|
||||||
to rebuild all the images (usually you only need to rebuild the `bdb` image).
|
to rebuild all the images (usually you only need to rebuild the `bdb` and
|
||||||
|
`bdb-mdb` images).
|
||||||
|
|
||||||
## Automated Testing of All Pull Requests
|
## Automated Testing of All Pull Requests
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user