1
0
mirror of https://github.com/bigchaindb/bigchaindb.git synced 2024-06-23 01:36:42 +02:00
bigchaindb/tests
Lev Berman 89d665c01e Problem: Asset tests are disabled. (#2277)
Solution: Update the tests to work with BigchainDB 2.* and enable them back.
2018-05-15 11:19:47 +02:00
..
assets Problem: Asset tests are disabled. (#2277) 2018-05-15 11:19:47 +02:00
backend Problem: No crash recovery mechanism (#2207) 2018-04-18 10:46:16 +02:00
commands Merge branch 'alpha-3' 2018-05-02 16:35:49 +02:00
common Problem: to get tx utxoset & inputs is cumbersome (#2055) 2018-02-15 18:23:29 +01:00
db Fixes #1891 2017-12-05 19:38:52 +01:00
log Fix code coverage 2017-10-23 10:20:56 +05:30
tendermint Problem: Invalid transaction posted to Tendermint (#2270) 2018-05-09 13:41:22 +02:00
validation changed constructed/allowed tx 'version' from '1.0' to '2.0' (#2048) 2018-02-15 11:07:16 +01:00
web Problem: Invalid transaction posted to Tendermint (#2270) 2018-05-09 13:41:22 +02:00
__init__.py Add code, have fun! 2016-02-10 19:55:33 +01:00
conftest.py Problem: Asset tests are disabled. (#2277) 2018-05-15 11:19:47 +02:00
README.md Problem: standardize docker-compose workflows (#2130) 2018-03-21 12:42:43 +01:00
test_block_model.py Fixes #1891 2017-12-05 19:38:52 +01:00
test_config_utils.py Problem: statsd config is no longer supported 2018-02-13 14:35:47 +01:00
test_consensus.py fix tests, temporarily disabling some tests that need to be re-written 2017-02-23 21:53:12 +01:00
test_core.py Problem: statsd config is no longer supported 2018-02-13 14:35:47 +01:00
test_docs.py add test to make sure documentation can build 2016-11-30 16:41:24 +01:00
test_events.py Problem: Exchange can fail silently (#2177) 2018-04-05 13:57:07 +02:00
test_fastquery.py Fixes #1891 2017-12-05 19:38:52 +01:00
test_txlist.py Pre commit styling (#1914) 2017-11-30 15:04:14 +01:00
test_utils.py Problem: Bigchaindb startup sometimes fails due genesis block creation during init (#2129) 2018-03-16 16:19:12 +01:00
test_voting.py Pre commit styling (#1914) 2017-11-30 15:04:14 +01:00
utils.py Problem: Changing validators requires a network restart (#2070) 2018-03-29 18:25:26 +02:00

BigchainDB Server Tests

The tests/ Folder

The tests/ folder is where all the tests for BigchainDB Server live. Most of them are unit tests. Integration tests are in the tests/integration/ folder.

A few notes:

Writing Tests

We write unit and integration tests for our Python code using the pytest framework. You can use the tests in the tests/ folder as templates or examples.

Running Tests

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 has instructions for how to do that.

Next, make sure you have Local MongoDB running in the background. You can run MongoDB using mongod.

The pytest command has many options. If you want to learn about all the things you can do with pytest, see the pytest documentation. We've also added a customization to pytest:

--database-backend: Defines the backend to use for the tests. It defaults to localmongodb.

Now you can run all tests using:

pytest -v

or, if that doesn't work, try:

python -m pytest -v

or:

python setup.py test

How does python setup.py test work? The documentation for 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. We've also added a customization to pytest:

Running Tests with Docker Compose

You can also use Docker Compose to run all the tests.

First, bring up all the services BigchainDB, MongoDB, Tendermint in the background:

$ docker-compose up -d bdb

then run the tests using:

$ docker-compose run --rm --no-deps bigchaindb pytest -v

Automated Testing of All Pull Requests

We use Travis CI, so that whenever someone creates a new BigchainDB pull request on GitHub, Travis CI gets the new code and does a bunch of stuff. We use the same docker-compose.yml for tests. It tells Travis CI how to install BigchainDB, how to run all the tests, and what to do "after success" (e.g. run codecov). (We use Codecov to get a rough estimate of our test coverage.)

Tox

We use tox to run multiple suites of tests against multiple environments during automated testing. Generally you don't need to run this yourself, but it might be useful when troubleshooting a failing Travis CI build.

To run all the tox tests, use:

tox

or:

python -m tox

To run only a few environments, use the -e flag:

tox -e {ENVLIST}

where {ENVLIST} is one or more of the environments specified in the tox.ini file.