mongo 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +3 -3
  5. data/lib/mongo/client.rb +16 -7
  6. data/lib/mongo/cluster.rb +9 -4
  7. data/lib/mongo/cluster/cursor_reaper.rb +1 -0
  8. data/lib/mongo/cluster/topology.rb +1 -1
  9. data/lib/mongo/collection.rb +0 -3
  10. data/lib/mongo/collection/view.rb +12 -5
  11. data/lib/mongo/collection/view/builder/find_command.rb +2 -2
  12. data/lib/mongo/collection/view/readable.rb +4 -4
  13. data/lib/mongo/collection/view/writable.rb +12 -10
  14. data/lib/mongo/cursor.rb +1 -0
  15. data/lib/mongo/error.rb +1 -0
  16. data/lib/mongo/error/invalid_min_pool_size.rb +35 -0
  17. data/lib/mongo/error/operation_failure.rb +24 -5
  18. data/lib/mongo/operation/write/bulk/update/result.rb +1 -10
  19. data/lib/mongo/operation/write/update/result.rb +26 -7
  20. data/lib/mongo/retryable.rb +30 -35
  21. data/lib/mongo/socket.rb +1 -1
  22. data/lib/mongo/socket/tcp.rb +1 -0
  23. data/lib/mongo/version.rb +1 -1
  24. data/spec/mongo/bulk_write_spec.rb +113 -43
  25. data/spec/mongo/client_spec.rb +253 -0
  26. data/spec/mongo/cluster/topology_spec.rb +37 -0
  27. data/spec/mongo/cluster_spec.rb +1 -1
  28. data/spec/mongo/collection/view/aggregation_spec.rb +2 -2
  29. data/spec/mongo/collection/view/map_reduce_spec.rb +1 -1
  30. data/spec/mongo/collection_spec.rb +55 -19
  31. data/spec/mongo/command_monitoring_spec.rb +1 -1
  32. data/spec/mongo/database_spec.rb +5 -5
  33. data/spec/mongo/grid/stream/write_spec.rb +2 -2
  34. data/spec/mongo/index/view_spec.rb +5 -5
  35. data/spec/mongo/max_staleness_spec.rb +0 -4
  36. data/spec/mongo/operation/write/update_spec.rb +15 -3
  37. data/spec/mongo/retryable_spec.rb +26 -22
  38. data/spec/mongo/server/connection_spec.rb +26 -0
  39. data/spec/mongo/shell_examples_spec.rb +981 -0
  40. data/spec/mongo/socket/ssl_spec.rb +51 -18
  41. data/spec/spec_helper.rb +26 -16
  42. data/spec/support/authorization.rb +38 -16
  43. data/spec/support/connection_string.rb +3 -3
  44. data/spec/support/crud.rb +38 -10
  45. data/spec/support/crud/write.rb +6 -3
  46. data/spec/support/crud_tests/write/findOneAndReplace-upsert.yml +48 -4
  47. data/spec/support/crud_tests/write/findOneAndReplace-upsert_pre_2.6.yml +88 -0
  48. data/spec/support/crud_tests/write/findOneAndReplace.yml +0 -29
  49. data/spec/support/crud_tests/write/findOneAndUpdate.yml +4 -1
  50. data/spec/support/crud_tests/write/replaceOne-collation.yml +1 -0
  51. data/spec/support/crud_tests/write/replaceOne-pre_2.6.yml +98 -0
  52. data/spec/support/crud_tests/write/replaceOne.yml +21 -5
  53. data/spec/support/crud_tests/write/updateMany-collation.yml +1 -0
  54. data/spec/support/crud_tests/write/updateMany-pre_2.6.yml +86 -0
  55. data/spec/support/crud_tests/write/updateMany.yml +5 -0
  56. data/spec/support/crud_tests/write/updateOne-collation.yml +1 -0
  57. data/spec/support/crud_tests/write/updateOne-pre_2.6.yml +83 -0
  58. data/spec/support/crud_tests/write/updateOne.yml +7 -2
  59. data/spec/support/gridfs.rb +1 -0
  60. metadata +13 -4
  61. metadata.gz.sig +2 -1
  62. data/spec/support/helpers.rb +0 -140
