Skip to content

Commit 6fc1ff9

Browse files
author
Ed Costello
committed
Merge pull request #574 from epc/master
draft port of the smoke tests doc from the wiki.
2 parents a2a56e5 + 1ad775b commit 6fc1ff9

File tree

1 file changed

+166
-0
lines changed

1 file changed

+166
-0
lines changed

draft/smoke-tests.txt

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
===========
2+
Smoke Tests
3+
===========
4+
5+
6+
Test Organization
7+
-----------------
8+
9+
# :file:`dbtests/.*cpp` has C++ unit tests
10+
# :file:`jstests/*.js` has core tests
11+
# :file:`jstests/repl*/*.js` has replication tests
12+
# :file:`jstests/sharding/*.js` has sharding tests
13+
# :file:`slowNightly/*js` has tests that take longer and run only at night
14+
# :file:`slowWeekly/*.js` has tests that take even longer and run only once a week
15+
16+
Running all the tests
17+
---------------------
18+
19+
.. code-block:: sh
20+
21+
scons smoke smokeCppUnittests smokeDisk smokeTool smokeAuth startMongod smokeClient smokeJs
22+
scons startMongodSmallOplog smokeJs
23+
scons startMongod smokeJsSlowNightly
24+
scons smokeTool
25+
scons smokeReplSets
26+
scons smokeDur
27+
scons mongosTest smokeSharding
28+
scons smokeRepl smokeClone
29+
scons startMongod smokeParallel
30+
31+
smoke.py
32+
--------
33+
34+
:file:`smoke.py` lets you run a subsets of the tests in :file:`jstests/`.
35+
When it is running tests, it starts up an instance of mongod, runs the tests,
36+
and then shuts it down again.
37+
You can run it while running other instances of MongoDB on the same machine:
38+
it uses ports in the 30000 range and its own data directories.
39+
40+
For the moment, :file:`smoke.py` must be run from the top-level directory
41+
of a MongoDB source repository.
42+
This directory must contain at least the :program:`mongo` and
43+
:program:`mongod` binaries.
44+
To run certain tests, you'll also need to build the tools and :program:`mongos`.
45+
It's a good idea to run ``scons .`` before running the tests.
46+
47+
To run :file:`smoke.py` you'll need a recent version of
48+
`PyMongo <http://api.mongodb.org/python/current/installation.html>`_.
49+
50+
To see the possible options, run:
51+
52+
.. code-block:: sh
53+
54+
$ python buildscripts/smoke.py --help
55+
Usage: smoke.py [OPTIONS] ARGS*
56+
57+
Options:
58+
-h, --help show this help message and exit
59+
--mode=MODE If "files", ARGS are filenames; if "suite", ARGS are
60+
sets of tests (suite)
61+
--test-path=TEST_PATH
62+
Path to the test executables to run, currently only
63+
used for 'client' (none)
64+
--mongod=MONGOD_EXECUTABLE
65+
Path to mongod to run (/Users/mike/10gen/mongo/mongod)
66+
--port=MONGOD_PORT Port the mongod will bind to (32000)
67+
--mongo=SHELL_EXECUTABLE
68+
Path to mongo, for .js test files
69+
(/Users/mike/10gen/mongo/mongo)
70+
--continue-on-failure
71+
If supplied, continue testing even after a test fails
72+
--from-file=FILE Run tests/suites named in FILE, one test per line, '-'
73+
means stdin
74+
--smoke-db-prefix=SMOKE_DB_PREFIX
75+
Prefix to use for the mongods' dbpaths ('')
76+
--small-oplog Run tests with master/slave replication & use a small
77+
oplog
78+
79+
80+
.. note::
81+
82+
By default, :file:`smoke.py` will run tests that create data in :file:`/data/db`,
83+
which may interfere with other MongoDB instances you are running.
84+
To change the directory in which the smoke tests create databases, use
85+
``--smoke-db-prefix=/some/other/path``
86+
87+
To run specific tests, use the :option:`--mode=files` option:
88+
89+
.. code-block:: sh
90+
91+
python buildscripts/smoke.py --mode=files jstests/find1.js
92+
93+
You can specify as many files as you want.
94+
95+
You can also run a suite of tests. Suites are predefined and include:
96+
97+
* _test_
98+
* _all_
99+
* _perf_
100+
* _js_
101+
* _quota_
102+
* _jsPerf_
103+
* _disk_
104+
* _jsSlowNightly_
105+
* _jsSlowWeekly_
106+
* _parallel_
107+
* _clone_
108+
* _repl_ (master/slave replication tests)
109+
* _replSets_ (replica set tests)
110+
* _auth_
111+
* _sharding_
112+
* _tool_
113+
* _client_
114+
* _mongosTest_
115+
116+
To run a suite, specify the suite's name:
117+
118+
.. code-block::
119+
120+
python buildscripts/smoke.py js
121+
122+
123+
Running a jstest manually
124+
-------------------------
125+
126+
You can run a jstest directly from the shell, for example:
127+
128+
.. code-block:: sh
129+
130+
mongo --nodb jstests/replsets/replsetarb3.js
131+
132+
Running the C++ unit tests
133+
--------------------------
134+
135+
The tests under jstests/ folder are written in mongo shell javascript.
136+
However there are a set of C++ unit tests also. To run them:
137+
138+
.. code-block:: sh
139+
140+
scons test
141+
./test
142+
143+
144+
Build the unit tests (in src/mongo/unittest/ by running:
145+
146+
.. code-block:: sh
147+
148+
$ scons build/unittests.txt
149+
/* build output */
150+
Generating build/unittests.txt
151+
build/linux2/dd/durableDefaultOff/mongo/platform/atomic_word_test
152+
...
153+
build/linux2/dd/durableDefaultOff/mongo/bson_template_evaluator_test
154+
build/linux2/dd/durableDefaultOff/mongo/balancer_policy_test
155+
scons: done building targets.
156+
157+
Then use the line above to run the binary generated:
158+
159+
.. code-block:: sh
160+
161+
$ ./build/linux2/dd/durableDefaultOff/mongo/platform/atomic_word_test
162+
163+
164+
.. see-also::
165+
166+
* `scons <http://www.scons.org/>`_

0 commit comments

Comments
 (0)