mongo 2.4.0.rc0 → 2.4.0.rc1

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 (93) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +1 -2
  4. data/lib/mongo/bulk_write/validatable.rb +3 -1
  5. data/lib/mongo/client.rb +30 -3
  6. data/lib/mongo/cluster/app_metadata.rb +7 -2
  7. data/lib/mongo/collection.rb +3 -1
  8. data/lib/mongo/collection/view.rb +3 -1
  9. data/lib/mongo/collection/view/aggregation.rb +3 -1
  10. data/lib/mongo/collection/view/builder/find_command.rb +20 -5
  11. data/lib/mongo/collection/view/map_reduce.rb +3 -1
  12. data/lib/mongo/collection/view/writable.rb +12 -2
  13. data/lib/mongo/cursor/builder/get_more_command.rb +3 -2
  14. data/lib/mongo/error/closed_stream.rb +1 -1
  15. data/lib/mongo/error/invalid_server_preference.rb +1 -1
  16. data/lib/mongo/index/view.rb +3 -1
  17. data/lib/mongo/operation/write/bulk/mergable.rb +1 -1
  18. data/lib/mongo/operation/write/create_index.rb +1 -1
  19. data/lib/mongo/operation/write/delete.rb +1 -1
  20. data/lib/mongo/operation/write/update.rb +1 -1
  21. data/lib/mongo/protocol/delete.rb +4 -1
  22. data/lib/mongo/protocol/get_more.rb +4 -1
  23. data/lib/mongo/protocol/insert.rb +7 -3
  24. data/lib/mongo/protocol/kill_cursors.rb +4 -1
  25. data/lib/mongo/protocol/message.rb +5 -1
  26. data/lib/mongo/protocol/query.rb +11 -4
  27. data/lib/mongo/protocol/update.rb +4 -1
  28. data/lib/mongo/server/connectable.rb +8 -2
  29. data/lib/mongo/server/connection_pool.rb +3 -1
  30. data/lib/mongo/server/monitor.rb +1 -0
  31. data/lib/mongo/socket.rb +16 -8
  32. data/lib/mongo/socket/ssl.rb +24 -9
  33. data/lib/mongo/uri.rb +6 -6
  34. data/lib/mongo/version.rb +1 -1
  35. data/mongo.gemspec +1 -1
  36. data/spec/mongo/bulk_write_spec.rb +117 -0
  37. data/spec/mongo/collection/view/aggregation_spec.rb +26 -0
  38. data/spec/mongo/collection/view/builder/find_command_spec.rb +244 -2
  39. data/spec/mongo/collection/view/map_reduce_spec.rb +13 -0
  40. data/spec/mongo/collection/view/readable_spec.rb +26 -0
  41. data/spec/mongo/collection/view/writable_spec.rb +104 -0
  42. data/spec/mongo/collection/view_spec.rb +13 -0
  43. data/spec/mongo/collection_spec.rb +226 -7
  44. data/spec/mongo/crud_spec.rb +5 -5
  45. data/spec/mongo/index/view_spec.rb +53 -0
  46. data/spec/mongo/server/connection_spec.rb +45 -26
  47. data/spec/mongo/socket/ssl_spec.rb +358 -22
  48. data/spec/spec_helper.rb +4 -0
  49. data/spec/support/authorization.rb +3 -3
  50. data/spec/support/certificates/client_cert.pem +21 -0
  51. data/spec/support/certificates/client_key.pem +28 -0
  52. data/spec/support/certificates/client_key_encrypted.pem +30 -0
  53. data/spec/support/crud.rb +67 -22
  54. data/spec/support/crud/read.rb +18 -36
  55. data/spec/support/crud/write.rb +0 -44
  56. data/spec/support/crud_tests/read/aggregate-collation.yml +17 -0
  57. data/spec/support/crud_tests/read/aggregate-out.yml +28 -0
  58. data/spec/support/crud_tests/read/aggregate.yml +1 -35
  59. data/spec/support/crud_tests/read/count-collation.yml +15 -0
  60. data/spec/support/crud_tests/read/count.yml +3 -15
  61. data/spec/support/crud_tests/read/distinct-collation.yml +17 -0
  62. data/spec/support/crud_tests/read/distinct.yml +1 -14
  63. data/spec/support/crud_tests/read/find-collation.yml +15 -0
  64. data/spec/support/crud_tests/read/find.yml +1 -12
  65. data/spec/support/crud_tests/write/deleteMany-collation.yml +22 -0
  66. data/spec/support/crud_tests/write/deleteMany.yml +1 -23
  67. data/spec/support/crud_tests/write/deleteOne-collation.yml +22 -0
  68. data/spec/support/crud_tests/write/deleteOne.yml +1 -21
  69. data/spec/support/crud_tests/write/findOneAndDelete-collation.yml +23 -0
  70. data/spec/support/crud_tests/write/findOneAndDelete.yml +2 -28
  71. data/spec/support/crud_tests/write/findOneAndReplace-collation.yml +24 -0
  72. data/spec/support/crud_tests/write/findOneAndReplace-upsert.yml +47 -0
  73. data/spec/support/crud_tests/write/findOneAndReplace.yml +13 -53
  74. data/spec/support/crud_tests/write/findOneAndUpdate-collation.yml +27 -0
  75. data/spec/support/crud_tests/write/findOneAndUpdate.yml +8 -51
  76. data/spec/support/crud_tests/write/insertMany.yml +1 -2
  77. data/spec/support/crud_tests/write/insertOne.yml +1 -2
  78. data/spec/support/crud_tests/write/replaceOne-collation.yml +23 -0
  79. data/spec/support/crud_tests/write/replaceOne-upsert.yml +48 -0
  80. data/spec/support/crud_tests/write/replaceOne.yml +11 -45
  81. data/spec/support/crud_tests/write/updateMany-collation.yml +27 -0
  82. data/spec/support/crud_tests/write/updateMany.yml +10 -42
  83. data/spec/support/crud_tests/write/updateOne-collation.yml +24 -0
  84. data/spec/support/crud_tests/write/updateOne.yml +7 -33
  85. data/spec/support/sdam/rs/new_primary_new_setversion.yml +1 -1
  86. data/spec/support/sdam/rs/null_election_id.yml +1 -0
  87. data/spec/support/sdam/rs/primary_disconnect_electionid.yml +2 -3
  88. data/spec/support/sdam/rs/primary_disconnect_setversion.yml +1 -2
  89. data/spec/support/sdam/single/direct_connection_rsarbiter.yml +1 -1
  90. data/spec/support/sdam/single/direct_connection_rsprimary.yml +1 -1
  91. data/spec/support/sdam/single/direct_connection_rssecondary.yml +1 -1
  92. metadata +40 -4
  93. metadata.gz.sig +0 -0
@@ -0,0 +1,15 @@
1
+ data:
2
+ - {_id: 1, x: 'PING'}
3
+ minServerVersion: '3.4'
4
+
5
+ tests:
6
+ -
7
+ description: "Count with collation"
8
+ operation:
9
+ name: count
10
+ arguments:
11
+ filter: { x: 'ping' }
12
+ collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document
13
+
14
+ outcome:
15
+ result: 1
@@ -2,7 +2,6 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
- - {_id: 4, x: 'PING'}
6
5
 
7
6
  tests:
8
7
  -
@@ -13,14 +12,14 @@ tests:
13
12
  filter: { }
14
13
 
15
14
  outcome:
16
- result: 4
15
+ result: 3
17
16
  -
18
17
  description: "Count with a filter"
19
18
  operation:
20
19
  name: count
21
20
  arguments:
22
21
  filter:
23
- _id: {$gt: 1, $lt: 4}
22
+ _id: {$gt: 1}
24
23
 
25
24
  outcome:
26
25
  result: 2
@@ -34,15 +33,4 @@ tests:
34
33
  limit: 3
35
34
 
36
35
  outcome:
37
- result: 3
38
- -
39
- description: "Count with collation"
40
- operation:
41
- name: count
42
- arguments:
43
- filter: { x: 'ping' }
44
- collation: { locale: 'en_US', strength: 2 }
45
-
46
- outcome:
47
- result: 1
48
-
36
+ result: 2
@@ -0,0 +1,17 @@
1
+ data:
2
+ - {_id: 1, string: 'PING'}
3
+ - {_id: 2, string: 'ping'}
4
+ minServerVersion: '3.4'
5
+
6
+ tests:
7
+ -
8
+ description: "Distinct with a collation"
9
+ operation:
10
+ name: distinct
11
+ arguments:
12
+ fieldName: "string"
13
+ collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document
14
+
15
+ outcome:
16
+ result:
17
+ - 'PING'
@@ -2,8 +2,6 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
- - {_id: 4, string: 'PING'}
6
- - {_id: 5, string: 'ping'}
7
5
 
8
6
  tests:
9
7
  -
@@ -31,15 +29,4 @@ tests:
31
29
  outcome:
32
30
  result:
33
31
  - 22
34
- - 33
35
- -
36
- description: "Distinct with a collation"
37
- operation:
38
- name: distinct
39
- arguments:
40
- fieldName: "string"
41
- collation: { locale: 'en_US', strength: 2 }
42
-
43
- outcome:
44
- result:
45
- - 'PING'
32
+ - 33
@@ -0,0 +1,15 @@
1
+ data:
2
+ - {_id: 1, x: 'ping'}
3
+ minServerVersion: '3.4'
4
+
5
+ tests:
6
+ -
7
+ description: "Find with a collation"
8
+ operation:
9
+ name: "find"
10
+ arguments:
11
+ filter: {x: 'PING'}
12
+ collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document
13
+ outcome:
14
+ result:
15
+ - {_id: 1, x: 'ping'}
@@ -4,7 +4,6 @@ data:
4
4
  - {_id: 3, x: 33}
5
5
  - {_id: 4, x: 44}
6
6
  - {_id: 5, x: 55}
7
- - {_id: 6, x: 'ping'}
8
7
 
9
8
  tests:
10
9
  -
@@ -24,7 +23,7 @@ tests:
24
23
  name: "find"
25
24
  arguments:
26
25
  filter:
27
- _id: {$gt: 2, $lt: 6}
26
+ _id: {$gt: 2}
28
27
  sort: {_id: 1}
29
28
  skip: 2
30
29
  limit: 2
@@ -48,13 +47,3 @@ tests:
48
47
  - {_id: 2, x: 22}
49
48
  - {_id: 3, x: 33}
50
49
  - {_id: 4, x: 44}
51
- -
52
- description: "Find with a collation"
53
- operation:
54
- name: "find"
55
- arguments:
56
- filter: {x: 'PING'}
57
- collation: { locale: 'en_US', strength: 2 }
58
- outcome:
59
- result:
60
- - {_id: 6, x: 'ping'}
@@ -0,0 +1,22 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 'ping'}
4
+ - {_id: 3, x: 'pINg'}
5
+ minServerVersion: '3.4'
6
+
7
+ tests:
8
+ -
9
+ description: "DeleteMany when many documents match with collation"
10
+ operation:
11
+ name: "deleteMany"
12
+ arguments:
13
+ filter:
14
+ x: 'PING'
15
+ collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document
16
+
17
+ outcome:
18
+ result:
19
+ deletedCount: 2
20
+ collection:
21
+ data:
22
+ - {_id: 1, x: 11}
@@ -2,8 +2,6 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
- - {_id: 4, x: 'ping'}
6
- - {_id: 5, x: 'pINg'}
7
5
 
8
6
  tests:
9
7
  -
@@ -14,35 +12,18 @@ tests:
14
12
  filter:
15
13
  _id: {$gt: 1}
16
14
 
17
- outcome:
18
- result:
19
- deletedCount: 4
20
- collection:
21
- data:
22
- - {_id: 1, x: 11}
23
- -
24
- description: "DeleteMany when many documents match with collation"
25
- operation:
26
- name: "deleteMany"
27
- arguments:
28
- filter:
29
- x: 'PING'
30
- collation: { locale: 'en_US', strength: 2 }
31
-
32
15
  outcome:
33
16
  result:
34
17
  deletedCount: 2
35
18
  collection:
36
19
  data:
37
20
  - {_id: 1, x: 11}
38
- - {_id: 2, x: 22}
39
- - {_id: 3, x: 33}
40
21
  -
41
22
  description: "DeleteMany when no document matches"
42
23
  operation:
43
24
  name: "deleteMany"
44
25
  arguments:
45
- filter: {_id: 6}
26
+ filter: {_id: 4}
46
27
 
47
28
  outcome:
48
29
  result:
@@ -52,6 +33,3 @@ tests:
52
33
  - {_id: 1, x: 11}
53
34
  - {_id: 2, x: 22}
54
35
  - {_id: 3, x: 33}
55
- - {_id: 4, x: 'ping'}
56
- - {_id: 5, x: 'pINg'}
57
-
@@ -0,0 +1,22 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 'ping'}
4
+ - {_id: 3, x: 'pINg'}
5
+ minServerVersion: '3.4'
6
+
7
+ tests:
8
+ -
9
+ description: "DeleteOne when many documents matches with collation"
10
+ operation:
11
+ name: "deleteOne"
12
+ arguments:
13
+ filter: {x: 'PING'}
14
+ collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document
15
+
16
+ outcome:
17
+ result:
18
+ deletedCount: 1
19
+ collection:
20
+ data:
21
+ - {_id: 1, x: 11}
22
+ - {_id: 3, x: 'pINg'}
@@ -2,7 +2,6 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
- - {_id: 4, x: 'ping'}
6
5
 
7
6
  tests:
8
7
  -
@@ -32,29 +31,12 @@ tests:
32
31
  data:
33
32
  - {_id: 1, x: 11}
34
33
  - {_id: 3, x: 33}
35
- - {_id: 4, x: 'ping'}
36
- -
37
- description: "DeleteOne when one document matches with collation"
38
- operation:
39
- name: "deleteOne"
40
- arguments:
41
- filter: {x: 'PING'}
42
- collation: { locale: 'en_US', strength: 2 }
43
-
44
- outcome:
45
- result:
46
- deletedCount: 1
47
- collection:
48
- data:
49
- - {_id: 1, x: 11}
50
- - {_id: 2, x: 22}
51
- - {_id: 3, x: 33}
52
34
  -
53
35
  description: "DeleteOne when no documents match"
54
36
  operation:
55
37
  name: "deleteOne"
56
38
  arguments:
57
- filter: {_id: 5}
39
+ filter: {_id: 4}
58
40
 
59
41
  outcome:
60
42
  result:
@@ -64,5 +46,3 @@ tests:
64
46
  - {_id: 1, x: 11}
65
47
  - {_id: 2, x: 22}
66
48
  - {_id: 3, x: 33}
67
- - {_id: 4, x: 'ping'}
68
-
@@ -0,0 +1,23 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 'ping'}
4
+ - {_id: 3, x: 'pINg'}
5
+ minServerVersion: '3.4'
6
+
7
+ tests:
8
+ -
9
+ description: "FindOneAndDelete when one document matches with collation"
10
+ operation:
11
+ name: findOneAndDelete
12
+ arguments:
13
+ filter: {_id: 2, x: 'PING'}
14
+ projection: {x: 1, _id: 0}
15
+ sort: {x: 1}
16
+ collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document
17
+
18
+ outcome:
19
+ result: {x: 'ping'}
20
+ collection:
21
+ data:
22
+ - {_id: 1, x: 11}
23
+ - {_id: 3, x: 'pINg'}
@@ -2,8 +2,6 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
- - {_id: 4, x: 'ping'}
6
- - {_id: 5, x: 'pINg'}
7
5
 
8
6
  tests:
9
7
  -
@@ -22,8 +20,6 @@ tests:
22
20
  data:
23
21
  - {_id: 1, x: 11}
24
22
  - {_id: 3, x: 33}
25
- - {_id: 4, x: 'ping'}
26
- - {_id: 5, x: 'pINg'}
27
23
  -
28
24
  description: "FindOneAndDelete when one document matches"
29
25
  operation:
@@ -39,32 +35,12 @@ tests:
39
35
  data:
40
36
  - {_id: 1, x: 11}
41
37
  - {_id: 3, x: 33}
42
- - {_id: 4, x: 'ping'}
43
- - {_id: 5, x: 'pINg'}
44
- -
45
- description: "FindOneAndDelete when one document matches with collation"
46
- operation:
47
- name: findOneAndDelete
48
- arguments:
49
- filter: {_id: 4, x: 'PING'}
50
- projection: {x: 1, _id: 0}
51
- sort: {x: 1}
52
- collation: { locale: 'en_US', strength: 2 }
53
-
54
- outcome:
55
- result: {x: 'ping'}
56
- collection:
57
- data:
58
- - {_id: 1, x: 11}
59
- - {_id: 2, x: 22}
60
- - {_id: 3, x: 33}
61
- - {_id: 5, x: 'pINg'}
62
38
  -
63
39
  description: "FindOneAndDelete when no documents match"
64
40
  operation:
65
41
  name: findOneAndDelete
66
42
  arguments:
67
- filter: {_id: 6}
43
+ filter: {_id: 4}
68
44
  projection: {x: 1, _id: 0}
69
45
  sort: {x: 1}
70
46
 
@@ -74,6 +50,4 @@ tests:
74
50
  data:
75
51
  - {_id: 1, x: 11}
76
52
  - {_id: 2, x: 22}
77
- - {_id: 3, x: 33}
78
- - {_id: 4, x: 'ping'}
79
- - {_id: 5, x: 'pINg'}
53
+ - {_id: 3, x: 33}
@@ -0,0 +1,24 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 'ping'}
4
+ minServerVersion: '3.4'
5
+
6
+ tests:
7
+ -
8
+ description: "FindOneAndReplace when one document matches with collation returning the document after modification"
9
+ operation:
10
+ name: findOneAndReplace
11
+ arguments:
12
+ filter: {x: 'PING'}
13
+ replacement: {x: 'pong'}
14
+ projection: {x: 1, _id: 0}
15
+ returnDocument: After
16
+ sort: {x: 1}
17
+ collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document
18
+
19
+ outcome:
20
+ result: {x: 'pong'}
21
+ collection:
22
+ data:
23
+ - {_id: 1, x: 11}
24
+ - {_id: 2, x: 'pong'}
@@ -0,0 +1,47 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 22}
4
+ - {_id: 3, x: 33}
5
+ minServerVersion: '2.6'
6
+ # See SERVER-5289 for why the collection data is only checked for server versions >= 2.6
7
+
8
+ tests:
9
+ -
10
+ description: "FindOneAndReplace when no documents match with upsert returning the document before modification"
11
+ operation:
12
+ name: findOneAndReplace
13
+ arguments:
14
+ filter: {_id: 4}
15
+ replacement: {x: 44}
16
+ projection: {x: 1, _id: 0}
17
+ sort: {x: 1}
18
+ upsert: true
19
+
20
+ outcome:
21
+ result: null
22
+ collection:
23
+ data:
24
+ - {_id: 1, x: 11}
25
+ - {_id: 2, x: 22}
26
+ - {_id: 3, x: 33}
27
+ - {_id: 4, x: 44}
28
+ -
29
+ description: "FindOneAndReplace when no documents match with upsert returning the document after modification"
30
+ operation:
31
+ name: findOneAndReplace
32
+ arguments:
33
+ filter: {_id: 4}
34
+ replacement: {x: 44}
35
+ projection: {x: 1, _id: 0}
36
+ returnDocument: After
37
+ sort: {x: 1}
38
+ upsert: true
39
+
40
+ outcome:
41
+ result: {x: 44}
42
+ collection:
43
+ data:
44
+ - {_id: 1, x: 11}
45
+ - {_id: 2, x: 22}
46
+ - {_id: 3, x: 33}
47
+ - {_id: 4, x: 44}