@@ -18,6 +18,7 @@ tests:
18
18
  result:
19
19
  matchedCount: 1
20
20
  modifiedCount: 1
21
+ upsertedCount: 0
21
22
  collection:
22
23
  data:
23
24
  - {_id: 1, x: 11}
@@ -0,0 +1,83 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 22}
4
+ - {_id: 3, x: 33}
5
+ # This file includes the same test cases as updateOne.yml with some omissions
6
+ # for pre-2.6 servers. We cannot verify the update result's modifiedCount as it
7
+ # is not available with legacy write operations and getLastError.
8
+ maxServerVersion: '2.4.99'
9
+
10
+ tests:
11
+ -
12
+ description: "UpdateOne when many documents match"
13
+ operation:
14
+ name: "updateOne"
15
+ arguments:
16
+ filter:
17
+ _id: {$gt: 1}
18
+ update:
19
+ $inc: {x: 1}
20
+
21
+ outcome:
22
+ result:
23
+ matchedCount: 1
24
+ upsertedCount: 0
25
+ # Can't verify collection data because we don't have a way of
26
+ # knowing which document gets updated.
27
+ -
28
+ description: "UpdateOne when one document matches"
29
+ operation:
30
+ name: "updateOne"
31
+ arguments:
32
+ filter: {_id: 1}
33
+ update:
34
+ $inc: {x: 1}
35
+
36
+ outcome:
37
+ result:
38
+ matchedCount: 1
39
+ upsertedCount: 0
40
+ collection:
41
+ data:
42
+ - {_id: 1, x: 12}
43
+ - {_id: 2, x: 22}
44
+ - {_id: 3, x: 33}
45
+ -
46
+ description: "UpdateOne when no documents match"
47
+ operation:
48
+ name: "updateOne"
49
+ arguments:
50
+ filter: {_id: 4}
51
+ update:
52
+ $inc: {x: 1}
53
+
54
+ outcome:
55
+ result:
56
+ matchedCount: 0
57
+ upsertedCount: 0
58
+ collection:
59
+ data:
60
+ - {_id: 1, x: 11}
61
+ - {_id: 2, x: 22}
62
+ - {_id: 3, x: 33}
63
+ -
64
+ description: "UpdateOne with upsert when no documents match"
65
+ operation:
66
+ name: "updateOne"
67
+ arguments:
68
+ filter: {_id: 4}
69
+ update:
70
+ $inc: {x: 1}
71
+ upsert: true
72
+
73
+ outcome:
74
+ result:
75
+ matchedCount: 0
76
+ upsertedCount: 1
77
+ upsertedId: 4
78
+ collection:
79
+ data:
80
+ - {_id: 1, x: 11}
81
+ - {_id: 2, x: 22}
82
+ - {_id: 3, x: 33}
83
+ - {_id: 4, x: 1}
@@ -2,6 +2,7 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
+ minServerVersion: '2.6'
5
6
 
6
7
  tests:
7
8
  -
@@ -18,8 +19,9 @@ tests:
18
19
  result:
19
20
  matchedCount: 1
20
21
  modifiedCount: 1
21
- # can't verify collection because we don't have a way
22
- # of knowing which document gets updated.
22
+ upsertedCount: 0
23
+ # Can't verify collection data because we don't have a way of
24
+ # knowing which document gets updated.
23
25
  -
24
26
  description: "UpdateOne when one document matches"
25
27
  operation:
@@ -33,6 +35,7 @@ tests:
33
35
  result:
34
36
  matchedCount: 1
35
37
  modifiedCount: 1
38
+ upsertedCount: 0
36
39
  collection:
37
40
  data:
38
41
  - {_id: 1, x: 12}
@@ -51,6 +54,7 @@ tests:
51
54
  result:
52
55
  matchedCount: 0
53
56
  modifiedCount: 0
57
+ upsertedCount: 0
54
58
  collection:
55
59
  data:
56
60
  - {_id: 1, x: 11}
@@ -70,6 +74,7 @@ tests:
70
74
  result:
71
75
  matchedCount: 0
72
76
  modifiedCount: 0
77
+ upsertedCount: 1
73
78
  upsertedId: 4
74
79
  collection:
75
80
  data:
@@ -312,6 +312,7 @@ module Mongo
312
312
  else
313
313
  @operation = SuccessfulOp.new(self, test)
314
314
  end
315
+ @result = nil
315
316
  end
316
317
 
317
318
  # Whether the expected and actual collections should be compared after the test runs.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -32,7 +32,7 @@ cert_chain:
32
32
  JORAC0isugdrjOh+7HDizWC+9xpvSdKSuNso9bVKO3czaBeR+i+IA43wWeUliq95
33
33
  5mp49lUwPrMEh694iPac5m+oxYlcU5U+sUyArQXg+lk=
34
34
  -----END CERTIFICATE-----
35
- date: 2016-12-20 00:00:00.000000000 Z
35
+ date: 2017-05-29 00:00:00.000000000 Z
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bson
@@ -140,6 +140,7 @@ files:
140
140
  - lib/mongo/error/invalid_document.rb
141
141
  - lib/mongo/error/invalid_file.rb
142
142
  - lib/mongo/error/invalid_file_revision.rb
143
+ - lib/mongo/error/invalid_min_pool_size.rb
143
144
  - lib/mongo/error/invalid_nonce.rb
144
145
  - lib/mongo/error/invalid_replacement_document.rb
145
146
  - lib/mongo/error/invalid_server_preference.rb
@@ -444,6 +445,7 @@ files:
444
445
  - spec/mongo/server_selector/secondary_spec.rb
445
446
  - spec/mongo/server_selector_spec.rb
446
447
  - spec/mongo/server_spec.rb
448
+ - spec/mongo/shell_examples_spec.rb
447
449
  - spec/mongo/socket/ssl_spec.rb
448
450
  - spec/mongo/socket/unix_spec.rb
449
451
  - spec/mongo/uri_spec.rb
@@ -499,24 +501,27 @@ files:
499
501
  - spec/support/crud_tests/write/findOneAndDelete.yml
500
502
  - spec/support/crud_tests/write/findOneAndReplace-collation.yml
501
503
  - spec/support/crud_tests/write/findOneAndReplace-upsert.yml
504
+ - spec/support/crud_tests/write/findOneAndReplace-upsert_pre_2.6.yml
502
505
  - spec/support/crud_tests/write/findOneAndReplace.yml
503
506
  - spec/support/crud_tests/write/findOneAndUpdate-collation.yml
504
507
  - spec/support/crud_tests/write/findOneAndUpdate.yml
505
508
  - spec/support/crud_tests/write/insertMany.yml
506
509
  - spec/support/crud_tests/write/insertOne.yml
507
510
  - spec/support/crud_tests/write/replaceOne-collation.yml
511
+ - spec/support/crud_tests/write/replaceOne-pre_2.6.yml
508
512
  - spec/support/crud_tests/write/replaceOne-upsert.yml
509
513
  - spec/support/crud_tests/write/replaceOne.yml
510
514
  - spec/support/crud_tests/write/updateMany-collation.yml
515
+ - spec/support/crud_tests/write/updateMany-pre_2.6.yml
511
516
  - spec/support/crud_tests/write/updateMany.yml
512
517
  - spec/support/crud_tests/write/updateOne-collation.yml
518
+ - spec/support/crud_tests/write/updateOne-pre_2.6.yml
513
519
  - spec/support/crud_tests/write/updateOne.yml
514
520
  - spec/support/gridfs.rb
515
521
  - spec/support/gridfs_tests/delete.yml
516
522
  - spec/support/gridfs_tests/download.yml
517
523
  - spec/support/gridfs_tests/download_by_name.yml
518
524
  - spec/support/gridfs_tests/upload.yml
519
- - spec/support/helpers.rb
520
525
  - spec/support/matchers.rb
521
526
  - spec/support/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml
522
527
  - spec/support/max_staleness/ReplicaSetNoPrimary/Incompatible.yml
@@ -797,6 +802,7 @@ test_files:
797
802
  - spec/mongo/server_selector/secondary_spec.rb
798
803
  - spec/mongo/server_selector_spec.rb
799
804
  - spec/mongo/server_spec.rb
805
+ - spec/mongo/shell_examples_spec.rb
800
806
  - spec/mongo/socket/ssl_spec.rb
801
807
  - spec/mongo/socket/unix_spec.rb
802
808
  - spec/mongo/uri_spec.rb
@@ -852,24 +858,27 @@ test_files:
852
858
  - spec/support/crud_tests/write/findOneAndDelete.yml
853
859
  - spec/support/crud_tests/write/findOneAndReplace-collation.yml
854
860
  - spec/support/crud_tests/write/findOneAndReplace-upsert.yml
861
+ - spec/support/crud_tests/write/findOneAndReplace-upsert_pre_2.6.yml
855
862
  - spec/support/crud_tests/write/findOneAndReplace.yml
856
863
  - spec/support/crud_tests/write/findOneAndUpdate-collation.yml
857
864
  - spec/support/crud_tests/write/findOneAndUpdate.yml
858
865
  - spec/support/crud_tests/write/insertMany.yml
859
866
  - spec/support/crud_tests/write/insertOne.yml
860
867
  - spec/support/crud_tests/write/replaceOne-collation.yml
868
+ - spec/support/crud_tests/write/replaceOne-pre_2.6.yml
861
869
  - spec/support/crud_tests/write/replaceOne-upsert.yml
862
870
  - spec/support/crud_tests/write/replaceOne.yml
863
871
  - spec/support/crud_tests/write/updateMany-collation.yml
872
+ - spec/support/crud_tests/write/updateMany-pre_2.6.yml
864
873
  - spec/support/crud_tests/write/updateMany.yml
865
874
  - spec/support/crud_tests/write/updateOne-collation.yml
875
+ - spec/support/crud_tests/write/updateOne-pre_2.6.yml
866
876
  - spec/support/crud_tests/write/updateOne.yml
867
877
  - spec/support/gridfs.rb
868
878
  - spec/support/gridfs_tests/delete.yml
869
879
  - spec/support/gridfs_tests/download.yml
870
880
  - spec/support/gridfs_tests/download_by_name.yml
871
881
  - spec/support/gridfs_tests/upload.yml
872
- - spec/support/helpers.rb
873
882
  - spec/support/matchers.rb
874
883
  - spec/support/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml
875
884
  - spec/support/max_staleness/ReplicaSetNoPrimary/Incompatible.yml
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- 6�ﰊ4t]�����t������F ��ꄒ$�X{nk�'�gu��R�0��mf,�n�3���?e��"�zRs��d�Rc�ܴ�0; ���ZE�l��1O�U?�o������(�Z������cv��og=��Ԛ*bP�����s�� �E1�p�qm 8�~������܌���mhtT���J>�4�x���{����#��Jo��
1
+ M!+��^K tj�?P1��J^Թ��\���D"͒ ��l��N|Ě�-�BͤД�"�w
2
+ ��B�3�";�=��
@@ -1,140 +0,0 @@
1
- # Copyright (C) 2009-2014 MongoDB, Inc.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- # Helper methods and utilities for testing.
16
- module Helpers
17
-
18
- # Helper method to allow temporary redirection of $stdout.
19
- #
20
- # @example
21
- # silence do
22
- # # your noisey code here
23
- # end
24
- #
25
- # @param A code block to execute.
26
- # @return Original $stdout value.
27
- def silence(&block)
28
- original_stdout = $stdout
29
- original_stderr = $stderr
30
- $stdout = $stderr = File.new('/dev/null', 'w')
31
- yield block
32
- ensure
33
- $stdout = original_stdout
34
- $stderr = original_stderr
35
- end
36
-
37
- TEST_KEY_RSA1024 = OpenSSL::PKey::RSA.new <<-_end_of_pem_
38
- -----BEGIN RSA PRIVATE KEY-----
39
- MIICXgIBAAKBgQDLwsSw1ECnPtT+PkOgHhcGA71nwC2/nL85VBGnRqDxOqjVh7Cx
40
- aKPERYHsk4BPCkE3brtThPWc9kjHEQQ7uf9Y1rbCz0layNqHyywQEVLFmp1cpIt/
41
- Q3geLv8ZD9pihowKJDyMDiN6ArYUmZczvW4976MU3+l54E6lF/JfFEU5hwIDAQAB
42
- AoGBAKSl/MQarye1yOysqX6P8fDFQt68VvtXkNmlSiKOGuzyho0M+UVSFcs6k1L0
43
- maDE25AMZUiGzuWHyaU55d7RXDgeskDMakD1v6ZejYtxJkSXbETOTLDwUWTn618T
44
- gnb17tU1jktUtU67xK/08i/XodlgnQhs6VoHTuCh3Hu77O6RAkEA7+gxqBuZR572
45
- 74/akiW/SuXm0SXPEviyO1MuSRwtI87B02D0qgV8D1UHRm4AhMnJ8MCs1809kMQE
46
- JiQUCrp9mQJBANlt2ngBO14us6NnhuAseFDTBzCHXwUUu1YKHpMMmxpnGqaldGgX
47
- sOZB3lgJsT9VlGf3YGYdkLTNVbogQKlKpB8CQQDiSwkb4vyQfDe8/NpU5Not0fII
48
- 8jsDUCb+opWUTMmfbxWRR3FBNu8wnym/m19N4fFj8LqYzHX4KY0oVPu6qvJxAkEA
49
- wa5snNekFcqONLIE4G5cosrIrb74sqL8GbGb+KuTAprzj5z1K8Bm0UW9lTjVDjDi
50
- qRYgZfZSL+x1P/54+xTFSwJAY1FxA/N3QPCXCjPh5YqFxAMQs2VVYTfg+t0MEcJD
51
- dPMQD5JX6g5HKnHFg2mZtoXQrWmJSn7p8GJK8yNTopEErA==
52
- -----END RSA PRIVATE KEY-----
53
- _end_of_pem_
54
-
55
- def issue_cert(dn, key, serial, not_before, not_after, extensions, issuer, issuer_key, digest)
56
- cert = OpenSSL::X509::Certificate.new
57
- issuer = cert unless issuer
58
- issuer_key = key unless issuer_key
59
- cert.version = 2
60
- cert.serial = serial
61
- cert.subject = dn
62
- cert.issuer = issuer.subject
63
- cert.public_key = key.public_key
64
- cert.not_before = not_before
65
- cert.not_after = not_after
66
- ef = OpenSSL::X509::ExtensionFactory.new
67
- ef.subject_certificate = cert
68
- ef.issuer_certificate = issuer
69
- extensions.each do |oid, value, critical|
70
- cert.add_extension(ef.create_extension(oid, value, critical))
71
- end
72
- cert.sign(issuer_key, digest)
73
- cert
74
- end
75
-
76
- def collection(name, db)
77
- documents = []
78
- double(name.to_s).tap do |coll|
79
-
80
- allow(coll).to receive(:db) { db }
81
-
82
- allow(coll).to receive(:save) do |doc|
83
- coll.remove({ :_id => doc[:_id] })
84
- coll.insert(doc)
85
- end
86
-
87
- allow(coll).to receive(:count) { documents.length }
88
-
89
- allow(coll).to receive(:insert) do |doc|
90
- if !coll.find({ :_id => doc[:_id] }).empty?
91
- raise GridError, "duplicate key error, _id"
92
- end
93
- documents.push(doc)
94
- end
95
-
96
- allow(coll).to receive(:find_one) do |query|
97
- result = nil
98
- documents.each do |doc|
99
- if matches(doc, query)
100
- result = doc
101
- break
102
- end
103
- end
104
- result
105
- end
106
-
107
- allow(coll).to receive(:remove) do |query|
108
- documents.dup.each do |doc|
109
- if matches(doc, query)
110
- documents.delete(doc)
111
- end
112
- end
113
- end
114
-
115
- allow(coll).to receive(:find) do |query|
116
- results = []
117
- documents.each do |doc|
118
- if matches(doc, query)
119
- results.push(doc)
120
- end
121
- end
122
- results
123
- end
124
- end
125
- end
126
-
127
- # does only strict equivalence,
128
- # {:n => 4} should work
129
- # {:n => {"$gt" => 3}} will not work.
130
- def matches(doc, query={})
131
- match = true
132
- query.each do |field, value|
133
- if !doc[field] || doc[field] != value
134
- match = false
135
- break
136
- end
137
- end
138
- match
139
- end
140
- end