Smoke Tests

Test Organization

  1. dbtests/.*cpp has C++ unit tests
  2. jstests/*.js has core tests
  3. jstests/repl*/*.js has replication tests
  4. jstests/sharding/*.js has sharding tests
  5. slowNightly/*js has tests that take longer and run only at night
  6. slowWeekly/*.js has tests that take even longer and run only once a week

Running all the tests

scons smoke smokeDisk smokeTool smokeAuth startMongod smokeClient smokeJs
scons startMongodSmallOplog smokeJs
scons startMongod smokeJsSlowNightly
scons smokeTool
scons smokeReplSets
scons smokeDur
scons mongosTest smokeSharding
scons smokeRepl smokeClone
scons startMongod smokeParallel

smoke.py

smoke.py lets you run a subsets of the tests in jstests/. When it is running tests, it starts up an instance of mongod, runs the tests, and then shuts it down again. You can run it while running other instances of MongoDB on the same machine: it uses ports in the 30000 range and its own data directories.

For the moment, smoke.py must be run from the top-level directory of a MongoDB source repository. This directory must contain at least the mongo and mongod binaries. To run certain tests, you'll also need to build the tools and mongos. It's a good idea to run scons . before running the tests.

To run smoke.py you'll need a recent version of PyMongo.

To see the possible options, run:

$ python buildscripts/smoke.py --help
Usage: smoke.py [OPTIONS] ARGS*

Options:
  -h, --help            show this help message and exit
  --mode=MODE           If "files", ARGS are filenames; if "suite", ARGS are
                        sets of tests (suite)
  --test-path=TEST_PATH
                        Path to the test executables to run, currently only
                        used for 'client' (none)
  --mongod=MONGOD_EXECUTABLE
                        Path to mongod to run (/Users/mike/10gen/mongo/mongod)
  --port=MONGOD_PORT    Port the mongod will bind to (32000)
  --mongo=SHELL_EXECUTABLE
                        Path to mongo, for .js test files
                        (/Users/mike/10gen/mongo/mongo)
  --continue-on-failure
                        If supplied, continue testing even after a test fails
  --from-file=FILE      Run tests/suites named in FILE, one test per line, '-'
                        means stdin
  --smoke-db-prefix=SMOKE_DB_PREFIX
                        Prefix to use for the mongods' dbpaths ('')
  --small-oplog         Run tests with master/slave replication & use a small
                        oplog
By default, smoke.py will run tests that create data in /data/db, which may interfere with other MongoDB instances you are running. To change the directory in which the smoke tests create databases, use --smoke-db-prefix=/some/other/path

To run specific tests, use the --mode=files option:

python buildscripts/smoke.py --mode=files jstests/find1.js

You can specify as many files as you want.

You can also run a suite of tests. Suites are predefined and include:

  • test
  • all
  • perf
  • js
  • quota
  • jsPerf
  • disk
  • jsSlowNightly
  • jsSlowWeekly
  • parallel
  • clone
  • repl (master/slave replication tests)
  • replSets (replica set tests)
  • auth
  • sharding
  • tool
  • client
  • mongosTest

To run a suite, specify the suite's name:

python buildscripts/smoke.py js

Running a jstest manually

You can run a jstest directly from the shell, for example:

mongo --nodb jstests/replsets/replsetarb3.js

Running the C++ unit tests

The tests under jstests/ folder are written in mongo shell javascript. However there are a set of C++ unit tests also. To run them:

scons test
./test

See Also

Follow @mongodb

MongoDB Pittsburgh - May 15
MongoNYC - May 23
MongoDB Paris - Jun 14
MongoDB UK - Jun 20
MongoDC - June 26


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.

blog comments powered by Disqus