-
Notifications
You must be signed in to change notification settings - Fork 97
Testing
This document describes how to run the tests we know how to run.
The tests in src/mongo/dbtests are unit tests that create a binary named test
.
You can build it with scons test
and run it with ./test
. It needs write access to /tmp/unittest
which is a pain.
You can build and run it with scons smoke
.
There are also some unit tests you can run with scons smokeCppUnittests
but they are not very numerous, they are either very new or have been abandoned.
The tests in jstests are tests that get run through the mongo
shell against a running mongod
server.
You need python 2.6 and pymongo installed to use the smoke.py
driver. To install pymongo, you can check out mongo-python-driver and run python2.6 setup.py --with-c-ext install --user
.
To run them all, build everything (scons .
at the top of the repo) and run buildscripts/smoke.py on the js
suite:
mongo $ mkdir -p smoke
mongo $ python2.6 buildscripts/smoke.py --smoke-db-prefix=smoke --continue-on-failure --quiet js
You can also run individual tests by starting a server (in gdb
if you want) and executing the javascript file with the mongo
shell:
mongo $ nohup ./mongod --logpath=mongod.log --port NNNNN &
mongo $ ./mongo --port NNNNN jstests/foo_test.js
Or, you can paste the javascript into the shell line-by-line.
If you check out mongo-python-driver, you can run its test suite against a running mongod
server, replica set, or sharded cluster.
mongo-python-driver $ python2.6 setup.py test
-OR-
mongo-python-driver $ nosetests # if you have nose installed
The environment variables DB_IP
(default 127.0.0.1
) and DB_PORT
(default 27017
) determine with which server the python tests try to communicate, so you can run tests on another machine this way.
If you check out mongo-ruby-driver, you can run its test suite against a running mongod
server, replica set, or sharded cluster.
First, you may need to install some gems as dependencies, then run rake test
:
mongo-ruby-driver $ gem install bundler
mongo-ruby-driver $ bundle install # uses bundler to install dependencies
mongo-ruby-driver $ rake test
The environment variables MONGO_RUBY_DRIVER_HOST
(default localhost
) and MONGO_RUBY_DRIVER_PORT
(default 27017
) determine with which server the ruby tests try to communicate, so you can run tests on another machine this way.
If you check out mongo-java-driver, you can run its test suite against a running mongod
server, replica set, or sharded cluster.
You will need to install maven, then run mvn test
, which will take care of downloading dependencies for you:
mongo-java-driver $ mvn test
If you check out mongo-perl-driver, you can run its test suite against a running mongod
server, replica set, or sharded cluster.
You will need to install Dist::Zilla
(the best way on CentOS is with perlbrew
and cpanm
), then run dzil authordeps | cpanm
and dzil listdeps | cpanm
to install dependencies. Then run tests with dzil test
:
mongo-perl-driver $ dzil authordeps | cpanm
mongo-perl-driver $ dzil listdeps | cpanm
mongo-perl-driver $ dzil test
The environment variable MONGOD
determines with which server the perl tests try to communicate, so you can run tests on another machine this way (though some tests will be skipped unless the mongod is localhost).
Installing Dist::Zilla
can be rough on CentOS 5. You should install perlbrew
, use that to install cpanm
and a modern perl, and then install Dist::Zilla
with that cpanm
. You may need a more modern OpenSSL (if you get undefined references to SSL_CTX_set1_param
), in that case you can install OpenSSL from source, and then specify OPENSSL_PREFIX
and LD_RUN_PATH
when you invoke cpanm
.