bigchaindb/tests
kansi a2ed03dabc Merge branch 'master' into bug/1813/retract-cmd-bigchaindb-flag 2017-11-09 15:41:40 +05:30
..
assets Remove condition details signature, rename subfulfillments to subconditions (#1589) 2017-06-30 09:44:22 +02:00
backend Unique index for bigchain collection, fixed test case 2017-11-01 21:23:06 +05:30
commands Fix tests 2017-11-07 15:41:55 +05:30
common Refine the condition uri regex for validation 2017-07-03 15:08:47 +02:00
db Integrate cryptoconditions version 02 2017-06-22 14:56:22 +02:00
integration Merge branch 'master' into bug/1813/retract-cmd-bigchaindb-flag 2017-11-09 15:41:40 +05:30
log Fix code coverage 2017-10-23 10:20:56 +05:30
pipelines Rename things, add tests 2017-08-09 10:51:30 +02:00
validation Remove condition details signature, rename subfulfillments to subconditions (#1589) 2017-06-30 09:44:22 +02:00
web Merge branch 'master' into bug/1670/asset-language-api-fix 2017-11-03 11:38:09 +05:30
README.md Added note about 'make clean-pyc' 2017-11-07 14:24:33 +01:00
__init__.py Add code, have fun! 2016-02-10 19:55:33 +01:00
conftest.py Bypass CI issues for rethinkdb (#1821) 2017-11-08 19:41:17 +01:00
test_block_model.py fixed typos 2017-05-24 17:05:43 +02:00
test_config_utils.py Provide log server port as config paramter 2017-10-23 09:17:58 +05:30
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 Rename unspent -> spent in outputs endpoint 2017-06-16 10:31:46 +02:00
test_docs.py add test to make sure documentation can build 2016-11-30 16:41:24 +01:00
test_events.py Add more coverage 2017-08-09 16:23:03 +02:00
test_fastquery.py Rename unspent -> spent in outputs endpoint 2017-06-16 10:31:46 +02:00
test_processes.py Rename things, add tests 2017-08-09 10:51:30 +02:00
test_txlist.py fix flake8 2017-01-18 17:13:38 +01:00
test_utils.py Fix flake8 ambiguous variable "l" issue 2017-10-23 18:06:11 +05:30
test_voting.py use patch instead of subclassing 2017-04-13 11:38:17 +02:00
utils.py Fixed tests. 2017-05-11 12:00:01 +02:00

README.md

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 RethinkDB or MongoDB running in the background. You can run RethinkDB using rethinkdb --daemon or MongoDB using mongod --replSet=bigchain-rs. If you wish to test with a TLS/SSL enabled MongoDB, use the command

mongod --replSet=bigchain-rs --sslAllowInvalidHostnames --sslMode=requireSSL \
-sslCAFile=bigchaindb/tests/backend/mongodb-ssl/certs/ca.crt \
--sslCRLFile=bigchaindb/tests/backend/mongodb-ssl/certs/crl.pem \
--sslPEMKeyFile=bigchaindb/tests/backend/mongodb-ssl/certs/test_mdb_ssl_cert_and_key.pem

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 rethinkdb It must be one of the backends available in the server configuration.

Now you can run all tests using:

py.test -v

or, if that doesn't work, try:

python -m pytest -v

or:

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. If you wish to run tests against a TLS/SSL enabled MongoDB instance (as mentioned above), use the command

pytest -v --database-backend=mongodb-ssl -m bdb_ssl

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.

With MongoDB as the backend

First, start MongoDB in the background:

$ docker-compose up -d mdb

then run the tests using:

$ 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 being able to run the tests. Run:

$ docker-compose build

With RethinkDB as the backend

First, start RethinkDB in the background:

$ docker-compose -f docker-compose.rdb.yml up -d rdb

then run the tests using:

$ docker-compose -f docker-compose.rdb.yml run --rm bdb-rdb py.test -v

to rebuild all the images (usually you only need to rebuild the bdb and bdb-rdb images). If that fails, then do make clean-pyc and try again.

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. You can find out what we tell Travis CI to do in the .travis.yml file: 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.