mongo 2.8.0 → 2.9.0.rc0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Rakefile +12 -0
- data/lib/mongo.rb +15 -1
- data/lib/mongo/address/ipv6.rb +0 -2
- data/lib/mongo/auth/scram/conversation.rb +0 -3
- data/lib/mongo/bulk_write/result_combiner.rb +12 -2
- data/lib/mongo/client.rb +59 -6
- data/lib/mongo/cluster.rb +19 -8
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +0 -2
- data/lib/mongo/cluster/reapers/socket_reaper.rb +12 -9
- data/lib/mongo/collection.rb +1 -1
- data/lib/mongo/collection/view/aggregation.rb +5 -1
- data/lib/mongo/collection/view/builder/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +30 -10
- data/lib/mongo/collection/view/iterable.rb +13 -6
- data/lib/mongo/collection/view/map_reduce.rb +12 -10
- data/lib/mongo/collection/view/readable.rb +19 -14
- data/lib/mongo/cursor.rb +12 -8
- data/lib/mongo/database.rb +10 -7
- data/lib/mongo/database/view.rb +18 -11
- data/lib/mongo/error.rb +2 -2
- data/lib/mongo/error/connection_check_out_timeout.rb +49 -0
- data/lib/mongo/error/operation_failure.rb +9 -9
- data/lib/mongo/error/parser.rb +25 -3
- data/lib/mongo/error/pool_closed_error.rb +43 -0
- data/lib/mongo/error/sdam_error_detection.rb +18 -0
- data/lib/mongo/grid/file/chunk.rb +0 -2
- data/lib/mongo/grid/fs_bucket.rb +26 -12
- data/lib/mongo/grid/stream/read.rb +36 -21
- data/lib/mongo/index/view.rb +11 -7
- data/lib/mongo/logger.rb +0 -2
- data/lib/mongo/monitoring.rb +31 -0
- data/lib/mongo/monitoring/cmap_log_subscriber.rb +53 -0
- data/lib/mongo/monitoring/event.rb +1 -0
- data/lib/mongo/monitoring/event/cmap.rb +25 -0
- data/lib/mongo/monitoring/event/cmap/base.rb +28 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +78 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_started.rb +56 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +63 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +64 -0
- data/lib/mongo/monitoring/event/cmap/connection_closed.rb +103 -0
- data/lib/mongo/monitoring/event/cmap/connection_created.rb +64 -0
- data/lib/mongo/monitoring/event/cmap/connection_ready.rb +64 -0
- data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +57 -0
- data/lib/mongo/monitoring/event/cmap/pool_closed.rb +57 -0
- data/lib/mongo/monitoring/event/cmap/pool_created.rb +63 -0
- data/lib/mongo/monitoring/event/command_started.rb +12 -3
- data/lib/mongo/monitoring/publishable.rb +10 -2
- data/lib/mongo/operation.rb +0 -1
- data/lib/mongo/operation/find/legacy/result.rb +1 -0
- data/lib/mongo/operation/list_collections/result.rb +7 -1
- data/lib/mongo/operation/result.rb +10 -1
- data/lib/mongo/operation/shared/executable.rb +15 -0
- data/lib/mongo/operation/shared/result/use_legacy_error_parser.rb +29 -0
- data/lib/mongo/operation/shared/specifiable.rb +0 -16
- data/lib/mongo/operation/update/legacy/result.rb +1 -0
- data/lib/mongo/protocol/compressed.rb +0 -2
- data/lib/mongo/protocol/msg.rb +25 -2
- data/lib/mongo/retryable.rb +171 -33
- data/lib/mongo/server.rb +26 -7
- data/lib/mongo/server/app_metadata.rb +0 -2
- data/lib/mongo/server/connectable.rb +8 -2
- data/lib/mongo/server/connection.rb +83 -13
- data/lib/mongo/server/connection_base.rb +1 -1
- data/lib/mongo/server/connection_pool.rb +439 -43
- data/lib/mongo/server/monitor/connection.rb +4 -1
- data/lib/mongo/session.rb +37 -5
- data/lib/mongo/session/session_pool.rb +2 -2
- data/lib/mongo/socket.rb +0 -2
- data/lib/mongo/socket/ssl.rb +0 -2
- data/lib/mongo/uri.rb +127 -66
- data/lib/mongo/uri/srv_protocol.rb +35 -13
- data/lib/mongo/version.rb +1 -1
- data/spec/README.md +190 -63
- data/spec/integration/change_stream_spec.rb +64 -0
- data/spec/integration/command_spec.rb +0 -7
- data/spec/integration/error_detection_spec.rb +39 -0
- data/spec/integration/read_concern.rb +83 -0
- data/spec/integration/retryable_writes_spec.rb +6 -50
- data/spec/integration/sdam_error_handling_spec.rb +60 -7
- data/spec/integration/ssl_uri_options_spec.rb +24 -0
- data/spec/integration/step_down_spec.rb +197 -0
- data/spec/lite_spec_helper.rb +4 -0
- data/spec/mongo/client_construction_spec.rb +42 -17
- data/spec/mongo/client_spec.rb +32 -1
- data/spec/mongo/cluster/socket_reaper_spec.rb +2 -2
- data/spec/mongo/cluster_spec.rb +36 -2
- data/spec/mongo/collection/view/aggregation_spec.rb +2 -0
- data/spec/mongo/collection/view/change_stream_spec.rb +28 -28
- data/spec/mongo/collection/view/readable_spec.rb +1 -1
- data/spec/mongo/collection/view_spec.rb +3 -1
- data/spec/mongo/cursor_spec.rb +5 -5
- data/spec/mongo/error/parser_spec.rb +61 -1
- data/spec/mongo/grid/stream/read_spec.rb +2 -2
- data/spec/mongo/monitoring/event/cmap/connection_check_out_failed_spec.rb +23 -0
- data/spec/mongo/monitoring/event/cmap/connection_check_out_started_spec.rb +19 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_in_spec.rb +23 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_out_spec.rb +23 -0
- data/spec/mongo/monitoring/event/cmap/connection_closed_spec.rb +27 -0
- data/spec/mongo/monitoring/event/cmap/connection_created_spec.rb +24 -0
- data/spec/mongo/monitoring/event/cmap/connection_ready_spec.rb +24 -0
- data/spec/mongo/monitoring/event/cmap/pool_cleared_spec.rb +19 -0
- data/spec/mongo/monitoring/event/cmap/pool_closed_spec.rb +19 -0
- data/spec/mongo/monitoring/event/cmap/pool_created_spec.rb +26 -0
- data/spec/mongo/operation/delete/bulk_spec.rb +1 -6
- data/spec/mongo/operation/delete/command_spec.rb +1 -1
- data/spec/mongo/operation/delete/op_msg_spec.rb +1 -1
- data/spec/mongo/operation/delete_spec.rb +4 -4
- data/spec/mongo/operation/insert/bulk_spec.rb +1 -1
- data/spec/mongo/operation/insert/command_spec.rb +1 -1
- data/spec/mongo/operation/insert/op_msg_spec.rb +1 -1
- data/spec/mongo/operation/update/bulk_spec.rb +1 -1
- data/spec/mongo/operation/update/command_spec.rb +2 -2
- data/spec/mongo/operation/update/op_msg_spec.rb +2 -2
- data/spec/mongo/protocol/msg_spec.rb +11 -0
- data/spec/mongo/retryable_spec.rb +78 -25
- data/spec/mongo/server/connection_pool_spec.rb +661 -126
- data/spec/mongo/server/connection_spec.rb +55 -7
- data/spec/mongo/server_spec.rb +5 -0
- data/spec/mongo/uri/srv_protocol_spec.rb +135 -2
- data/spec/mongo/uri_option_parsing_spec.rb +511 -0
- data/spec/mongo/uri_spec.rb +42 -6
- data/spec/spec_helper.rb +1 -84
- data/spec/spec_tests/cmap_spec.rb +50 -0
- data/spec/spec_tests/command_monitoring_spec.rb +7 -18
- data/spec/spec_tests/crud_spec.rb +3 -49
- data/spec/spec_tests/data/cmap/connection-must-have-id.yml +21 -0
- data/spec/spec_tests/data/cmap/connection-must-order-ids.yml +21 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-closed.yml +24 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-stale.yml +24 -0
- data/spec/spec_tests/data/cmap/pool-checkin-make-available.yml +21 -0
- data/spec/spec_tests/data/cmap/pool-checkin.yml +18 -0
- data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +13 -0
- data/spec/spec_tests/data/cmap/pool-checkout-error-closed.yml +28 -0
- data/spec/spec_tests/data/cmap/pool-checkout-multiple.yml +34 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-idle.yml +31 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-stale.yml +29 -0
- data/spec/spec_tests/data/cmap/pool-close-destroy-conns.yml +26 -0
- data/spec/spec_tests/data/cmap/pool-close.yml +11 -0
- data/spec/spec_tests/data/cmap/pool-create-max-size.yml +56 -0
- data/spec/spec_tests/data/cmap/pool-create-min-size.yml +27 -0
- data/spec/spec_tests/data/cmap/pool-create-with-options.yml +20 -0
- data/spec/spec_tests/data/cmap/pool-create.yml +12 -0
- data/spec/spec_tests/data/cmap/wait-queue-fairness.yml +94 -0
- data/spec/spec_tests/data/cmap/wait-queue-timeout.yml +41 -0
- data/spec/spec_tests/data/retryable_reads/aggregate-serverErrors.yml +157 -0
- data/spec/spec_tests/data/retryable_reads/aggregate.yml +87 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +149 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +61 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +149 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +65 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +153 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +61 -0
- data/spec/spec_tests/data/retryable_reads/count-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/count.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/countDocuments-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/countDocuments.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/distinct-serverErrors.yml +156 -0
- data/spec/spec_tests/data/retryable_reads/distinct.yml +71 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors.yml +148 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount.yml +62 -0
- data/spec/spec_tests/data/retryable_reads/find-serverErrors.yml +160 -0
- data/spec/spec_tests/data/retryable_reads/find.yml +86 -0
- data/spec/spec_tests/data/retryable_reads/findOne-serverErrors.yml +154 -0
- data/spec/spec_tests/data/retryable_reads/findOne.yml +68 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-download-serverErrors.yml +173 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-download.yml +79 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName-serverErrors.yml +174 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName.yml +79 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionNames-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionNames.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listCollections-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listCollections.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabases-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listDatabases.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/listIndexes-serverErrors.yml +145 -0
- data/spec/spec_tests/data/retryable_reads/listIndexes.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/mapReduce.yml +60 -0
- data/spec/spec_tests/data/retryable_writes/bulkWrite-serverErrors.yml +10 -7
- data/spec/spec_tests/data/retryable_writes/bulkWrite.yml +15 -22
- data/spec/spec_tests/data/retryable_writes/deleteMany.yml +22 -0
- data/spec/spec_tests/data/retryable_writes/deleteOne-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/deleteOne.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/insertMany-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/insertMany.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +10 -45
- data/spec/spec_tests/data/retryable_writes/insertOne.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/replaceOne-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/replaceOne.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/updateMany.yml +27 -0
- data/spec/spec_tests/data/retryable_writes/updateOne-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/updateOne.yml +5 -14
- data/spec/spec_tests/data/transactions/abort.yml +7 -2
- data/spec/spec_tests/data/transactions/bulk.yml +7 -2
- data/spec/spec_tests/data/transactions/causal-consistency.yml +11 -4
- data/spec/spec_tests/data/transactions/commit.yml +11 -4
- data/spec/spec_tests/data/transactions/count.yml +64 -0
- data/spec/spec_tests/data/transactions/delete.yml +7 -2
- data/spec/spec_tests/data/transactions/error-labels.yml +8 -2
- data/spec/spec_tests/data/transactions/errors.yml +7 -2
- data/spec/spec_tests/data/transactions/findOneAndDelete.yml +7 -2
- data/spec/spec_tests/data/transactions/findOneAndReplace.yml +7 -2
- data/spec/spec_tests/data/transactions/findOneAndUpdate.yml +7 -2
- data/spec/spec_tests/data/transactions/insert.yml +9 -2
- data/spec/spec_tests/data/transactions/isolation.yml +7 -2
- data/spec/spec_tests/data/transactions/read-concern.yml +15 -6
- data/spec/spec_tests/data/transactions/read-pref.yml +7 -2
- data/spec/spec_tests/data/transactions/reads.yml +8 -48
- data/spec/spec_tests/data/transactions/retryable-abort.yml +7 -2
- data/spec/spec_tests/data/transactions/retryable-commit.yml +7 -2
- data/spec/spec_tests/data/transactions/retryable-writes.yml +7 -2
- data/spec/spec_tests/data/transactions/run-command.yml +7 -2
- data/spec/spec_tests/data/transactions/transaction-options.yml +7 -2
- data/spec/spec_tests/data/transactions/update.yml +7 -2
- data/spec/spec_tests/data/transactions/write-concern.yml +7 -2
- data/spec/spec_tests/data/transactions_api/callback-aborts.yml +6 -1
- data/spec/spec_tests/data/transactions_api/callback-commits.yml +6 -1
- data/spec/spec_tests/data/transactions_api/callback-retry.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit-retry.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +6 -3
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit.yml +6 -1
- data/spec/spec_tests/data/transactions_api/transaction-options.yml +6 -1
- data/spec/spec_tests/retryable_reads_spec.rb +11 -0
- data/spec/spec_tests/retryable_writes_spec.rb +4 -69
- data/spec/spec_tests/transactions_api_spec.rb +42 -37
- data/spec/spec_tests/transactions_spec.rb +42 -33
- data/spec/support/authorization.rb +12 -0
- data/spec/support/change_streams/operation.rb +1 -1
- data/spec/support/client_registry.rb +20 -0
- data/spec/support/cluster_config.rb +16 -15
- data/spec/support/cluster_tools.rb +346 -0
- data/spec/support/cmap.rb +367 -0
- data/spec/support/cmap/verifier.rb +46 -0
- data/spec/support/command_monitoring.rb +4 -6
- data/spec/support/common_shortcuts.rb +6 -0
- data/spec/support/connection_string.rb +2 -2
- data/spec/support/crud.rb +171 -184
- data/spec/support/crud/operation.rb +43 -0
- data/spec/support/crud/outcome.rb +53 -0
- data/spec/support/crud/read.rb +102 -12
- data/spec/support/crud/requirement.rb +69 -0
- data/spec/support/crud/spec.rb +68 -0
- data/spec/support/crud/test.rb +141 -0
- data/spec/support/crud/verifier.rb +96 -18
- data/spec/support/crud/write.rb +18 -3
- data/spec/support/event_subscriber.rb +15 -0
- data/spec/support/primary_socket.rb +2 -2
- data/spec/support/spec_config.rb +89 -20
- data/spec/support/transactions.rb +2 -306
- data/spec/support/transactions/operation.rb +7 -7
- data/spec/support/transactions/spec.rb +28 -0
- data/spec/support/transactions/test.rb +191 -0
- data/spec/support/utils.rb +123 -0
- metadata +202 -9
- metadata.gz.sig +0 -0
- data/lib/mongo/server/connection_pool/queue.rb +0 -359
- data/spec/mongo/server/connection_pool/queue_spec.rb +0 -353
- data/spec/support/transactions/verifier.rb +0 -97
data/lib/mongo/version.rb
CHANGED
data/spec/README.md
CHANGED
@@ -1,85 +1,212 @@
|
|
1
|
-
|
2
|
-
configured and started externally to the test suite. This allows
|
3
|
-
running the entire test suite against, for example, a standalone
|
4
|
-
mongod as well as a replica set. The flip side to this is the
|
5
|
-
test suite will not work without a running mongo cluster, and
|
6
|
-
tests which are not applicable to or cannot be performed on the
|
7
|
-
running mongo cluster are skipped.
|
1
|
+
# Running Ruby Driver Tests
|
8
2
|
|
9
|
-
|
10
|
-
the test suite must also be told how the cluster is configured
|
11
|
-
via MONGODB_URI, TOPOLOGY, MONGODB_ADDRESSES, RS_ENABLED, RS_NAME and/or
|
12
|
-
SHARDED_ENABLED environment variables.
|
3
|
+
## Quick Start
|
13
4
|
|
14
|
-
|
15
|
-
|
5
|
+
To run the test suite against a local MongoDB deployment listening on port
|
6
|
+
27017, run:
|
16
7
|
|
17
|
-
|
18
|
-
MONGODB_URI or MONGODB_ADDRESSES) encompasses all servers in the cluster,
|
19
|
-
and will fail when MONGODB_URI includes only one host of a replica set.
|
20
|
-
It is best to include all hosts of the cluster in MONGODB_URI and
|
21
|
-
MONGODB_ADDRESSES.
|
8
|
+
rake
|
22
9
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
on server discovery.
|
10
|
+
When run without options, the test suite will automatically detect deployment
|
11
|
+
topology and configure itself appropriately. Standalone, replica set and
|
12
|
+
sharded cluster topologies are supported (though the test suite will presently
|
13
|
+
use only the first listed shard in a sharded cluster if given a seed list,
|
14
|
+
or the one running on port 27017 if not given a seed list).
|
29
15
|
|
30
|
-
|
31
|
-
|
32
|
-
|
16
|
+
TLS, authentication and other options can be configured via URI options by
|
17
|
+
setting `MONGODB_URI` environment variable appropriately. Examples of such
|
18
|
+
configuration are given later in this document.
|
33
19
|
|
34
|
-
|
20
|
+
## MongoDB Server Deployment
|
35
21
|
|
36
|
-
|
22
|
+
The tests require a running MongoDB deployment, configured and started
|
23
|
+
externally to the test suite. Tests that are not appropriate for the running
|
24
|
+
deployment will be skipped.
|
37
25
|
|
38
|
-
|
26
|
+
## Starting MongoDB Deployment
|
39
27
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
There are many ways in which MongoDB can be started. The instructions below
|
29
|
+
are for manually launching `mongod` instances and using
|
30
|
+
[mlaunch](http://blog.rueckstiess.com/mtools/mlaunch.html)
|
31
|
+
(part of [mtools](https://github.com/rueckstiess/mtools)) for more complex
|
32
|
+
deployments, but other tools like
|
33
|
+
[mongodb-runner](https://github.com/mongodb-js/runner) and
|
34
|
+
[Mongo Orchestration](https://github.com/10gen/mongo-orchestration) can
|
35
|
+
in principle also work.
|
45
36
|
|
46
|
-
|
47
|
-
MONGODB_URI=mongodb://127.0.0.1:27001,127.0.0.1:27002/ TOPOLOGY=sharded_cluster
|
37
|
+
### Standalone
|
48
38
|
|
49
|
-
|
50
|
-
|
39
|
+
The simplest possible deployment is a standalone `mongod`, which can be
|
40
|
+
launched as follows:
|
51
41
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
# Launch mongod in one terminal
|
43
|
+
mkdir /tmp/mdb
|
44
|
+
mongod --dbpath /tmp/mdb
|
45
|
+
|
46
|
+
# Run tests in another terminal
|
47
|
+
rake
|
56
48
|
|
57
|
-
|
58
|
-
|
59
|
-
replica set with MONGODB_URI, specify the replica set name in the URI
|
60
|
-
(despite the Ruby driver performing topology discovery by default, it
|
61
|
-
doesn't do so in the test suite).
|
62
|
-
RS_NAME can be given to specify the replica set name; the default is
|
63
|
-
ruby-driver-rs.
|
49
|
+
A standalone deployment is a good starting point, however a great many tests
|
50
|
+
require a replica set deployment and will be skipped on a standalone deployment.
|
64
51
|
|
65
|
-
|
66
|
-
RS_ENABLED=1 RS_NAME=test
|
52
|
+
### Replica Set
|
67
53
|
|
68
|
-
|
69
|
-
|
54
|
+
While a replica set can be started and configured by hand, doing so is
|
55
|
+
cumbersome. The examples below use
|
56
|
+
[mlaunch](http://blog.rueckstiess.com/mtools/mlaunch.html)
|
57
|
+
to start a replica set.
|
70
58
|
|
71
|
-
|
59
|
+
First, install [mtools](https://github.com/rueckstiess/mtools):
|
72
60
|
|
73
|
-
|
61
|
+
pip install mtools --user
|
62
|
+
export PATH=~/.local/bin:$PATH
|
63
|
+
|
64
|
+
Then, launch a replica set:
|
74
65
|
|
75
|
-
|
76
|
-
|
77
|
-
SSL=ssl
|
66
|
+
mlaunch init --replicaset --name ruby-driver-rs \
|
67
|
+
--dir /tmp/mdb-rs --setParameter enableTestCommands=1
|
78
68
|
|
79
|
-
|
69
|
+
The test suite willl automatically detect the topology, no explicit
|
70
|
+
configuration is needed:
|
80
71
|
|
81
|
-
|
82
|
-
|
83
|
-
|
72
|
+
rake
|
73
|
+
|
74
|
+
### Sharded Cluster
|
75
|
+
|
76
|
+
A sharded cluster can be configured with mlaunch:
|
77
|
+
|
78
|
+
mlaunch init --replicaset --name ruby-driver-rs --sharded 1 \
|
79
|
+
--dir /tmp/mdb-sc --setParameter enableTestCommands=1
|
80
|
+
|
81
|
+
As with the replica set, the test suite will automatically detect sharded
|
82
|
+
cluster topology.
|
83
|
+
|
84
|
+
## TLS With Verification
|
85
|
+
|
86
|
+
The test suite includes a set of TLS certificates for configuring a server
|
87
|
+
and a client to perform full TLS verification. The server can be started as
|
88
|
+
follows, if the current directory is the top of the driver source tree:
|
89
|
+
|
90
|
+
mlaunch init --single --dir /tmp/mdb-ssl --sslMode requireSSL \
|
91
|
+
--sslPEMKeyFile `pwd`/spec/support/certificates/server.pem \
|
92
|
+
--sslCAFile `pwd`/spec/support/certificates/ca.pem \
|
93
|
+
--sslClientCertificate `pwd`/spec/support/certificates/client.pem
|
94
|
+
|
95
|
+
## TLS Without Verification
|
96
|
+
|
97
|
+
It is also possible to enable TLS but omit certificate verification. In this
|
98
|
+
case a standalone server can be started as follows:
|
99
|
+
|
100
|
+
mlaunch init --single --dir /tmp/mdb-ssl --sslMode requireSSL \
|
101
|
+
--sslPEMKeyFile `pwd`/spec/support/certificates/server.pem \
|
102
|
+
--sslCAFile `pwd`/spec/support/certificates/ca.pem \
|
103
|
+
--sslAllowConnectionsWithoutCertificates \
|
104
|
+
--sslAllowInvalidCertificates
|
105
|
+
|
106
|
+
To run the test suite against such a server, also omitting certificate
|
107
|
+
verification, run:
|
108
|
+
|
109
|
+
MONGODB_URI='mongodb://localhost:27017/?tls=true&tlsInsecure=true' rake
|
110
|
+
|
111
|
+
## Authentication
|
112
|
+
|
113
|
+
mlaunch can configure authentication on the server:
|
114
|
+
|
115
|
+
mlaunch init --single --dir /tmp/mdb-auth --auth --username dev --password dev
|
116
|
+
|
117
|
+
To run the test suite against such a server, run:
|
118
|
+
|
119
|
+
MONGODB_URI='mongodb://dev:dev@localhost:27017/' rake
|
120
|
+
|
121
|
+
## Compression
|
122
|
+
|
123
|
+
To be written.
|
124
|
+
|
125
|
+
## Other Options
|
126
|
+
|
127
|
+
Generally, all URI options recognized by the driver may be set for a test run,
|
128
|
+
and will cause the clients created by the test suite to have those options
|
129
|
+
by default. For example, retryable writes may be turned on and off as follows:
|
130
|
+
|
131
|
+
MONGODB_URI='mongodb://localhost:27017/?retryWrites=true' rake
|
132
|
+
|
133
|
+
MONGODB_URI='mongodb://localhost:27017/?retryWrites=false' rake
|
134
|
+
|
135
|
+
Individual tests may override options that the test suite uses as defaults.
|
136
|
+
For example, retryable writes tests may create clients with the retry writes
|
137
|
+
option set to true or false as needed regardless of what the default is for
|
138
|
+
the entire test run.
|
139
|
+
|
140
|
+
It is also possible to, for example, reference non-default hosts and replica
|
141
|
+
set names:
|
142
|
+
|
143
|
+
MONGODB_URI='mongodb://test.host:27017,test.host:27018/?replicaSet=fooset' rake
|
144
|
+
|
145
|
+
However, as noted in the caveats section, changing the database name used by
|
146
|
+
the test suite is not supported.
|
147
|
+
|
148
|
+
Some tests require internet connectivity, for example to test DNS seed lists
|
149
|
+
and SRV URIs. These tests can be skipped by setting the following environment
|
150
|
+
variable:
|
84
151
|
|
85
152
|
EXTERNAL_DISABLED=true
|
153
|
+
|
154
|
+
## Caveats
|
155
|
+
|
156
|
+
### Socket Permission Errors
|
157
|
+
|
158
|
+
If you get permission errors connecting to `mongod`'s socket, adjust its
|
159
|
+
permissions:
|
160
|
+
|
161
|
+
sudo chmod 0666 /tmp/mongodb-27017.sock
|
162
|
+
|
163
|
+
### Non-Identical Hostnames
|
164
|
+
|
165
|
+
The test suite should be configured to connect to exactly the hostnames
|
166
|
+
configured in the cluster. If, for example, the test suite is configured
|
167
|
+
to use IP addresses but the cluster is configured with hostnames, most tests
|
168
|
+
would still work (by using SDAM to discover correct cluster configuration)
|
169
|
+
but will spend a significant amount of extra time on server discovery.
|
170
|
+
|
171
|
+
Some tests perform address assertions and will fail if hostnames configured
|
172
|
+
in the test suite do not match hostnames configured in the cluster.
|
173
|
+
For the same reason, each node in server configuration should have its port
|
174
|
+
specified.
|
175
|
+
|
176
|
+
### Database Name
|
177
|
+
|
178
|
+
The test suite currently does not allow changing the database name that it
|
179
|
+
uses, which is `ruby-driver`. Attempts to specify a different database name
|
180
|
+
in the URI for example will lead to some of the tests failing.
|
181
|
+
|
182
|
+
### Fail Points
|
183
|
+
|
184
|
+
In order to run some of the tests, the mongo cluster needs to have fail points
|
185
|
+
enabled. This is accomplished by starting `mongod` with the following option:
|
186
|
+
|
187
|
+
--setParameter enableTestCommands=1
|
188
|
+
|
189
|
+
### Log Output
|
190
|
+
|
191
|
+
The test suite is run with the driver log level set to WARN by default.
|
192
|
+
This produces a fair amount of output as many tests trigger various conditions
|
193
|
+
resulting in the driver outputting warnings. This is expected behavior.
|
194
|
+
|
195
|
+
## Running Individual Examples
|
196
|
+
|
197
|
+
Individual examples can be run by invoking `rspec` instead of `rake`. Prior
|
198
|
+
to running `rspec`, ensure the test suite created users for itself - this
|
199
|
+
is done by the `rake` command automatically, or you can manually invoke the
|
200
|
+
Rake task which configures the deployment for testing:
|
201
|
+
|
202
|
+
rake spec:prepare
|
203
|
+
|
204
|
+
Then, any of the standard RSpec invocations will work:
|
205
|
+
|
206
|
+
rspec path/to/file_spec.rb
|
207
|
+
|
208
|
+
## Configuration Reporting
|
209
|
+
|
210
|
+
To have the test suite report its current configuration, run:
|
211
|
+
|
212
|
+
rake spec:config
|
@@ -366,4 +366,68 @@ describe 'Change stream integration', retry: 4 do
|
|
366
366
|
end.to raise_error(ArgumentError, 'Time must be a Time or a BSON::Timestamp instance')
|
367
367
|
end
|
368
368
|
end
|
369
|
+
|
370
|
+
describe ':start_after option' do
|
371
|
+
require_topology :replica_set
|
372
|
+
min_server_version '4.1'
|
373
|
+
|
374
|
+
let(:start_after) do
|
375
|
+
stream = authorized_collection.watch([])
|
376
|
+
authorized_collection.insert_one(x: 1)
|
377
|
+
start_after = stream.to_enum.next['_id']
|
378
|
+
end
|
379
|
+
|
380
|
+
let(:stream) do
|
381
|
+
authorized_collection.watch([], { start_after: start_after })
|
382
|
+
end
|
383
|
+
|
384
|
+
let(:events) do
|
385
|
+
start_after
|
386
|
+
|
387
|
+
subscriber = EventSubscriber.new
|
388
|
+
authorized_client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
389
|
+
use_stream
|
390
|
+
|
391
|
+
subscriber.started_events.select { |e| e.command_name == 'aggregate' }
|
392
|
+
end
|
393
|
+
|
394
|
+
context 'when an initial aggregation is run' do
|
395
|
+
let(:use_stream) do
|
396
|
+
stream
|
397
|
+
end
|
398
|
+
|
399
|
+
it 'sends startAfter' do
|
400
|
+
expect(events.size >= 1).to eq(true)
|
401
|
+
|
402
|
+
command = events.first.command
|
403
|
+
expect(command['pipeline'].size == 1).to eq(true)
|
404
|
+
expect(command['pipeline'].first.key?('$changeStream')).to eq(true)
|
405
|
+
expect(command['pipeline'].first['$changeStream'].key?('startAfter')).to eq(true)
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
context 'when resuming' do
|
410
|
+
let(:use_stream) do
|
411
|
+
stream
|
412
|
+
|
413
|
+
authorized_collection.insert_one(x: 1)
|
414
|
+
stream.to_enum.next
|
415
|
+
|
416
|
+
authorized_collection.insert_one(x: 1)
|
417
|
+
authorized_collection.client.use(:admin).command(fail_point_base_command.merge(
|
418
|
+
:mode => {:times => 1},
|
419
|
+
:data => {:failCommands => ['getMore'], errorCode: 100}))
|
420
|
+
stream.to_enum.next
|
421
|
+
end
|
422
|
+
|
423
|
+
it 'does not startAfter even when passed in' do
|
424
|
+
expect(events.size == 2).to eq(true)
|
425
|
+
|
426
|
+
command = events.last.command
|
427
|
+
expect(command['pipeline'].size == 1).to eq(true)
|
428
|
+
expect(command['pipeline'].first.key?('$changeStream')).to eq(true)
|
429
|
+
expect(command['pipeline'].first['$changeStream'].key?('startAfter')).to eq(false)
|
430
|
+
end
|
431
|
+
end
|
432
|
+
end
|
369
433
|
end
|
@@ -62,12 +62,6 @@ describe 'Command' do
|
|
62
62
|
min_server_fcv '3.6'
|
63
63
|
|
64
64
|
let(:session) { authorized_client.start_session }
|
65
|
-
# w will be 2 for a RS topology with 3 nodes
|
66
|
-
let(:w) do
|
67
|
-
authorized_client.write_concern.options[:w].tap do |w|
|
68
|
-
expect(w).to be_a(Integer)
|
69
|
-
end
|
70
|
-
end
|
71
65
|
|
72
66
|
let(:expected_payload) do
|
73
67
|
{
|
@@ -75,7 +69,6 @@ describe 'Command' do
|
|
75
69
|
'commitTransaction' => 1,
|
76
70
|
'lsid' => session.session_id,
|
77
71
|
'txnNumber' => BSON::Int64.new(123),
|
78
|
-
'writeConcern' => {'w' => w},
|
79
72
|
},
|
80
73
|
'command_name' => 'commitTransaction',
|
81
74
|
'database_name' => 'admin',
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Error detection' do
|
4
|
+
context 'document contains a not master/node recovering code' do
|
5
|
+
let(:document) { {code: 91} }
|
6
|
+
|
7
|
+
let(:coll) { authorized_client_without_any_retries['error-detection'] }
|
8
|
+
|
9
|
+
before do
|
10
|
+
coll.delete_many
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'cursors not used' do
|
14
|
+
|
15
|
+
before do
|
16
|
+
coll.insert_one(document)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'is not treated as an error when retrieved' do
|
20
|
+
actual = coll.find.first
|
21
|
+
expect(actual['code']).to eq(91)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'cursors used' do
|
26
|
+
|
27
|
+
before do
|
28
|
+
10.times do
|
29
|
+
coll.insert_one(document)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'is not treated as an error when retrieved' do
|
34
|
+
actual = coll.find({}, batch_size: 2).first
|
35
|
+
expect(actual['code']).to eq(91)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'read concern' do
|
4
|
+
let(:subscriber) do
|
5
|
+
EventSubscriber.new
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:specified_read_concern) do
|
9
|
+
{ 'level' => 'local' }
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:sent_read_concern) do
|
13
|
+
subscriber.clear_events!
|
14
|
+
collection.count_documents({})
|
15
|
+
subscriber.started_events.find { |c| c.command_name == 'aggregate' }.command[:readConcern]
|
16
|
+
end
|
17
|
+
|
18
|
+
shared_examples_for 'a read concern is specified' do
|
19
|
+
it 'sends a read concern to the server' do
|
20
|
+
expect(sent_read_concern).to eq(specified_read_concern)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
shared_examples_for 'no read concern is specified' do
|
25
|
+
it 'does not send a read concern to the server' do
|
26
|
+
expect(sent_read_concern).to be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when the client has no read concern specified' do
|
31
|
+
|
32
|
+
let(:client) do
|
33
|
+
authorized_client.tap do |client|
|
34
|
+
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when the collection has no read concern specified' do
|
39
|
+
|
40
|
+
let(:collection) do
|
41
|
+
client[TEST_COLL]
|
42
|
+
end
|
43
|
+
|
44
|
+
it_behaves_like 'no read concern is specified'
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when the collection has a read concern specified' do
|
48
|
+
|
49
|
+
let(:collection) do
|
50
|
+
client[TEST_COLL].with(read_concern: specified_read_concern)
|
51
|
+
end
|
52
|
+
|
53
|
+
it_behaves_like 'a read concern is specified'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when the client has a read concern specified' do
|
58
|
+
|
59
|
+
let(:client) do
|
60
|
+
authorized_client.with(read_concern: specified_read_concern).tap do |client|
|
61
|
+
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when the collection has no read concern specified' do
|
66
|
+
|
67
|
+
let(:collection) do
|
68
|
+
client[TEST_COLL]
|
69
|
+
end
|
70
|
+
|
71
|
+
it_behaves_like 'a read concern is specified'
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when the collection has a read concern specified' do
|
75
|
+
|
76
|
+
let(:collection) do
|
77
|
+
client[TEST_COLL].with(read_concern: specified_read_concern)
|
78
|
+
end
|
79
|
+
|
80
|
+
it_behaves_like 'a read concern is specified'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|