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
@@ -0,0 +1,88 @@
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 findOneAndReplace-upsert.yml with
6
+ # some omissions for pre-2.6 servers. We cannot verify the ID of an upserted
7
+ # document in some cases due to SERVER-5289.
8
+ maxServerVersion: '2.4.99'
9
+
10
+ tests:
11
+ -
12
+ description: "FindOneAndReplace when no documents match without id specified with upsert returning the document before modification"
13
+ operation:
14
+ name: findOneAndReplace
15
+ arguments:
16
+ filter: {_id: 4}
17
+ replacement: {x: 44}
18
+ projection: {x: 1, _id: 0}
19
+ # Omit the sort option as it has no effect when no documents
20
+ # match and would only cause an inconsistent return value on
21
+ # pre-3.0 servers when combined with returnDocument "before"
22
+ # (see: SERVER-17650).
23
+ upsert: true
24
+
25
+ outcome:
26
+ result: null
27
+ # Can't verify collection data because server versions before 2.6 do
28
+ # not take the _id from the filter document during an upsert (see:
29
+ # SERVER-5289).
30
+ -
31
+ description: "FindOneAndReplace when no documents match without id specified with upsert returning the document after modification"
32
+ operation:
33
+ name: findOneAndReplace
34
+ arguments:
35
+ filter: {_id: 4}
36
+ replacement: {x: 44}
37
+ projection: {x: 1, _id: 0}
38
+ returnDocument: After
39
+ sort: {x: 1}
40
+ upsert: true
41
+
42
+ outcome:
43
+ result: {x: 44}
44
+ # Can't verify collection data because server versions before 2.6 do
45
+ # not take the _id from the filter document during an upsert (see:
46
+ # SERVER-5289).
47
+ -
48
+ description: "FindOneAndReplace when no documents match with id specified with upsert returning the document before modification"
49
+ operation:
50
+ name: findOneAndReplace
51
+ arguments:
52
+ filter: {_id: 4}
53
+ replacement: {_id: 4, x: 44}
54
+ projection: {x: 1, _id: 0}
55
+ # Omit the sort option as it has no effect when no documents
56
+ # match and would only cause an inconsistent return value on
57
+ # pre-3.0 servers when combined with returnDocument "before"
58
+ # (see: SERVER-17650).
59
+ upsert: true
60
+
61
+ outcome:
62
+ result: null
63
+ collection:
64
+ data:
65
+ - {_id: 1, x: 11}
66
+ - {_id: 2, x: 22}
67
+ - {_id: 3, x: 33}
68
+ - {_id: 4, x: 44}
69
+ -
70
+ description: "FindOneAndReplace when no documents match with id specified with upsert returning the document after modification"
71
+ operation:
72
+ name: findOneAndReplace
73
+ arguments:
74
+ filter: {_id: 4}
75
+ replacement: {_id: 4, x: 44}
76
+ projection: {x: 1, _id: 0}
77
+ returnDocument: After
78
+ sort: {x: 1}
79
+ upsert: true
80
+
81
+ outcome:
82
+ result: {x: 44}
83
+ collection:
84
+ data:
85
+ - {_id: 1, x: 11}
86
+ - {_id: 2, x: 22}
87
+ - {_id: 3, x: 33}
88
+ - {_id: 4, x: 44}
@@ -93,20 +93,6 @@ tests:
93
93
  - {_id: 1, x: 11}
94
94
  - {_id: 2, x: 22}
95
95
  - {_id: 3, x: 33}
96
- -
97
- description: "FindOneAndReplace when no documents match with upsert returning the document before modification"
98
- operation:
99
- name: findOneAndReplace
100
- arguments:
101
- filter: {_id: 4}
102
- replacement: {x: 44}
103
- projection: {x: 1, _id: 0}
104
- sort: {x: 1}
105
- upsert: true
106
-
107
- outcome:
108
- result: null
109
- # See SERVER-5289 for why the collection data is not checked for server versions < 2.6
110
96
  -
111
97
  description: "FindOneAndReplace when no documents match returning the document after modification"
112
98
  operation:
@@ -125,18 +111,3 @@ tests:
125
111
  - {_id: 1, x: 11}
126
112
  - {_id: 2, x: 22}
127
113
  - {_id: 3, x: 33}
128
- -
129
- description: "FindOneAndReplace when no documents match with upsert returning the document after modification"
130
- operation:
131
- name: findOneAndReplace
132
- arguments:
133
- filter: {_id: 4}
134
- replacement: {x: 44}
135
- projection: {x: 1, _id: 0}
136
- returnDocument: After
137
- sort: {x: 1}
138
- upsert: true
139
-
140
- outcome:
141
- result: {x: 44}
142
- # See SERVER-5289 for why the collection data is not checked for server versions < 2.6
@@ -107,7 +107,10 @@ tests:
107
107
  update:
108
108
  $inc: {x: 1}
109
109
  projection: {x: 1, _id: 0}
110
- sort: {x: 1}
110
+ # Omit the sort option as it has no effect when no documents
111
+ # match and would only cause an inconsistent return value on
112
+ # pre-3.0 servers when combined with returnDocument "before"
113
+ # (see: SERVER-17650).
111
114
  upsert: true
112
115
 
113
116
  outcome:
@@ -17,6 +17,7 @@ tests:
17
17
  result:
18
18
  matchedCount: 1
19
19
  modifiedCount: 1
20
+ upsertedCount: 0
20
21
  collection:
21
22
  data:
22
23
  - {_id: 1, x: 11}
@@ -0,0 +1,98 @@
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 replaceOne.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. Additionally,
8
+ # we cannot verify the ID of an upserted document in some cases due to
9
+ # SERVER-5289.
10
+ maxServerVersion: '2.4.99'
11
+
12
+ tests:
13
+ -
14
+ description: "ReplaceOne when many documents match"
15
+ operation:
16
+ name: "replaceOne"
17
+ arguments:
18
+ filter:
19
+ _id: {$gt: 1}
20
+ replacement: {x: 111}
21
+
22
+ outcome:
23
+ result:
24
+ matchedCount: 1
25
+ upsertedCount: 0
26
+ # Can't verify collection data because we don't have a way of
27
+ # knowing which document gets updated.
28
+ -
29
+ description: "ReplaceOne when one document matches"
30
+ operation:
31
+ name: "replaceOne"
32
+ arguments:
33
+ filter: {_id: 1}
34
+ replacement: {_id: 1, x: 111}
35
+
36
+ outcome:
37
+ result:
38
+ matchedCount: 1
39
+ upsertedCount: 0
40
+ collection:
41
+ data:
42
+ - {_id: 1, x: 111}
43
+ - {_id: 2, x: 22}
44
+ - {_id: 3, x: 33}
45
+ -
46
+ description: "ReplaceOne when no documents match"
47
+ operation:
48
+ name: "replaceOne"
49
+ arguments:
50
+ filter: {_id: 4}
51
+ replacement: {_id: 4, x: 1}
52
+
53
+ outcome:
54
+ result:
55
+ matchedCount: 0
56
+ upsertedCount: 0
57
+ collection:
58
+ data:
59
+ - {_id: 1, x: 11}
60
+ - {_id: 2, x: 22}
61
+ - {_id: 3, x: 33}
62
+ -
63
+ description: "ReplaceOne with upsert when no documents match without an id specified"
64
+ operation:
65
+ name: "replaceOne"
66
+ arguments:
67
+ filter: {_id: 4}
68
+ replacement: {x: 1}
69
+ upsert: true
70
+
71
+ outcome:
72
+ result:
73
+ matchedCount: 0
74
+ upsertedCount: 1
75
+ # Can't verify upsertedId or collection data because server versions
76
+ # before 2.6 do not take the _id from the filter document during an
77
+ # upsert (see: SERVER-5289)
78
+
79
+ -
80
+ description: "ReplaceOne with upsert when no documents match with an id specified"
81
+ operation:
82
+ name: "replaceOne"
83
+ arguments:
84
+ filter: {_id: 4}
85
+ replacement: {_id: 4, x: 1}
86
+ upsert: true
87
+
88
+ outcome:
89
+ result:
90
+ matchedCount: 0
91
+ upsertedCount: 1
92
+ upsertedId: 4
93
+ collection:
94
+ data:
95
+ - {_id: 1, x: 11}
96
+ - {_id: 2, x: 22}
97
+ - {_id: 3, x: 33}
98
+ - {_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
  -
@@ -9,7 +10,7 @@ tests:
9
10
  operation:
10
11
  name: "replaceOne"
11
12
  arguments:
12
- filter:
13
+ filter:
13
14
  _id: {$gt: 1}
14
15
  replacement: {x: 111}
15
16
 
@@ -17,8 +18,9 @@ tests:
17
18
  result:
18
19
  matchedCount: 1
19
20
  modifiedCount: 1
20
- # can't verify collection because we don't have a way
21
- # of knowing which document gets updated.
21
+ upsertedCount: 0
22
+ # Can't verify collection data because we don't have a way of
23
+ # knowing which document gets updated.
22
24
  -
23
25
  description: "ReplaceOne when one document matches"
24
26
  operation:
@@ -31,6 +33,7 @@ tests:
31
33
  result:
32
34
  matchedCount: 1
33
35
  modifiedCount: 1
36
+ upsertedCount: 0
34
37
  collection:
35
38
  data:
36
39
  - {_id: 1, x: 111}
@@ -48,6 +51,7 @@ tests:
48
51
  result:
49
52
  matchedCount: 0
50
53
  modifiedCount: 0
54
+ upsertedCount: 0
51
55
  collection:
52
56
  data:
53
57
  - {_id: 1, x: 11}
@@ -66,8 +70,14 @@ tests:
66
70
  result:
67
71
  matchedCount: 0
68
72
  modifiedCount: 0
73
+ upsertedCount: 1
69
74
  upsertedId: 4
70
- # See SERVER-5289 for why the collection data is not checked for server versions < 2.6
75
+ collection:
76
+ data:
77
+ - {_id: 1, x: 11}
78
+ - {_id: 2, x: 22}
79
+ - {_id: 3, x: 33}
80
+ - {_id: 4, x: 1}
71
81
 
72
82
  -
73
83
  description: "ReplaceOne with upsert when no documents match with an id specified"
@@ -82,5 +92,11 @@ tests:
82
92
  result:
83
93
  matchedCount: 0
84
94
  modifiedCount: 0
95
+ upsertedCount: 1
85
96
  upsertedId: 4
86
- # See SERVER-5289 for why the collection data is not checked for server versions < 2.6
97
+ collection:
98
+ data:
99
+ - {_id: 1, x: 11}
100
+ - {_id: 2, x: 22}
101
+ - {_id: 3, x: 33}
102
+ - {_id: 4, x: 1}
@@ -20,6 +20,7 @@ tests:
20
20
  result:
21
21
  matchedCount: 2
22
22
  modifiedCount: 2
23
+ upsertedCount: 0
23
24
  collection:
24
25
  data:
25
26
  - {_id: 1, x: 11}
@@ -0,0 +1,86 @@
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 updateMany.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: "UpdateMany when many documents match"
13
+ operation:
14
+ name: "updateMany"
15
+ arguments:
16
+ filter:
17
+ _id: {$gt: 1}
18
+ update:
19
+ $inc: {x: 1}
20
+
21
+ outcome:
22
+ result:
23
+ matchedCount: 2
24
+ upsertedCount: 0
25
+ collection:
26
+ data:
27
+ - {_id: 1, x: 11}
28
+ - {_id: 2, x: 23}
29
+ - {_id: 3, x: 34}
30
+ -
31
+ description: "UpdateMany when one document matches"
32
+ operation:
33
+ name: "updateMany"
34
+ arguments:
35
+ filter: {_id: 1}
36
+ update:
37
+ $inc: {x: 1}
38
+
39
+ outcome:
40
+ result:
41
+ matchedCount: 1
42
+ upsertedCount: 0
43
+ collection:
44
+ data:
45
+ - {_id: 1, x: 12}
46
+ - {_id: 2, x: 22}
47
+ - {_id: 3, x: 33}
48
+ -
49
+ description: "UpdateMany when no documents match"
50
+ operation:
51
+ name: "updateMany"
52
+ arguments:
53
+ filter: {_id: 4}
54
+ update:
55
+ $inc: {x: 1}
56
+
57
+ outcome:
58
+ result:
59
+ matchedCount: 0
60
+ upsertedCount: 0
61
+ collection:
62
+ data:
63
+ - {_id: 1, x: 11}
64
+ - {_id: 2, x: 22}
65
+ - {_id: 3, x: 33}
66
+ -
67
+ description: "UpdateMany with upsert when no documents match"
68
+ operation:
69
+ name: "updateMany"
70
+ arguments:
71
+ filter: {_id: 4}
72
+ update:
73
+ $inc: {x: 1}
74
+ upsert: true
75
+
76
+ outcome:
77
+ result:
78
+ matchedCount: 0
79
+ upsertedCount: 1
80
+ upsertedId: 4
81
+ collection:
82
+ data:
83
+ - {_id: 1, x: 11}
84
+ - {_id: 2, x: 22}
85
+ - {_id: 3, x: 33}
86
+ - {_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,6 +19,7 @@ tests:
18
19
  result:
19
20
  matchedCount: 2
20
21
  modifiedCount: 2
22
+ upsertedCount: 0
21
23
  collection:
22
24
  data:
23
25
  - {_id: 1, x: 11}
@@ -36,6 +38,7 @@ tests:
36
38
  result:
37
39
  matchedCount: 1
38
40
  modifiedCount: 1
41
+ upsertedCount: 0
39
42
  collection:
40
43
  data:
41
44
  - {_id: 1, x: 12}
@@ -54,6 +57,7 @@ tests:
54
57
  result:
55
58
  matchedCount: 0
56
59
  modifiedCount: 0
60
+ upsertedCount: 0
57
61
  collection:
58
62
  data:
59
63
  - {_id: 1, x: 11}
@@ -73,6 +77,7 @@ tests:
73
77
  result:
74
78
  matchedCount: 0
75
79
  modifiedCount: 0
80
+ upsertedCount: 1
76
81
  upsertedId: 4
77
82
  collection:
78
83
  data: