mongo 2.7.0 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) 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 +39 -14
  5. data/Rakefile +1 -0
  6. data/lib/mongo/auth.rb +4 -1
  7. data/lib/mongo/client.rb +4 -3
  8. data/lib/mongo/cluster.rb +1 -1
  9. data/lib/mongo/collection/view/readable.rb +5 -2
  10. data/lib/mongo/database.rb +1 -0
  11. data/lib/mongo/error/invalid_server_preference.rb +1 -0
  12. data/lib/mongo/error/operation_failure.rb +10 -0
  13. data/lib/mongo/error/parser.rb +10 -0
  14. data/lib/mongo/event.rb +1 -2
  15. data/lib/mongo/operation/result.rb +4 -1
  16. data/lib/mongo/operation/shared/executable_transaction_label.rb +3 -1
  17. data/lib/mongo/operation/shared/sessions_supported.rb +1 -1
  18. data/lib/mongo/protocol/msg.rb +1 -1
  19. data/lib/mongo/protocol/query.rb +2 -2
  20. data/lib/mongo/retryable.rb +20 -6
  21. data/lib/mongo/server.rb +6 -0
  22. data/lib/mongo/server/connection.rb +4 -4
  23. data/lib/mongo/server/monitor/connection.rb +9 -5
  24. data/lib/mongo/server_selector/selectable.rb +86 -32
  25. data/lib/mongo/session.rb +98 -15
  26. data/lib/mongo/version.rb +1 -1
  27. data/spec/README.md +85 -0
  28. data/spec/integration/bulk_insert_spec.rb +1 -1
  29. data/spec/integration/change_stream_examples_spec.rb +3 -1
  30. data/spec/integration/change_stream_spec.rb +10 -14
  31. data/spec/integration/client_construction_spec.rb +1 -0
  32. data/spec/integration/command_monitoring_spec.rb +37 -1
  33. data/spec/integration/command_spec.rb +141 -0
  34. data/spec/integration/connection_spec.rb +4 -2
  35. data/spec/integration/cursor_reaping_spec.rb +1 -1
  36. data/spec/integration/docs_examples_spec.rb +1 -1
  37. data/spec/integration/retryable_writes_spec.rb +33 -42
  38. data/spec/integration/server_description_spec.rb +3 -3
  39. data/spec/integration/server_selector_spec.rb +79 -0
  40. data/spec/lite_spec_helper.rb +4 -2
  41. data/spec/mongo/address_spec.rb +8 -0
  42. data/spec/mongo/auth/cr_spec.rb +5 -2
  43. data/spec/mongo/auth/invalid_mechanism_spec.rb +11 -0
  44. data/spec/mongo/auth/scram/conversation_spec.rb +3 -2
  45. data/spec/mongo/auth/scram/negotiation_spec.rb +1 -2
  46. data/spec/mongo/auth/scram_spec.rb +11 -6
  47. data/spec/mongo/auth/user/view_spec.rb +13 -6
  48. data/spec/mongo/bulk_write_spec.rb +81 -104
  49. data/spec/mongo/client_construction_spec.rb +18 -7
  50. data/spec/mongo/client_spec.rb +11 -7
  51. data/spec/mongo/cluster_spec.rb +30 -1
  52. data/spec/mongo/collection/view/aggregation_spec.rb +18 -10
  53. data/spec/mongo/collection/view/change_stream_spec.rb +28 -8
  54. data/spec/mongo/collection/view/map_reduce_spec.rb +24 -10
  55. data/spec/mongo/collection/view/readable_spec.rb +37 -19
  56. data/spec/mongo/collection/view/writable_spec.rb +64 -32
  57. data/spec/mongo/collection/view_spec.rb +4 -2
  58. data/spec/mongo/collection_spec.rb +163 -73
  59. data/spec/mongo/cursor_spec.rb +5 -2
  60. data/spec/mongo/database_spec.rb +41 -19
  61. data/spec/mongo/error/no_server_available_spec.rb +1 -1
  62. data/spec/mongo/error/parser_spec.rb +29 -0
  63. data/spec/mongo/grid/stream/write_spec.rb +2 -1
  64. data/spec/mongo/index/view_spec.rb +42 -24
  65. data/spec/mongo/operation/delete/op_msg_spec.rb +11 -7
  66. data/spec/mongo/operation/insert/op_msg_spec.rb +10 -6
  67. data/spec/mongo/operation/update/op_msg_spec.rb +10 -6
  68. data/spec/mongo/protocol/compressed_spec.rb +1 -1
  69. data/spec/mongo/protocol/msg_spec.rb +1 -1
  70. data/spec/mongo/server/app_metadata_spec.rb +2 -1
  71. data/spec/mongo/server/connection_auth_spec.rb +1 -1
  72. data/spec/mongo/server/monitor/connection_spec.rb +42 -0
  73. data/spec/mongo/server_selector_spec.rb +17 -0
  74. data/spec/mongo/server_spec.rb +110 -0
  75. data/spec/mongo/session/session_pool_spec.rb +1 -1
  76. data/spec/mongo/session_spec.rb +1 -1
  77. data/spec/mongo/session_transaction_spec.rb +162 -1
  78. data/spec/mongo/socket/ssl_spec.rb +14 -7
  79. data/spec/mongo/uri/srv_protocol_spec.rb +41 -34
  80. data/spec/spec_helper.rb +3 -191
  81. data/spec/spec_tests/change_streams_spec.rb +3 -6
  82. data/spec/spec_tests/data/transactions/abort.yml +3 -1
  83. data/spec/spec_tests/data/transactions/commit.yml +4 -3
  84. data/spec/spec_tests/data/transactions/error-labels.yml +17 -13
  85. data/spec/spec_tests/data/transactions/read-concern.yml +611 -0
  86. data/spec/spec_tests/data/transactions/retryable-commit.yml +126 -21
  87. data/spec/spec_tests/data/transactions_api/callback-aborts.yml +42 -39
  88. data/spec/spec_tests/data/transactions_api/callback-commits.yml +52 -50
  89. data/spec/spec_tests/data/transactions_api/callback-retry.yml +33 -31
  90. data/spec/spec_tests/data/transactions_api/commit-retry.yml +42 -39
  91. data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +13 -12
  92. data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +15 -26
  93. data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +25 -33
  94. data/spec/spec_tests/data/transactions_api/commit.yml +44 -42
  95. data/spec/spec_tests/data/transactions_api/transaction-options.yml +25 -23
  96. data/spec/spec_tests/max_staleness_spec.rb +2 -0
  97. data/spec/spec_tests/retryable_writes_spec.rb +2 -6
  98. data/spec/spec_tests/sdam_spec.rb +2 -0
  99. data/spec/spec_tests/server_selection_spec.rb +3 -0
  100. data/spec/spec_tests/transactions_api_spec.rb +7 -1
  101. data/spec/spec_tests/transactions_spec.rb +6 -0
  102. data/spec/spec_tests/uri_options_spec.rb +4 -26
  103. data/spec/support/certificates/ca.pem +21 -16
  104. data/spec/support/certificates/client.pem +90 -90
  105. data/spec/support/certificates/client_cert.pem +21 -20
  106. data/spec/support/certificates/client_key.pem +27 -28
  107. data/spec/support/certificates/client_key_encrypted.pem +26 -26
  108. data/spec/support/certificates/crl.pem +10 -8
  109. data/spec/support/certificates/crl_client_revoked.pem +11 -10
  110. data/spec/support/certificates/server.pem +48 -33
  111. data/spec/support/change_streams.rb +12 -32
  112. data/spec/support/client_registry.rb +12 -1
  113. data/spec/support/cluster_config.rb +48 -2
  114. data/spec/support/common_shortcuts.rb +73 -7
  115. data/spec/support/connection_string.rb +0 -3
  116. data/spec/support/constraints.rb +87 -22
  117. data/spec/support/crud.rb +2 -1
  118. data/spec/support/shared/server_selector.rb +0 -28
  119. data/spec/support/shared/session.rb +25 -14
  120. data/spec/support/transactions.rb +4 -8
  121. data/spec/support/transactions/operation.rb +26 -4
  122. data/spec/support/transactions/verifier.rb +5 -2
  123. metadata +496 -488
  124. metadata.gz.sig +5 -2
  125. data/spec/support/certificates/password_protected.pem +0 -51
@@ -72,7 +72,8 @@ tests:
72
72
  $numberLong: "1"
73
73
  startTransaction:
74
74
  autocommit: false
75
- writeConcern:
75
+ # commitTransaction applies w:majority on retries
76
+ writeConcern: { w: majority, wtimeout: 10000 }
76
77
  command_name: commitTransaction
77
78
  database_name: admin
78
79
  - command_started_event:
@@ -83,7 +84,99 @@ tests:
83
84
  $numberLong: "1"
84
85
  startTransaction:
85
86
  autocommit: false
87
+ writeConcern: { w: majority, wtimeout: 10000 }
88
+ command_name: commitTransaction
89
+ database_name: admin
90
+
91
+ outcome:
92
+ collection:
93
+ data:
94
+ - _id: 1
95
+
96
+ - description: commitTransaction applies majority write concern on retries
97
+
98
+ clientOptions:
99
+ retryWrites: false
100
+
101
+ failPoint:
102
+ configureFailPoint: failCommand
103
+ mode: { times: 2 }
104
+ data:
105
+ failCommands: ["commitTransaction"]
106
+ closeConnection: true
107
+
108
+ operations:
109
+ - name: startTransaction
110
+ object: session0
111
+ arguments:
112
+ options:
113
+ writeConcern: { w: 2, j: true, wtimeout: 5000 }
114
+ - name: insertOne
115
+ object: collection
116
+ arguments:
117
+ session: session0
118
+ document:
119
+ _id: 1
120
+ result:
121
+ insertedId: 1
122
+ # First call to commit fails after a single retry attempt.
123
+ - name: commitTransaction
124
+ object: session0
125
+ result:
126
+ errorLabelsContain: ["UnknownTransactionCommitResult"]
127
+ errorLabelsOmit: ["TransientTransactionError"]
128
+ # Second call to commit succeeds because the failpoint was disabled.
129
+ - name: commitTransaction
130
+ object: session0
131
+
132
+ expectations:
133
+ - command_started_event:
134
+ command:
135
+ insert: *collection_name
136
+ documents:
137
+ - _id: 1
138
+ ordered: true
139
+ readConcern:
140
+ lsid: session0
141
+ txnNumber:
142
+ $numberLong: "1"
143
+ startTransaction: true
144
+ autocommit: false
86
145
  writeConcern:
146
+ command_name: insert
147
+ database_name: *database_name
148
+ - command_started_event:
149
+ command:
150
+ commitTransaction: 1
151
+ lsid: session0
152
+ txnNumber:
153
+ $numberLong: "1"
154
+ startTransaction:
155
+ autocommit: false
156
+ writeConcern: { w: 2, j: true, wtimeout: 5000 }
157
+ command_name: commitTransaction
158
+ database_name: admin
159
+ - command_started_event:
160
+ command:
161
+ commitTransaction: 1
162
+ lsid: session0
163
+ txnNumber:
164
+ $numberLong: "1"
165
+ startTransaction:
166
+ autocommit: false
167
+ # commitTransaction applies w:majority on retries
168
+ writeConcern: { w: majority, j: true, wtimeout: 5000 }
169
+ command_name: commitTransaction
170
+ database_name: admin
171
+ - command_started_event:
172
+ command:
173
+ commitTransaction: 1
174
+ lsid: session0
175
+ txnNumber:
176
+ $numberLong: "1"
177
+ startTransaction:
178
+ autocommit: false
179
+ writeConcern: { w: majority, j: true, wtimeout: 5000 }
87
180
  command_name: commitTransaction
88
181
  database_name: admin
89
182
 
@@ -274,7 +367,8 @@ tests:
274
367
  $numberLong: "1"
