mongo 2.18.0.beta1 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/mongo/bulk_write.rb +8 -2
- data/lib/mongo/client.rb +19 -5
- data/lib/mongo/client_encryption.rb +86 -4
- data/lib/mongo/cluster.rb +6 -4
- data/lib/mongo/collection/view/aggregation.rb +3 -0
- data/lib/mongo/collection/view/change_stream.rb +9 -0
- data/lib/mongo/collection/view/iterable.rb +1 -0
- data/lib/mongo/collection/view/readable.rb +11 -3
- data/lib/mongo/collection.rb +9 -1
- data/lib/mongo/config.rb +11 -0
- data/lib/mongo/crypt/auto_encrypter.rb +49 -21
- data/lib/mongo/crypt/binding.rb +73 -48
- data/lib/mongo/crypt/data_key_context.rb +6 -1
- data/lib/mongo/crypt/encryption_io.rb +66 -0
- data/lib/mongo/crypt/explicit_encrypter.rb +116 -5
- data/lib/mongo/crypt/explicit_encryption_context.rb +3 -8
- data/lib/mongo/crypt/handle.rb +26 -8
- data/lib/mongo/crypt/kms/aws.rb +11 -3
- data/lib/mongo/crypt/kms/azure.rb +14 -6
- data/lib/mongo/crypt/kms/gcp.rb +12 -5
- data/lib/mongo/crypt/kms/kmip.rb +15 -9
- data/lib/mongo/crypt/kms/local.rb +9 -1
- data/lib/mongo/crypt/kms/master_key_document.rb +1 -1
- data/lib/mongo/crypt/rewrap_many_data_key_context.rb +46 -0
- data/lib/mongo/crypt/rewrap_many_data_key_result.rb +37 -0
- data/lib/mongo/crypt/status.rb +8 -2
- data/lib/mongo/crypt.rb +2 -0
- data/lib/mongo/database.rb +10 -27
- data/lib/mongo/error/missing_file_chunk.rb +8 -2
- data/lib/mongo/grid/stream/read.rb +6 -0
- data/lib/mongo/index/view.rb +1 -0
- data/lib/mongo/operation/create/op_msg.rb +1 -13
- data/lib/mongo/operation/distinct/op_msg.rb +4 -1
- data/lib/mongo/protocol/msg.rb +0 -16
- data/lib/mongo/server/connection_pool.rb +5 -4
- data/lib/mongo/server/monitor/connection.rb +10 -4
- data/lib/mongo/server/monitor.rb +4 -0
- data/lib/mongo/server/push_monitor.rb +4 -0
- data/lib/mongo/version.rb +1 -1
- data/lib/mongo.rb +2 -0
- data/spec/README.md +14 -0
- data/spec/integration/change_stream_spec.rb +1 -1
- data/spec/integration/client_construction_spec.rb +73 -7
- data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +165 -164
- data/spec/integration/client_side_encryption/decryption_events_prose_spec.rb +158 -0
- data/spec/integration/client_side_encryption/explicit_queryable_encryption_spec.rb +5 -5
- data/spec/integration/client_side_encryption/kms_tls_options_spec.rb +50 -8
- data/spec/integration/client_side_encryption/unique_index_on_key_alt_names_prose_spec.rb +85 -0
- data/spec/integration/ocsp_verifier_spec.rb +1 -1
- data/spec/integration/reconnect_spec.rb +2 -0
- data/spec/integration/sdam_events_spec.rb +40 -0
- data/spec/integration/srv_monitoring_spec.rb +1 -0
- data/spec/integration/srv_spec.rb +1 -0
- data/spec/lite_spec_helper.rb +5 -4
- data/spec/mongo/bulk_write_spec.rb +13 -0
- data/spec/mongo/client_construction_spec.rb +45 -2
- data/spec/mongo/client_encryption_spec.rb +0 -12
- data/spec/mongo/client_spec.rb +1 -1
- data/spec/mongo/collection/view/aggregation_spec.rb +119 -0
- data/spec/mongo/collection/view/readable_spec.rb +630 -5
- data/spec/mongo/collection_spec.rb +32 -0
- data/spec/mongo/crypt/auto_encrypter_spec.rb +110 -0
- data/spec/mongo/crypt/binding/context_spec.rb +3 -35
- data/spec/mongo/crypt/data_key_context_spec.rb +1 -1
- data/spec/mongo/crypt/explicit_encryption_context_spec.rb +8 -3
- data/spec/mongo/crypt/handle_spec.rb +39 -3
- data/spec/mongo/crypt/kms/credentials_spec.rb +0 -47
- data/spec/mongo/index/view_spec.rb +56 -0
- data/spec/mongo/operation/create/op_msg_spec.rb +0 -42
- data/spec/mongo/server/connection_pool_spec.rb +26 -4
- data/spec/mongo/socket/ssl_spec.rb +3 -3
- data/spec/runners/crud/requirement.rb +6 -1
- data/spec/runners/crud/test.rb +1 -1
- data/spec/runners/transactions/spec.rb +2 -2
- data/spec/runners/transactions/test.rb +4 -20
- data/spec/runners/transactions.rb +2 -2
- data/spec/runners/unified/assertions.rb +32 -2
- data/spec/runners/unified/change_stream_operations.rb +3 -0
- data/spec/runners/unified/client_side_encryption_operations.rb +83 -0
- data/spec/runners/unified/crud_operations.rb +17 -2
- data/spec/runners/unified/ddl_operations.rb +27 -2
- data/spec/runners/unified/grid_fs_operations.rb +21 -0
- data/spec/runners/unified/test.rb +59 -1
- data/spec/shared/lib/mrss/docker_runner.rb +2 -0
- data/spec/shared/lib/mrss/eg_config_utils.rb +51 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +10 -2
- data/spec/shared/shlib/set_env.sh +3 -0
- data/spec/solo/clean_exit_spec.rb +5 -0
- data/spec/spec_tests/client_side_encryption_spec.rb +1 -1
- data/spec/spec_tests/client_side_encryption_unified_spec.rb +16 -0
- data/spec/spec_tests/data/change_streams_unified/change-streams-showExpandedEvents.yml +298 -0
- data/spec/spec_tests/data/client_side_encryption/create-and-createIndexes.yml +58 -0
- data/spec/spec_tests/data/client_side_encryption/fle2-Delete.yml +1 -1
- data/spec/spec_tests/data/client_side_encryption/fle2-EncryptedFields-vs-jsonSchema.yml +1 -1
- data/spec/spec_tests/data/client_side_encryption/fle2-FindOneAndUpdate.yml +2 -2
- data/spec/spec_tests/data/client_side_encryption/fle2-InsertFind-Indexed.yml +1 -1
- data/spec/spec_tests/data/client_side_encryption/fle2-Update.yml +2 -2
- data/spec/spec_tests/data/client_side_encryption/unified/addKeyAltName.yml +194 -0
- data/spec/spec_tests/data/client_side_encryption/unified/createDataKey-kms_providers-invalid.yml +67 -0
- data/spec/spec_tests/data/client_side_encryption/unified/createDataKey.yml +309 -0
- data/spec/spec_tests/data/client_side_encryption/unified/deleteKey.yml +159 -0
- data/spec/spec_tests/data/client_side_encryption/unified/getKey.yml +105 -0
- data/spec/spec_tests/data/client_side_encryption/unified/getKeyByAltName.yml +104 -0
- data/spec/spec_tests/data/client_side_encryption/unified/getKeys.yml +122 -0
- data/spec/spec_tests/data/client_side_encryption/unified/removeKeyAltName.yml +157 -0
- data/spec/spec_tests/data/client_side_encryption/unified/rewrapManyDataKey-decrypt_failure.yml +69 -0
- data/spec/spec_tests/data/client_side_encryption/unified/rewrapManyDataKey-encrypt_failure.yml +122 -0
- data/spec/spec_tests/data/client_side_encryption/unified/rewrapManyDataKey.yml +432 -0
- data/spec/spec_tests/data/client_side_encryption/validatorAndPartialFieldExpression.yml +166 -0
- data/spec/spec_tests/data/command_monitoring_unified/bulkWrite.yml +68 -0
- data/spec/spec_tests/data/command_monitoring_unified/command.yml +50 -0
- data/spec/spec_tests/data/command_monitoring_unified/deleteMany.yml +79 -0
- data/spec/spec_tests/data/command_monitoring_unified/deleteOne.yml +79 -0
- data/spec/spec_tests/data/command_monitoring_unified/find.yml +254 -0
- data/spec/spec_tests/data/command_monitoring_unified/insertMany.yml +79 -0
- data/spec/spec_tests/data/command_monitoring_unified/insertOne.yml +77 -0
- data/spec/spec_tests/data/command_monitoring_unified/unacknowledgedBulkWrite.yml +55 -0
- data/spec/spec_tests/data/command_monitoring_unified/updateMany.yml +87 -0
- data/spec/spec_tests/data/command_monitoring_unified/updateOne.yml +118 -0
- data/spec/spec_tests/data/crud_unified/distinct-comment.yml +98 -0
- data/spec/spec_tests/data/gridfs_unified/delete.yml +198 -0
- data/spec/spec_tests/data/gridfs_unified/download.yml +241 -0
- data/spec/spec_tests/data/gridfs_unified/downloadByName.yml +159 -0
- data/spec/spec_tests/data/gridfs_unified/upload-disableMD5.yml +92 -0
- data/spec/spec_tests/data/gridfs_unified/upload.yml +288 -0
- data/spec/spec_tests/gridfs_unified_spec.rb +13 -0
- data/spec/stress/connection_pool_timing_spec.rb +2 -2
- data/spec/support/background_thread_registry.rb +3 -13
- data/spec/support/certificates/atlas-ocsp-ca.crt +40 -47
- data/spec/support/certificates/atlas-ocsp.crt +101 -106
- data/spec/support/crypt.rb +57 -13
- data/spec/support/macros.rb +10 -0
- data/spec/support/spec_config.rb +4 -0
- data.tar.gz.sig +0 -0
- metadata +1271 -1219
- metadata.gz.sig +0 -0
- data/spec/spec_tests/command_monitoring_spec.rb +0 -71
- data/spec/spec_tests/data/command_monitoring/bulkWrite.yml +0 -49
- data/spec/spec_tests/data/command_monitoring/command.yml +0 -61
- data/spec/spec_tests/data/command_monitoring/deleteMany.yml +0 -55
- data/spec/spec_tests/data/command_monitoring/deleteOne.yml +0 -55
- data/spec/spec_tests/data/command_monitoring/find.yml +0 -266
- data/spec/spec_tests/data/command_monitoring/insertMany.yml +0 -75
- data/spec/spec_tests/data/command_monitoring/insertOne.yml +0 -51
- data/spec/spec_tests/data/command_monitoring/unacknowledgedBulkWrite.yml +0 -34
- data/spec/spec_tests/data/command_monitoring/updateMany.yml +0 -65
- 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
|