Skip to content

Commit be11f80

Browse files
committed
Merge branch '1.2.0-dev'
* 1.2.0-dev: (557 commits) CDRIVER-696 fix test when server isn't on 27017 Ignore stray files/changes in submodules CDRIVER-901 document bulk write error domains CDRIVER-901 update bson_error_t from write concern err CDRIVER-907 crash retrieving invalid server description MONGOC_TEST_FUTURE_TIMEOUT_MS environment variable Update documentation for wtimeout_msec write concern params Fix parameter indentation for mongoc_write_concern_set_wtimeout() CDRIVER-851: Negative wtimeout values are invalid Skip test on mongos (mongos returns indiviaul shards status) CDRIVER-902: Bump libbson to 1.2.0-dev so Solaris build work again CDRIVER-888: inprog, killop & unlock are commands now, not queries CDRIVER-822 clean generated HTML docs/man pages Fix expectations on windows CDRIVER-900: Print debug error messaging to stderr post-release bump 1.2.0-rc0 Release CDRIVER-697 no bson_return calls in tests merge 1.1.11 release notes NEWS file layout ...
2 parents df4d1f3 + 413e60c commit be11f80

File tree

328 files changed

+31609
-7683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

328 files changed

+31609
-7683
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ autom4te.cache
77
bulk1
88
bulk2
99
bulk3
10+
bulk4
1011
ChangeLog
1112
cluster1
1213
*.cmake
@@ -69,6 +70,7 @@ test-mongoc-client-pool
6970
test-mongoc-collection
7071
test-mongoc-cursor
7172
test-mongoc-database
73+
test-mongoc-exhaust
7274
test-mongoc-event
7375
test-mongoc-gridfs
7476
test-mongoc-gridfs-file-page

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[submodule "src/libbson"]
22
path = src/libbson
33
url = https://github.com/mongodb/libbson.git
4+
ignore = dirty

.mci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ c_driver_variables:
100100
mongo_orchestration:
101101
windows: &mongo_orchestration_windows
102102
start_mongo_orchestration: |
103-
trap 'set +o errexit; mongo-orchestration stop;' EXIT
103+
trap 'set +o errexit; cat server.log; mongo-orchestration stop;' EXIT
104104
taskkill.exe /FI "IMAGENAME eq python.exe" /F
105105
taskkill.exe /FI "IMAGENAME eq mongod.exe" /F
106106
fsutil volume diskfree c:
@@ -111,7 +111,7 @@ c_driver_variables:
111111
curl -s http://localhost:8889/
112112
unix: &mongo_orchestration_unix
113113
start_mongo_orchestration: |
114-
trap 'set +o errexit; mongo-orchestration stop;' EXIT
114+
trap 'set +o errexit; cat server.log; mongo-orchestration stop;' EXIT
115115
df -h
116116
echo "Starting Mongo Orchestration..."
117117
echo "{ \"releases\": { \"default\": \"`pwd`/mongodb/bin\" } }" > orchestration.config
@@ -408,6 +408,7 @@ post:
408408
params:
409409
working_dir: "mongo-c-driver"
410410
script: |
411+
cat server.log
411412
mongo-orchestration stop
412413
- command: shell.cleanup
413414

CMakeLists.txt

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,45 @@ cmake_minimum_required(VERSION 2.8)
22

33
project (libmongoc)
44

5+
option(SEARCH_OPEN_SSL "SEARCH_OPEN_SSL" ON)
6+
57
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/build/cmake)
68

79
include(InstallRequiredSystemLibraries)
8-
include(FindOpenSSL)
10+
11+
if (SEARCH_OPEN_SSL)
12+
include(FindOpenSSL)
13+
endif ()
914

1015
include(FindBSON REQUIRED)
16+
include(FindSASL2)
1117

1218
set (SOURCE_DIR "${PROJECT_SOURCE_DIR}/")
1319

1420
set (MONGOC_MAJOR_VERSION 1)
15-
set (MONGOC_MINOR_VERSION 1)
16-
set (MONGOC_MICRO_VERSION 11)
17-
set (MONGOC_PRERELEASE_VERSION )
21+
set (MONGOC_MINOR_VERSION 2)
22+
set (MONGOC_MICRO_VERSION 0)
23+
set (MONGOC_PRERELEASE_VERSION dev)
1824
set (MONGOC_API_VERSION 1.0)
19-
set (MONGOC_VERSION 1.1.11)
25+
set (MONGOC_VERSION 1.2.0-dev)
2026

2127
set (CPACK_RESOURCE_FILE_LICENSE "${SOURCE_DIR}/COPYING")
2228
set (CPACK_PACKAGE_VERSION_MAJOR ${MONGOC_MAJOR_VERSION})
2329
set (CPACK_PACKAGE_VERSION_MINOR ${MONGOC_MINOR_VERSION})
2430

2531
include (CPack)
2632

27-
if (OPENSSL_FOUND)
33+
if (SEARCH_OPEN_SSL AND OPENSSL_FOUND)
2834
set (MONGOC_ENABLE_SSL 1)
2935
else()
3036
set (MONGOC_ENABLE_SSL 0)
3137
endif ()
3238

33-
set (MONGOC_ENABLE_SASL 0)
39+
if (SASL2_FOUND)
40+
set (MONGOC_ENABLE_SASL 1)
41+
else()
42+
set (MONGOC_ENABLE_SASL 0)
43+
endif ()
3444
set (MONGOC_HAVE_SASL_CLIENT_DONE 0)
3545

3646
configure_file (
@@ -60,9 +70,17 @@ endif()
6070
add_definitions(-D_GNU_SOURCE)
6171
add_definitions(-D_BSD_SOURCE)
6272
add_definitions("-DBINARY_DIR=\"${SOURCE_DIR}/tests/binary\"")
73+
if (APPLE)
74+
# Until CDRIVER-520.
75+
add_definitions(-Wno-deprecated-declarations)
76+
endif()
6377

6478
set (SOURCES
6579
${SOURCE_DIR}/src/mongoc/mongoc-array.c
80+
${SOURCE_DIR}/src/mongoc/mongoc-async.c
81+
${SOURCE_DIR}/src/mongoc/mongoc-async-cmd.c
82+
${SOURCE_DIR}/src/mongoc/mongoc-b64.c
83+
${SOURCE_DIR}/src/mongoc/mongoc-buffer.c
6684
${SOURCE_DIR}/src/mongoc/mongoc-bulk-operation.c
6785
${SOURCE_DIR}/src/mongoc/mongoc-buffer.c
6886
${SOURCE_DIR}/src/mongoc/mongoc-b64.c
@@ -71,6 +89,7 @@ set (SOURCES
7189
${SOURCE_DIR}/src/mongoc/mongoc-cluster.c
7290
${SOURCE_DIR}/src/mongoc/mongoc-collection.c
7391
${SOURCE_DIR}/src/mongoc/mongoc-counters.c
92+
${SOURCE_DIR}/src/mongoc/mongoc-cursor-array.c
7493
${SOURCE_DIR}/src/mongoc/mongoc-cursor.c
7594
${SOURCE_DIR}/src/mongoc/mongoc-cursor-array.c
7695
${SOURCE_DIR}/src/mongoc/mongoc-cursor-cursorid.c
@@ -79,24 +98,35 @@ set (SOURCES
7998
${SOURCE_DIR}/src/mongoc/mongoc-init.c
8099
${SOURCE_DIR}/src/mongoc/mongoc-gridfs.c
81100
${SOURCE_DIR}/src/mongoc/mongoc-gridfs-file.c
101+
${SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-list.c
82102
${SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-page.c
83103
${SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-list.c
104+
${SOURCE_DIR}/src/mongoc/mongoc-host-list.c
84105
${SOURCE_DIR}/src/mongoc/mongoc-index.c
106+
${SOURCE_DIR}/src/mongoc/mongoc-init.c
85107
${SOURCE_DIR}/src/mongoc/mongoc-list.c
86108
${SOURCE_DIR}/src/mongoc/mongoc-log.c
87109
${SOURCE_DIR}/src/mongoc/mongoc-matcher.c
88110
${SOURCE_DIR}/src/mongoc/mongoc-matcher-op.c
111+
${SOURCE_DIR}/src/mongoc/mongoc-opcode.c
89112
${SOURCE_DIR}/src/mongoc/mongoc-queue.c
90113
${SOURCE_DIR}/src/mongoc/mongoc-read-prefs.c
91114
${SOURCE_DIR}/src/mongoc/mongoc-rpc.c
115+
${SOURCE_DIR}/src/mongoc/mongoc-server-description.c
116+
${SOURCE_DIR}/src/mongoc/mongoc-set.c
92117
${SOURCE_DIR}/src/mongoc/mongoc-socket.c
118+
${SOURCE_DIR}/src/mongoc/mongoc-stream-buffered.c
93119
${SOURCE_DIR}/src/mongoc/mongoc-stream.c
94120
${SOURCE_DIR}/src/mongoc/mongoc-stream-buffered.c
95121
${SOURCE_DIR}/src/mongoc/mongoc-stream-file.c
96122
${SOURCE_DIR}/src/mongoc/mongoc-stream-gridfs.c
97123
${SOURCE_DIR}/src/mongoc/mongoc-stream-socket.c
124+
${SOURCE_DIR}/src/mongoc/mongoc-topology.c
125+
${SOURCE_DIR}/src/mongoc/mongoc-topology-description.c
126+
${SOURCE_DIR}/src/mongoc/mongoc-topology-scanner.c
98127
${SOURCE_DIR}/src/mongoc/mongoc-uri.c
99128
${SOURCE_DIR}/src/mongoc/mongoc-util.c
129+
${SOURCE_DIR}/src/mongoc/mongoc-version-functions.c
100130
${SOURCE_DIR}/src/mongoc/mongoc-write-command.c
101131
${SOURCE_DIR}/src/mongoc/mongoc-write-concern.c
102132
)
@@ -124,7 +154,9 @@ set (HEADERS
124154
${SOURCE_DIR}/src/mongoc/mongoc-log.h
125155
${SOURCE_DIR}/src/mongoc/mongoc-matcher.h
126156
${SOURCE_DIR}/src/mongoc/mongoc-opcode.h
157+
${SOURCE_DIR}/src/mongoc/mongoc-opcode-private.h
127158
${SOURCE_DIR}/src/mongoc/mongoc-read-prefs.h
159+
${SOURCE_DIR}/src/mongoc/mongoc-server-description.h
128160
${SOURCE_DIR}/src/mongoc/mongoc-socket.h
129161
${SOURCE_DIR}/src/mongoc/mongoc-socket-private.h
130162
${SOURCE_DIR}/src/mongoc/mongoc-stream.h
@@ -133,6 +165,7 @@ set (HEADERS
133165
${SOURCE_DIR}/src/mongoc/mongoc-stream-gridfs.h
134166
${SOURCE_DIR}/src/mongoc/mongoc-stream-socket.h
135167
${SOURCE_DIR}/src/mongoc/mongoc-uri.h
168+
${SOURCE_DIR}/src/mongoc/mongoc-version-functions.h
136169
${SOURCE_DIR}/src/mongoc/mongoc-write-concern.h
137170
)
138171

@@ -151,6 +184,13 @@ if (OPENSSL_FOUND)
151184
include_directories(${OPENSSL_INCLUDE_DIR})
152185
endif()
153186

187+
if (SASL2_FOUND)
188+
set (HEADERS ${HEADERS} ${SOURCE_DIR}/src/mongoc/mongoc-sasl-private.h)
189+
set (SOURCES ${SOURCES} ${SOURCE_DIR}/src/mongoc/mongoc-sasl.c)
190+
set(LIBS ${LIBS} ${SASL2_LIBRARY})
191+
include_directories(${SASL2_INCLUDE_DIR})
192+
endif()
193+
154194
if (MSVC)
155195
if (OPENSSL_FOUND)
156196
set(MONGOC_SHARED_SOURCES ${SOURCES} ${PROJECT_SOURCE_DIR}/build/cmake/libmongoc-ssl.def)
@@ -205,35 +245,58 @@ function(mongoc_add_example example use_shared)
205245
endfunction()
206246

207247
set(test-libmongoc-sources
248+
${SOURCE_DIR}/tests/debug-stream.c
208249
${SOURCE_DIR}/tests/ha-test.c
250+
${SOURCE_DIR}/tests/json-test.c
251+
${SOURCE_DIR}/tests/mock_server/future.c
252+
${SOURCE_DIR}/tests/mock_server/future-functions.c
253+
${SOURCE_DIR}/tests/mock_server/future-value.c
254+
${SOURCE_DIR}/tests/mock_server/sync-queue.c
255+
${SOURCE_DIR}/tests/mock_server/mock-rs.c
256+
${SOURCE_DIR}/tests/mock_server/mock-server.c
257+
${SOURCE_DIR}/tests/mock_server/request.c
258+
${SOURCE_DIR}/tests/test-conveniences.c
259+
${SOURCE_DIR}/tests/test-bulk.c
209260
${SOURCE_DIR}/tests/test-libmongoc.c
210261
${SOURCE_DIR}/tests/test-mongoc-array.c
262+
${SOURCE_DIR}/tests/test-mongoc-async.c
211263
${SOURCE_DIR}/tests/test-mongoc-buffer.c
212264
${SOURCE_DIR}/tests/test-mongoc-client.c
213-
${SOURCE_DIR}/tests/mock-server.c
214265
${SOURCE_DIR}/tests/test-bulk.c
215266
${SOURCE_DIR}/tests/test-mongoc-client-pool.c
216267
${SOURCE_DIR}/tests/test-mongoc-cluster.c
217268
${SOURCE_DIR}/tests/test-mongoc-collection.c
218269
${SOURCE_DIR}/tests/test-mongoc-cursor.c
219270
${SOURCE_DIR}/tests/test-mongoc-database.c
271+
${SOURCE_DIR}/tests/test-mongoc-exhaust.c
220272
${SOURCE_DIR}/tests/test-mongoc-gridfs.c
221273
${SOURCE_DIR}/tests/test-mongoc-gridfs-file-page.c
222274
${SOURCE_DIR}/tests/test-mongoc-list.c
275+
${SOURCE_DIR}/tests/test-mongoc-log.c
223276
${SOURCE_DIR}/tests/test-mongoc-matcher.c
224277
${SOURCE_DIR}/tests/test-mongoc-queue.c
225278
${SOURCE_DIR}/tests/test-mongoc-read-prefs.c
226279
${SOURCE_DIR}/tests/test-mongoc-rpc.c
280+
${SOURCE_DIR}/tests/test-mongoc-sdam.c
281+
${SOURCE_DIR}/tests/test-mongoc-server-selection.c
282+
${SOURCE_DIR}/tests/test-mongoc-server-selection-errors.c
283+
${SOURCE_DIR}/tests/test-mongoc-set.c
227284
${SOURCE_DIR}/tests/test-mongoc-socket.c
228285
${SOURCE_DIR}/tests/test-mongoc-stream.c
286+
${SOURCE_DIR}/tests/test-mongoc-thread.c
287+
${SOURCE_DIR}/tests/test-mongoc-topology.c
288+
${SOURCE_DIR}/tests/test-mongoc-topology-reconcile.c
289+
${SOURCE_DIR}/tests/test-mongoc-topology-scanner.c
229290
${SOURCE_DIR}/tests/test-mongoc-uri.c
291+
${SOURCE_DIR}/tests/test-mongoc-version.c
292+
${SOURCE_DIR}/tests/test-mongoc-usleep.c
230293
${SOURCE_DIR}/tests/test-mongoc-write-concern.c
231294
${SOURCE_DIR}/tests/test-sasl.c
232295
${SOURCE_DIR}/tests/test-write-commands.c
233296
${SOURCE_DIR}/tests/TestSuite.c
234297
)
235298

236-
if (OPENSSL_FOUND)
299+
if (SEARCH_OPEN_SSL AND OPENSSL_FOUND)
237300
set(test-libmongoc-sources ${test-libmongoc-sources}
238301
${SOURCE_DIR}/tests/test-x509.c
239302
${SOURCE_DIR}/tests/ssl-test.c

CONTRIBUTING.md

Lines changed: 88 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,62 @@ generate man pages and HTML for it.
115115

116116
### Testing
117117

118-
You should always run `make test` before submitting a patch. Just make sure you
119-
have a locally running `mongod` instance available on `127.0.0.1:27017`. All
120-
tests should pass. Alternatively, you can specify `MONGOC_TEST_HOST`
121-
environment variable to specify a non-localhost hostname or ip address.
122-
123-
To test with auth, create a "root" user on the "admin" database and set the
124-
`MONGOC_TEST_USER` and `MONGOC_TEST_PASSWORD` environment variables to its
125-
username and password.
126-
127-
Set the `MONGOC_TEST_SSL` environment variable `on` to connect to the server via
128-
SSL with default options. Configure SSL options with paths
129-
`MONGOC_TEST_SSL_PEM_FILE`, `MONGOC_TEST_SSL_PEM_PWD`,
130-
`MONGOC_TEST_SSL_CA_FILE`, `MONGOC_TEST_SSL_CA_DIR`, and
131-
`MONGOC_TEST_SSL_CRL_FILE`. Set the `MONGOC_TEST_SSL_WEAK_CERT_VALIDATION`
132-
environment variable `on` to relax server certificate validation.
118+
To run the entire test suite, including authentication tests,
119+
start `mongod` with auth enabled:
120+
121+
```
122+
$ mongod --auth
123+
```
124+
125+
In another terminal, use the `mongo` shell to create a user:
126+
127+
```
128+
$ mongo --eval "db.createUser({user: 'admin', pwd: 'pass', roles: ['root']})" admin
129+
```
130+
131+
To authenticate against MongoDB 3.0+ requires SCRAM-SHA-1, which in turn
132+
requires a driver built with OpenSSL:
133+
134+
```
135+
$ ./configure --enable-ssl`
136+
```
137+
138+
Set the user and password environment variables, then build and run the tests:
139+
140+
```
141+
$ export MONGOC_TEST_USER=admin
142+
$ export MONGOC_TEST_PASSWORD=pass
143+
$ make test
144+
```
145+
146+
Additional environment variables:
147+
148+
* `MONGOC_TEST_HOST`: default `localhost`, the host running MongoDB.
149+
* `MONGOC_TEST_PORT`: default 27017, MongoDB's listening port.
150+
* `MONGOC_TEST_SERVER_VERBOSE`: set to `on` for wire protocol logging from
151+
tests that use `mock_server_t`.
152+
153+
If you start `mongod` with SSL, set these variables to configure how
154+
`make test` connects to it:
155+
156+
* `MONGOC_TEST_SSL`: set to `on` to connect to the server with SSL.
157+
* `MONGOC_TEST_SSL_PEM_FILE`: path to a client PEM file.
158+
* `MONGOC_TEST_SSL_PEM_PWD`: the PEM file's password.
159+
* `MONGOC_TEST_SSL_CA_FILE`: path to a certificate authority file.
160+
* `MONGOC_TEST_SSL_CA_DIR`: path to a certificate authority directory.
161+
* `MONGOC_TEST_SSL_CRL_FILE`: path to a certificate revocation list.
162+
* `MONGOC_TEST_SSL_WEAK_CERT_VALIDATION`: set to `on` to relax the client's
163+
validation of the server's certificate.
164+
165+
The SASL / GSSAPI / Kerberos tests are skipped by default. To run them, set up a
166+
separate `mongod` with Kerberos and set its host and Kerberos principal name
167+
as environment variables:
168+
169+
* `MONGOC_TEST_GSSAPI_HOST`
170+
* `MONGOC_TEST_GSSAPI_USER`
171+
172+
URI-escape the username, for example write "user@realm" as "user%40realm".
173+
The user must be authorized to query `test.collection`.
133174

134175
The SASL / GSSAPI / Kerberos tests are skipped by default. To run them, set up a
135176
separate `mongod` with Kerberos and set its host and Kerberos principal name
@@ -143,3 +184,35 @@ The user must be authorized to query `test.collection`.
143184

144185
All tests should pass before submitting a patch.
145186

187+
## Configuring the test runner
188+
189+
The test runner can be configured by declaring the `TEST_ARGS` environment
190+
variable. The following options can be provided:
191+
192+
```
193+
-h, --help Show this help menu.
194+
-f Do not fork() before running tests.
195+
-l NAME Run test by name, e.g. "/Client/command" or "/Client/*".
196+
-p Do not run tests in parallel.
197+
-v Be verbose with logs.
198+
```
199+
200+
`TEST_ARGS` is set to "-f -p" by default.
201+
202+
To run just a specific portion of the test suite use the -l option like so:
203+
204+
```
205+
$ make test TEST_ARGS="-l /server_selection/*"
206+
```
207+
208+
The full list of tests is shown in the help.
209+
210+
## Debugging failed tests
211+
212+
The easiest way to debug a failed tests is to use the `debug` make target:
213+
214+
```
215+
$ make debug TEST_ARGS="-l /WriteConcern/bson_omits_defaults"
216+
```
217+
218+
This will build all dependencies and leave you in a debugger ready to run the test.

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ endif
2929
include build/cmake/Makefile.am
3030

3131
ACLOCAL_AMFLAGS = -I build/autotools/m4 ${ACLOCAL_FLAGS}
32-
DISTCHECK_CONFIGURE_FLAGS = --enable-silent-rules --enable-man-pages --enable-html-doc --enable-sasl --enable-ssl --enable-maintainer-flags --enable-debug --with-libbson=bundled
32+
DISTCHECK_CONFIGURE_FLAGS = --enable-silent-rules --enable-man-pages --enable-html-docs --enable-sasl --enable-ssl --enable-maintainer-flags --enable-debug --with-libbson=bundled
3333

3434
mongocdocdir = ${docdir}
3535
mongocdoc_DATA = \

0 commit comments

Comments
 (0)