275
368
  startTransaction:
276
369
  autocommit: false
277
- writeConcern:
370
+ # commitTransaction applies w:majority on retries
371
+ writeConcern: { w: majority, wtimeout: 10000 }
278
372
  command_name: commitTransaction
279
373
  database_name: admin
280
374
 
@@ -342,7 +436,8 @@ tests:
342
436
  $numberLong: "1"
343
437
  startTransaction:
344
438
  autocommit: false
345
- writeConcern:
439
+ # commitTransaction applies w:majority on retries
440
+ writeConcern: { w: majority, wtimeout: 10000 }
346
441
  command_name: commitTransaction
347
442
  database_name: admin
348
443
 
@@ -410,7 +505,8 @@ tests:
410
505
  $numberLong: "1"
411
506
  startTransaction:
412
507
  autocommit: false
413
- writeConcern:
508
+ # commitTransaction applies w:majority on retries
509
+ writeConcern: { w: majority, wtimeout: 10000 }
414
510
  command_name: commitTransaction
415
511
  database_name: admin
416
512
 
@@ -478,7 +574,8 @@ tests:
478
574
  $numberLong: "1"
479
575
  startTransaction:
480
576
  autocommit: false
481
- writeConcern:
577
+ # commitTransaction applies w:majority on retries
578
+ writeConcern: { w: majority, wtimeout: 10000 }
482
579
  command_name: commitTransaction
483
580
  database_name: admin
484
581
 
@@ -546,7 +643,8 @@ tests:
546
643
  $numberLong: "1"
547
644
  startTransaction:
548
645
  autocommit: false
549
- writeConcern:
646
+ # commitTransaction applies w:majority on retries
647
+ writeConcern: { w: majority, wtimeout: 10000 }
550
648
  command_name: commitTransaction
551
649
  database_name: admin
552
650
 
@@ -614,7 +712,8 @@ tests:
614
712
  $numberLong: "1"
615
713
  startTransaction:
616
714
  autocommit: false
617
- writeConcern:
715
+ # commitTransaction applies w:majority on retries
716
+ writeConcern: { w: majority, wtimeout: 10000 }
618
717
  command_name: commitTransaction
619
718
  database_name: admin
620
719
 
@@ -682,7 +781,8 @@ tests:
682
781
  $numberLong: "1"
683
782
  startTransaction:
684
783
  autocommit: false
685
- writeConcern:
784
+ # commitTransaction applies w:majority on retries
785
+ writeConcern: { w: majority, wtimeout: 10000 }
686
786
  command_name: commitTransaction
687
787
  database_name: admin
688
788
 
@@ -750,7 +850,8 @@ tests:
750
850
  $numberLong: "1"
751
851
  startTransaction:
752
852
  autocommit: false
753
- writeConcern:
853
+ # commitTransaction applies w:majority on retries
854
+ writeConcern: { w: majority, wtimeout: 10000 }
754
855
  command_name: commitTransaction
755
856
  database_name: admin
756
857
 
@@ -818,7 +919,8 @@ tests:
818
919
  $numberLong: "1"
819
920
  startTransaction:
820
921
  autocommit: false
821
- writeConcern:
922
+ # commitTransaction applies w:majority on retries
923
+ writeConcern: { w: majority, wtimeout: 10000 }
822
924
  command_name: commitTransaction
823
925
  database_name: admin
824
926
 
@@ -886,7 +988,8 @@ tests:
886
988
  $numberLong: "1"
887
989
  startTransaction:
888
990
  autocommit: false
889
- writeConcern:
991
+ # commitTransaction applies w:majority on retries
992
+ writeConcern: { w: majority, wtimeout: 10000 }
890
993
  command_name: commitTransaction
891
994
  database_name: admin
892
995
 
@@ -954,7 +1057,8 @@ tests:
954
1057
  $numberLong: "1"
955
1058
  startTransaction:
956
1059
  autocommit: false
957
- writeConcern:
1060
+ # commitTransaction applies w:majority on retries
1061
+ writeConcern: { w: majority, wtimeout: 10000 }
958
1062
  command_name: commitTransaction
959
1063
  database_name: admin
960
1064
 
@@ -1022,7 +1126,8 @@ tests:
1022
1126
  $numberLong: "1"
1023
1127
  startTransaction:
1024
1128
  autocommit: false
1025
- writeConcern:
1129
+ # commitTransaction applies w:majority on retries
1130
+ writeConcern: { w: majority, wtimeout: 10000 }
1026
1131
  command_name: commitTransaction
1027
1132
  database_name: admin
1028
1133
 
@@ -1096,8 +1201,8 @@ tests:
1096
1201
  $numberLong: "1"
1097
1202
  startTransaction:
1098
1203
  autocommit: false
1099
- writeConcern:
1100
- w: majority
1204
+ # commitTransaction applies w:majority on retries
1205
+ writeConcern: { w: majority, wtimeout: 10000 }
1101
1206
  command_name: commitTransaction
1102
1207
  database_name: admin
1103
1208
 
@@ -1171,8 +1276,8 @@ tests:
1171
1276
  $numberLong: "1"
1172
1277
  startTransaction:
1173
1278
  autocommit: false
1174
- writeConcern:
1175
- w: majority
1279
+ # commitTransaction applies w:majority on retries
1280
+ writeConcern: { w: majority, wtimeout: 10000 }
1176
1281
  command_name: commitTransaction
1177
1282
  database_name: admin
1178
1283
 
@@ -1246,8 +1351,8 @@ tests:
1246
1351
  $numberLong: "1"
1247
1352
  startTransaction:
1248
1353
  autocommit: false
1249
- writeConcern:
1250
- w: majority
1354
+ # commitTransaction applies w:majority on retries
1355
+ writeConcern: { w: majority, wtimeout: 10000 }
1251
1356
  command_name: commitTransaction
1252
1357
  database_name: admin
1253
1358
 
@@ -1321,8 +1426,8 @@ tests:
1321
1426
  $numberLong: "1"
1322
1427
  startTransaction:
1323
1428
  autocommit: false
1324
- writeConcern:
1325
- w: majority
1429
+ # commitTransaction applies w:majority on retries
1430
+ writeConcern: { w: majority, wtimeout: 10000 }
1326
1431
  command_name: commitTransaction
1327
1432
  database_name: admin
1328
1433
 
@@ -11,19 +11,20 @@ tests:
11
11
  -
12
12
  name: withTransaction
13
13
  object: session0
14
- callback:
15
- operations:
16
- -
17
- name: insertOne
18
- object: collection
19
- arguments:
20
- session: session0
21
- document: { _id: 1 }
22
- result:
23
- insertedId: 1
24
- -
25
- name: abortTransaction
26
- object: session0
14
+ arguments:
15
+ callback:
16
+ operations:
17
+ -
18
+ name: insertOne
19
+ object: collection
20
+ arguments:
21
+ session: session0
22
+ document: { _id: 1 }
23
+ result:
24
+ insertedId: 1
25
+ -
26
+ name: abortTransaction
27
+ object: session0
27
28
  expectations:
28
29
  -
29
30
  command_started_event:
@@ -64,11 +65,12 @@ tests:
64
65
  -
65
66
  name: withTransaction
66
67
  object: session0
67
- callback:
68
- operations:
69
- -
70
- name: abortTransaction
71
- object: session0
68
+ arguments:
69
+ callback:
70
+ operations:
71
+ -
72
+ name: abortTransaction
73
+ object: session0
72
74
  expectations: []
73
75
  outcome:
74
76
  collection:
@@ -80,27 +82,28 @@ tests:
80
82
  -
81
83
  name: withTransaction
82
84
  object: session0
83
- callback:
84
- operations:
85
- -
86
- name: insertOne
87
- object: collection
88
- arguments:
89
- session: session0
90
- document: { _id: 1 }
91
- result:
92
- insertedId: 1
93
- -
94
- name: abortTransaction
95
- object: session0
96
- -
97
- name: insertOne
98
- object: collection
99
- arguments:
100
- session: session0
101
- document: { _id: 2 }
102
- result:
103
- insertedId: 2
85
+ arguments:
86
+ callback:
87
+ operations:
88
+ -
89
+ name: insertOne
90
+ object: collection
91
+ arguments:
92
+ session: session0
93
+ document: { _id: 1 }
94
+ result:
95
+ insertedId: 1
96
+ -
97
+ name: abortTransaction
98
+ object: session0
99
+ -
100
+ name: insertOne
101
+ object: collection
102
+ arguments:
103
+ session: session0
104
+ document: { _id: 2 }
105
+ result:
106
+ insertedId: 2
104
107
  expectations:
105
108
  -
106
109
  command_started_event:
@@ -11,27 +11,28 @@ tests:
11
11
  -
12
12
  name: withTransaction
13
13
  object: session0
14
- callback:
15
- operations:
16
- -
17
- name: insertOne
18
- object: collection
19
- arguments:
20
- session: session0
21
- document: { _id: 1 }
22
- result:
23
- insertedId: 1
24
- -
25
- name: insertOne
26
- object: collection
27
- arguments:
28
- session: session0
29
- document: { _id: 2 }
30
- result:
31
- insertedId: 2
32
- -
33
- name: commitTransaction
34
- object: session0
14
+ arguments:
15
+ callback:
16
+ operations:
17
+ -
18
+ name: insertOne
19
+ object: collection
20
+ arguments:
21
+ session: session0
22
+ document: { _id: 1 }
23
+ result:
24
+ insertedId: 1
25
+ -
26
+ name: insertOne
27
+ object: collection
28
+ arguments:
29
+ session: session0
30
+ document: { _id: 2 }
31
+ result:
32
+ insertedId: 2
33
+ -
34
+ name: commitTransaction
35
+ object: session0
35
36
  expectations:
36
37
  -
37
38
  command_started_event:
@@ -90,35 +91,36 @@ tests:
90
91
  -
91
92
  name: withTransaction
92
93
  object: session0
93
- callback:
94
- operations:
95
- -
96
- name: insertOne
97
- object: collection
98
- arguments:
99
- session: session0
100
- document: { _id: 1 }
101
- result:
102
- insertedId: 1
103
- -
104
- name: insertOne
105
- object: collection
106
- arguments:
107
- session: session0
108
- document: { _id: 2 }
109
- result:
110
- insertedId: 2
111
- -
112
- name: commitTransaction
113
- object: session0
114
- -
115
- name: insertOne
116
- object: collection
117
- arguments:
118
- session: session0
119
- document: { _id: 3 }
120
- result:
121
- insertedId: 3
94
+ arguments:
95
+ callback:
96
+ operations:
97
+ -
98
+ name: insertOne
99
+ object: collection
100
+ arguments:
101
+ session: session0
102
+ document: { _id: 1 }
103
+ result:
104
+ insertedId: 1
105
+ -
106
+ name: insertOne
107
+ object: collection
108
+ arguments:
109
+ session: session0
110
+ document: { _id: 2 }
111
+ result:
112
+ insertedId: 2
113
+ -
114
+ name: commitTransaction
115
+ object: session0
116
+ -
117
+ name: insertOne
118
+ object: collection
119
+ arguments:
120
+ session: session0
121
+ document: { _id: 3 }
122
+ result:
123
+ insertedId: 3
122
124
  expectations:
123
125
  -
124
126
  command_started_event: