mongo 2.18.0.beta1 → 2.18.0

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 (149) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/mongo/bulk_write.rb +8 -2
  4. data/lib/mongo/client.rb +19 -5
  5. data/lib/mongo/client_encryption.rb +86 -4
  6. data/lib/mongo/cluster.rb +6 -4
  7. data/lib/mongo/collection/view/aggregation.rb +3 -0
  8. data/lib/mongo/collection/view/change_stream.rb +9 -0
  9. data/lib/mongo/collection/view/iterable.rb +1 -0
  10. data/lib/mongo/collection/view/readable.rb +11 -3
  11. data/lib/mongo/collection.rb +9 -1
  12. data/lib/mongo/config.rb +11 -0
  13. data/lib/mongo/crypt/auto_encrypter.rb +49 -21
  14. data/lib/mongo/crypt/binding.rb +73 -48
  15. data/lib/mongo/crypt/data_key_context.rb +6 -1
  16. data/lib/mongo/crypt/encryption_io.rb +66 -0
  17. data/lib/mongo/crypt/explicit_encrypter.rb +116 -5
  18. data/lib/mongo/crypt/explicit_encryption_context.rb +3 -8
  19. data/lib/mongo/crypt/handle.rb +26 -8
  20. data/lib/mongo/crypt/kms/aws.rb +11 -3
  21. data/lib/mongo/crypt/kms/azure.rb +14 -6
  22. data/lib/mongo/crypt/kms/gcp.rb +12 -5
  23. data/lib/mongo/crypt/kms/kmip.rb +15 -9
  24. data/lib/mongo/crypt/kms/local.rb +9 -1
  25. data/lib/mongo/crypt/kms/master_key_document.rb +1 -1
  26. data/lib/mongo/crypt/rewrap_many_data_key_context.rb +46 -0
  27. data/lib/mongo/crypt/rewrap_many_data_key_result.rb +37 -0
  28. data/lib/mongo/crypt/status.rb +8 -2
  29. data/lib/mongo/crypt.rb +2 -0
  30. data/lib/mongo/database.rb +10 -27
  31. data/lib/mongo/error/missing_file_chunk.rb +8 -2
  32. data/lib/mongo/grid/stream/read.rb +6 -0
  33. data/lib/mongo/index/view.rb +1 -0
  34. data/lib/mongo/operation/create/op_msg.rb +1 -13
  35. data/lib/mongo/operation/distinct/op_msg.rb +4 -1
  36. data/lib/mongo/protocol/msg.rb +0 -16
  37. data/lib/mongo/server/connection_pool.rb +5 -4
  38. data/lib/mongo/server/monitor/connection.rb +10 -4
  39. data/lib/mongo/server/monitor.rb +4 -0
  40. data/lib/mongo/server/push_monitor.rb +4 -0
  41. data/lib/mongo/version.rb +1 -1
  42. data/lib/mongo.rb +2 -0
  43. data/spec/README.md +14 -0
  44. data/spec/integration/change_stream_spec.rb +1 -1
  45. data/spec/integration/client_construction_spec.rb +73 -7
  46. data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +165 -164
  47. data/spec/integration/client_side_encryption/decryption_events_prose_spec.rb +158 -0
  48. data/spec/integration/client_side_encryption/explicit_queryable_encryption_spec.rb +5 -5
  49. data/spec/integration/client_side_encryption/kms_tls_options_spec.rb +50 -8
  50. data/spec/integration/client_side_encryption/unique_index_on_key_alt_names_prose_spec.rb +85 -0
  51. data/spec/integration/ocsp_verifier_spec.rb +1 -1
  52. data/spec/integration/reconnect_spec.rb +2 -0
  53. data/spec/integration/sdam_events_spec.rb +40 -0
  54. data/spec/integration/srv_monitoring_spec.rb +1 -0
  55. data/spec/integration/srv_spec.rb +1 -0
  56. data/spec/lite_spec_helper.rb +5 -4
  57. data/spec/mongo/bulk_write_spec.rb +13 -0
  58. data/spec/mongo/client_construction_spec.rb +45 -2
  59. data/spec/mongo/client_encryption_spec.rb +0 -12
  60. data/spec/mongo/client_spec.rb +1 -1
  61. data/spec/mongo/collection/view/aggregation_spec.rb +119 -0
  62. data/spec/mongo/collection/view/readable_spec.rb +630 -5
  63. data/spec/mongo/collection_spec.rb +32 -0
  64. data/spec/mongo/crypt/auto_encrypter_spec.rb +110 -0
  65. data/spec/mongo/crypt/binding/context_spec.rb +3 -35
  66. data/spec/mongo/crypt/data_key_context_spec.rb +1 -1
  67. data/spec/mongo/crypt/explicit_encryption_context_spec.rb +8 -3
  68. data/spec/mongo/crypt/handle_spec.rb +39 -3
  69. data/spec/mongo/crypt/kms/credentials_spec.rb +0 -47
  70. data/spec/mongo/index/view_spec.rb +56 -0
  71. data/spec/mongo/operation/create/op_msg_spec.rb +0 -42
  72. data/spec/mongo/server/connection_pool_spec.rb +26 -4
  73. data/spec/mongo/socket/ssl_spec.rb +3 -3
  74. data/spec/runners/crud/requirement.rb +6 -1
  75. data/spec/runners/crud/test.rb +1 -1
  76. data/spec/runners/transactions/spec.rb +2 -2
  77. data/spec/runners/transactions/test.rb +4 -20
  78. data/spec/runners/transactions.rb +2 -2
  79. data/spec/runners/unified/assertions.rb +32 -2
  80. data/spec/runners/unified/change_stream_operations.rb +3 -0
  81. data/spec/runners/unified/client_side_encryption_operations.rb +83 -0
  82. data/spec/runners/unified/crud_operations.rb +17 -2
  83. data/spec/runners/unified/ddl_operations.rb +27 -2
  84. data/spec/runners/unified/grid_fs_operations.rb +21 -0
  85. data/spec/runners/unified/test.rb +59 -1
  86. data/spec/shared/lib/mrss/docker_runner.rb +2 -0
  87. data/spec/shared/lib/mrss/eg_config_utils.rb +51 -0
  88. data/spec/shared/lib/mrss/lite_constraints.rb +10 -2
  89. data/spec/shared/shlib/set_env.sh +3 -0
  90. data/spec/solo/clean_exit_spec.rb +5 -0
  91. data/spec/spec_tests/client_side_encryption_spec.rb +1 -1
  92. data/spec/spec_tests/client_side_encryption_unified_spec.rb +16 -0
  93. data/spec/spec_tests/data/change_streams_unified/change-streams-showExpandedEvents.yml +298 -0
  94. data/spec/spec_tests/data/client_side_encryption/create-and-createIndexes.yml +58 -0
  95. data/spec/spec_tests/data/client_side_encryption/fle2-Delete.yml +1 -1
  96. data/spec/spec_tests/data/client_side_encryption/fle2-EncryptedFields-vs-jsonSchema.yml +1 -1
  97. data/spec/spec_tests/data/client_side_encryption/fle2-FindOneAndUpdate.yml +2 -2
  98. data/spec/spec_tests/data/client_side_encryption/fle2-InsertFind-Indexed.yml +1 -1
  99. data/spec/spec_tests/data/client_side_encryption/fle2-Update.yml +2 -2
  100. data/spec/spec_tests/data/client_side_encryption/unified/addKeyAltName.yml +194 -0
  101. data/spec/spec_tests/data/client_side_encryption/unified/createDataKey-kms_providers-invalid.yml +67 -0
  102. data/spec/spec_tests/data/client_side_encryption/unified/createDataKey.yml +309 -0
  103. data/spec/spec_tests/data/client_side_encryption/unified/deleteKey.yml +159 -0
  104. data/spec/spec_tests/data/client_side_encryption/unified/getKey.yml +105 -0
  105. data/spec/spec_tests/data/client_side_encryption/unified/getKeyByAltName.yml +104 -0
  106. data/spec/spec_tests/data/client_side_encryption/unified/getKeys.yml +122 -0
  107. data/spec/spec_tests/data/client_side_encryption/unified/removeKeyAltName.yml +157 -0
  108. data/spec/spec_tests/data/client_side_encryption/unified/rewrapManyDataKey-decrypt_failure.yml +69 -0
  109. data/spec/spec_tests/data/client_side_encryption/unified/rewrapManyDataKey-encrypt_failure.yml +122 -0
  110. data/spec/spec_tests/data/client_side_encryption/unified/rewrapManyDataKey.yml +432 -0
  111. data/spec/spec_tests/data/client_side_encryption/validatorAndPartialFieldExpression.yml +166 -0
  112. data/spec/spec_tests/data/command_monitoring_unified/bulkWrite.yml +68 -0
  113. data/spec/spec_tests/data/command_monitoring_unified/command.yml +50 -0
  114. data/spec/spec_tests/data/command_monitoring_unified/deleteMany.yml +79 -0
  115. data/spec/spec_tests/data/command_monitoring_unified/deleteOne.yml +79 -0
  116. data/spec/spec_tests/data/command_monitoring_unified/find.yml +254 -0
  117. data/spec/spec_tests/data/command_monitoring_unified/insertMany.yml +79 -0
  118. data/spec/spec_tests/data/command_monitoring_unified/insertOne.yml +77 -0
  119. data/spec/spec_tests/data/command_monitoring_unified/unacknowledgedBulkWrite.yml +55 -0
  120. data/spec/spec_tests/data/command_monitoring_unified/updateMany.yml +87 -0
  121. data/spec/spec_tests/data/command_monitoring_unified/updateOne.yml +118 -0
  122. data/spec/spec_tests/data/crud_unified/distinct-comment.yml +98 -0
  123. data/spec/spec_tests/data/gridfs_unified/delete.yml +198 -0
  124. data/spec/spec_tests/data/gridfs_unified/download.yml +241 -0
  125. data/spec/spec_tests/data/gridfs_unified/downloadByName.yml +159 -0
  126. data/spec/spec_tests/data/gridfs_unified/upload-disableMD5.yml +92 -0
  127. data/spec/spec_tests/data/gridfs_unified/upload.yml +288 -0
  128. data/spec/spec_tests/gridfs_unified_spec.rb +13 -0
  129. data/spec/stress/connection_pool_timing_spec.rb +2 -2
  130. data/spec/support/background_thread_registry.rb +3 -13
  131. data/spec/support/certificates/atlas-ocsp-ca.crt +40 -47
  132. data/spec/support/certificates/atlas-ocsp.crt +101 -106
  133. data/spec/support/crypt.rb +57 -13
  134. data/spec/support/macros.rb +10 -0
  135. data/spec/support/spec_config.rb +4 -0
  136. data.tar.gz.sig +0 -0
  137. metadata +1271 -1219
  138. metadata.gz.sig +0 -0
  139. data/spec/spec_tests/command_monitoring_spec.rb +0 -71
  140. data/spec/spec_tests/data/command_monitoring/bulkWrite.yml +0 -49
  141. data/spec/spec_tests/data/command_monitoring/command.yml +0 -61
  142. data/spec/spec_tests/data/command_monitoring/deleteMany.yml +0 -55
  143. data/spec/spec_tests/data/command_monitoring/deleteOne.yml +0 -55
  144. data/spec/spec_tests/data/command_monitoring/find.yml +0 -266
  145. data/spec/spec_tests/data/command_monitoring/insertMany.yml +0 -75
  146. data/spec/spec_tests/data/command_monitoring/insertOne.yml +0 -51
  147. data/spec/spec_tests/data/command_monitoring/unacknowledgedBulkWrite.yml +0 -34
  148. data/spec/spec_tests/data/command_monitoring/updateMany.yml +0 -65
  149. data/spec/spec_tests/data/command_monitoring/updateOne.yml +0 -90
@@ -0,0 +1,87 @@
1
+ description: "updateMany"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client client
8
+ observeEvents:
9
+ - commandStartedEvent
10
+ - commandSucceededEvent
11
+ - commandFailedEvent
12
+ - database:
13
+ id: &database database
14
+ client: *client
15
+ databaseName: &databaseName command-monitoring-tests
16
+ - collection:
17
+ id: &collection collection
18
+ database: *database
19
+ collectionName: &collectionName test
20
+
21
+ initialData:
22
+ - collectionName: *collectionName
23
+ databaseName: *databaseName
24
+ documents:
25
+ - { _id: 1, x: 11 }
26
+ - { _id: 2, x: 22 }
27
+ - { _id: 3, x: 33 }
28
+
29
+ tests:
30
+ - description: "A successful updateMany"
31
+ operations:
32
+ - name: updateMany
33
+ object: *collection
34
+ arguments:
35
+ filter: { _id: { $gt: 1 } }
36
+ update: { $inc: { x: 1 } }
37
+ expectEvents:
38
+ - client: *client
39
+ events:
40
+ - commandStartedEvent:
41
+ command:
42
+ update: *collectionName
43
+ updates:
44
+ - q: { _id: { $gt: 1 } }
45
+ u: { $inc: { x: 1 } }
46
+ upsert: { $$unsetOrMatches: false }
47
+ multi: true
48
+ ordered: true
49
+ commandName: update
50
+ databaseName: *databaseName
51
+ - commandSucceededEvent:
52
+ reply: { ok: 1, n: 2 }
53
+ commandName: update
54
+
55
+ - description: "A successful updateMany with write errors"
56
+ operations:
57
+ - name: updateMany
58
+ object: *collection
59
+ arguments:
60
+ filter: { _id: { $gt: 1 } }
61
+ update: { $unsupported: { x: 1 } }
62
+ expectError:
63
+ isClientError: false
64
+ expectEvents:
65
+ - client: *client
66
+ events:
67
+ - commandStartedEvent:
68
+ command:
69
+ update: *collectionName
70
+ updates:
71
+ - q: { _id: { $gt: 1 } }
72
+ u: { $unsupported: { x: 1 } }
73
+ upsert: { $$unsetOrMatches: false }
74
+ multi: true
75
+ ordered: true
76
+ commandName: update
77
+ databaseName: *databaseName
78
+ - commandSucceededEvent:
79
+ reply:
80
+ ok: 1
81
+ n: 0
82
+ # The legacy version of this test included an assertion that writeErrors contained a single document
83
+ # with index=0, a "code" value, and a non-empty "errmsg". However, writeErrors can contain extra fields
84
+ # beyond these, and the unified format currently does not permit allowing extra fields in sub-documents,
85
+ # so those assertions are not present here.
86
+ writeErrors: { $$type: array }
87
+ commandName: update
@@ -0,0 +1,118 @@
1
+ description: "updateOne"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client client
8
+ observeEvents:
9
+ - commandStartedEvent
10
+ - commandSucceededEvent
11
+ - commandFailedEvent
12
+ - database:
13
+ id: &database database
14
+ client: *client
15
+ databaseName: &databaseName command-monitoring-tests
16
+ - collection:
17
+ id: &collection collection
18
+ database: *database
19
+ collectionName: &collectionName test
20
+
21
+ initialData:
22
+ - collectionName: *collectionName
23
+ databaseName: *databaseName
24
+ documents:
25
+ - { _id: 1, x: 11 }
26
+ - { _id: 2, x: 22 }
27
+ - { _id: 3, x: 33 }
28
+
29
+ tests:
30
+ - description: "A successful updateOne"
31
+ operations:
32
+ - name: updateOne
33
+ object: *collection
34
+ arguments:
35
+ filter: { _id: { $gt: 1 } }
36
+ update: { $inc: { x: 1 } }
37
+ expectEvents:
38
+ - client: *client
39
+ events:
40
+ - commandStartedEvent:
41
+ command:
42
+ update: *collectionName
43
+ updates:
44
+ - q: { _id: { $gt: 1 } }
45
+ u: { $inc: { x: 1 } }
46
+ upsert: { $$unsetOrMatches: false }
47
+ multi: { $$unsetOrMatches: false }
48
+ ordered: true
49
+ commandName: update
50
+ databaseName: *databaseName
51
+ - commandSucceededEvent:
52
+ reply: { ok: 1, n: 1 }
53
+ commandName: update
54
+
55
+ - description: "A successful updateOne with upsert where the upserted id is not an ObjectId"
56
+ operations:
57
+ - name: updateOne
58
+ object: *collection
59
+ arguments:
60
+ filter: { _id: 4 }
61
+ update: { $inc: { x: 1 } }
62
+ upsert: true
63
+ expectEvents:
64
+ - client: *client
65
+ events:
66
+ - commandStartedEvent:
67
+ command:
68
+ update: *collectionName
69
+ updates:
70
+ - q: { _id: 4 }
71
+ u: { $inc: { x: 1 } }
72
+ upsert: true
73
+ multi: { $$unsetOrMatches: false }
74
+ ordered: true
75
+ commandName: update
76
+ databaseName: *databaseName
77
+ - commandSucceededEvent:
78
+ reply:
79
+ ok: 1
80
+ n: 1
81
+ upserted:
82
+ - index: 0
83
+ _id: 4
84
+ commandName: update
85
+
86
+ - description: "A successful updateOne with write errors"
87
+ operations:
88
+ - name: updateOne
89
+ object: *collection
90
+ arguments:
91
+ filter: { _id: { $gt: 1 } }
92
+ update: { $unsupported: { x: 1 } }
93
+ expectError:
94
+ isClientError: false
95
+ expectEvents:
96
+ - client: *client
97
+ events:
98
+ - commandStartedEvent:
99
+ command:
100
+ update: *collectionName
101
+ updates:
102
+ - q: { _id: { $gt: 1 } }
103
+ u: { $unsupported: { x: 1 } }
104
+ upsert: { $$unsetOrMatches: false }
105
+ multi: { $$unsetOrMatches: false }
106
+ ordered: true
107
+ commandName: update
108
+ databaseName: *databaseName
109
+ - commandSucceededEvent:
110
+ reply:
111
+ ok: 1
112
+ n: 0
113
+ # The legacy version of this test included an assertion that writeErrors contained a single document
114
+ # with index=0, a "code" value, and a non-empty "errmsg". However, writeErrors can contain extra fields
115
+ # beyond these, and the unified format currently does not permit allowing extra fields in sub-documents,
116
+ # so those assertions are not present here.
117
+ writeErrors: { $$type: array }
118
+ commandName: update
@@ -0,0 +1,98 @@
1
+ description: "distinct-comment"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ observeEvents: [ commandStartedEvent ]
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: &database0Name distinct-comment-tests
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: &collection0Name coll0
17
+
18
+ initialData:
19
+ - collectionName: *collection0Name
20
+ databaseName: *database0Name
21
+ documents:
22
+ - { _id: 1, x: 11 }
23
+ - { _id: 2, x: 22 }
24
+ - { _id: 3, x: 33 }
25
+
26
+ tests:
27
+ - description: "distinct with document comment"
28
+ runOnRequirements:
29
+ # https://jira.mongodb.org/browse/SERVER-44847
30
+ # Server supports distinct with comment of any type for comment starting from 4.4.14.
31
+ - minServerVersion: "4.4.14"
32
+ operations:
33
+ - name: distinct
34
+ object: *collection0
35
+ arguments:
36
+ fieldName: &fieldName x
37
+ filter: &filter {}
38
+ comment: &documentComment { key: "value"}
39
+ expectResult: [ 11, 22, 33 ]
40
+ expectEvents:
41
+ - client: *client0
42
+ events:
43
+ - commandStartedEvent:
44
+ command:
45
+ distinct: *collection0Name
46
+ key: *fieldName
47
+ query: *filter
48
+ comment: *documentComment
49
+ commandName: distinct
50
+ databaseName: *database0Name
51
+
52
+ - description: "distinct with string comment"
53
+ runOnRequirements:
54
+ - minServerVersion: "4.4.0"
55
+ operations:
56
+ - name: distinct
57
+ object: *collection0
58
+ arguments:
59
+ fieldName: *fieldName
60
+ filter: *filter
61
+ comment: &stringComment "comment"
62
+ expectResult: [ 11, 22, 33 ]
63
+ expectEvents:
64
+ - client: *client0
65
+ events:
66
+ - commandStartedEvent:
67
+ command:
68
+ distinct: *collection0Name
69
+ key: *fieldName
70
+ query: *filter
71
+ comment: *stringComment
72
+ commandName: distinct
73
+ databaseName: *database0Name
74
+
75
+ - description: "distinct with document comment - pre 4.4, server error"
76
+ runOnRequirements:
77
+ - minServerVersion: "3.6.0"
78
+ maxServerVersion: "4.4.13"
79
+ operations:
80
+ - name: distinct
81
+ object: *collection0
82
+ arguments:
83
+ fieldName: *fieldName
84
+ filter: *filter
85
+ comment: *documentComment
86
+ expectError:
87
+ isClientError: false
88
+ expectEvents:
89
+ - client: *client0
90
+ events:
91
+ - commandStartedEvent:
92
+ command:
93
+ distinct: *collection0Name
94
+ key: *fieldName
95
+ query: *filter
96
+ comment: *documentComment
97
+ commandName: distinct
98
+ databaseName: *database0Name
@@ -0,0 +1,198 @@
1
+ description: "gridfs-delete"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ - database:
9
+ id: &database0 database0
10
+ client: *client0
11
+ databaseName: &database0Name gridfs-tests
12
+ - bucket:
13
+ id: &bucket0 bucket0
14
+ database: *database0
15
+ - collection:
16
+ id: &bucket0_files_collection bucket0_files_collection
17
+ database: *database0
18
+ collectionName: &bucket0_files_collectionName fs.files
19
+ - collection:
20
+ id: &bucket0_chunks_collection bucket0_chunks_collection
21
+ database: *database0
22
+ collectionName: &bucket0_chunks_collectionName fs.chunks
23
+
24
+ initialData:
25
+ - collectionName: *bucket0_files_collectionName
26
+ databaseName: *database0Name
27
+ documents:
28
+ - &file1
29
+ _id: { "$oid": "000000000000000000000001" }
30
+ length: 0
31
+ chunkSize: 4
32
+ uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
33
+ md5: "d41d8cd98f00b204e9800998ecf8427e"
34
+ filename: "length-0"
35
+ contentType: "application/octet-stream"
36
+ aliases: []
37
+ metadata: {}
38
+ - &file2
39
+ _id: { "$oid": "000000000000000000000002" }
40
+ length: 0
41
+ chunkSize: 4
42
+ uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
43
+ md5: "d41d8cd98f00b204e9800998ecf8427e"
44
+ filename: "length-0-with-empty-chunk"
45
+ contentType: "application/octet-stream"
46
+ aliases: []
47
+ metadata: {}
48
+ - &file3
49
+ _id: { "$oid": "000000000000000000000003" }
50
+ length: 2
51
+ chunkSize: 4
52
+ uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
53
+ md5: "c700ed4fdb1d27055aa3faa2c2432283"
54
+ filename: "length-2"
55
+ contentType: "application/octet-stream"
56
+ aliases: []
57
+ metadata: {}
58
+ - &file4
59
+ _id: { "$oid": "000000000000000000000004" }
60
+ length: 8
61
+ chunkSize: 4
62
+ uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
63
+ md5: "dd254cdc958e53abaa67da9f797125f5"
64
+ filename: "length-8"
65
+ contentType: "application/octet-stream"
66
+ aliases: []
67
+ metadata: {}
68
+ - collectionName: *bucket0_chunks_collectionName
69
+ databaseName: *database0Name
70
+ documents:
71
+ - &file2_chunk0
72
+ _id: { "$oid": "000000000000000000000001" }
73
+ files_id: { "$oid": "000000000000000000000002" }
74
+ n: 0
75
+ data: { "$binary": { "base64": "", "subType": "00" } }
76
+ - &file3_chunk0
77
+ _id: { "$oid": "000000000000000000000002" }
78
+ files_id: { "$oid": "000000000000000000000003" }
79
+ n: 0
80
+ data: { "$binary": { "base64": "ESI=", "subType": "00" } } # hex: 1122
81
+ - &file4_chunk0
82
+ _id: { "$oid": "000000000000000000000003" }
83
+ files_id: { "$oid": "000000000000000000000004" }
84
+ n: 0
85
+ data: { "$binary": { "base64": "ESIzRA==", "subType": "00" } } # hex: 11223344
86
+ - &file4_chunk1
87
+ _id: { "$oid": "000000000000000000000004" }
88
+ files_id: { "$oid": "000000000000000000000004" }
89
+ n: 1
90
+ data: { "$binary": { "base64": "VWZ3iA==", "subType": "00" } } # hex: 55667788
91
+
92
+ tests:
93
+ - description: "delete when length is 0"
94
+ operations:
95
+ - name: delete
96
+ object: *bucket0
97
+ arguments:
98
+ id: { $oid: "000000000000000000000001" }
99
+ outcome:
100
+ - collectionName: *bucket0_files_collectionName
101
+ databaseName: *database0Name
102
+ documents:
103
+ - *file2
104
+ - *file3
105
+ - *file4
106
+ - collectionName: *bucket0_chunks_collectionName
107
+ databaseName: *database0Name
108
+ documents:
109
+ - *file2_chunk0
110
+ - *file3_chunk0
111
+ - *file4_chunk0
112
+ - *file4_chunk1
113
+ - description: "delete when length is 0 and there is one extra empty chunk"
114
+ operations:
115
+ - name: delete
116
+ object: *bucket0
117
+ arguments:
118
+ id: { $oid: "000000000000000000000002" }
119
+ outcome:
120
+ - collectionName: *bucket0_files_collectionName
121
+ databaseName: *database0Name
122
+ documents:
123
+ - *file1
124
+ - *file3
125
+ - *file4
126
+ - collectionName: *bucket0_chunks_collectionName
127
+ databaseName: *database0Name
128
+ documents:
129
+ - *file3_chunk0
130
+ - *file4_chunk0
131
+ - *file4_chunk1
132
+ - description: "delete when length is 8"
133
+ operations:
134
+ - name: delete
135
+ object: *bucket0
136
+ arguments:
137
+ id: { $oid: "000000000000000000000004" }
138
+ outcome:
139
+ - collectionName: *bucket0_files_collectionName
140
+ databaseName: *database0Name
141
+ documents:
142
+ - *file1
143
+ - *file2
144
+ - *file3
145
+ - collectionName: *bucket0_chunks_collectionName
146
+ databaseName: *database0Name
147
+ documents:
148
+ - *file2_chunk0
149
+ - *file3_chunk0
150
+ - description: "delete when files entry does not exist"
151
+ operations:
152
+ - name: delete
153
+ object: *bucket0
154
+ arguments:
155
+ id: { $oid: "000000000000000000000000" }
156
+ expectError: { isError: true } # FileNotFound
157
+ outcome:
158
+ - collectionName: *bucket0_files_collectionName
159
+ databaseName: *database0Name
160
+ documents:
161
+ - *file1
162
+ - *file2
163
+ - *file3
164
+ - *file4
165
+ - collectionName: *bucket0_chunks_collectionName
166
+ databaseName: *database0Name
167
+ documents:
168
+ - *file2_chunk0
169
+ - *file3_chunk0
170
+ - *file4_chunk0
171
+ - *file4_chunk1
172
+ - description: "delete when files entry does not exist and there are orphaned chunks"
173
+ operations:
174
+ - name: deleteOne
175
+ object: *bucket0_files_collection
176
+ arguments:
177
+ filter:
178
+ _id: { $oid: "000000000000000000000004" }
179
+ expectResult:
180
+ deletedCount: 1
181
+ - name: delete
182
+ object: *bucket0
183
+ arguments:
184
+ id: { $oid: "000000000000000000000004" }
185
+ expectError: { isError: true } # FileNotFound
186
+ outcome:
187
+ - collectionName: *bucket0_files_collectionName
188
+ databaseName: *database0Name
189
+ documents:
190
+ - *file1
191
+ - *file2
192
+ - *file3
193
+ # Orphaned chunks are still deleted even if fs.files
194
+ - collectionName: *bucket0_chunks_collectionName
195
+ databaseName: *database0Name
196
+ documents:
197
+ - *file2_chunk0
198
+ - *file3_chunk0