Skip to content

Commit 06bceb0

Browse files
authored
DRIVERS-2776 test compact with "range" (#1605)
* expect `ok: 1` in result To ensure the test runner asserts no error. * note bug in test * add test for compact with range * regenerate spec tests
1 parent 89edd81 commit 06bceb0

File tree

6 files changed

+484
-2
lines changed

6 files changed

+484
-2
lines changed

source/client-side-encryption/etc/test-templates/fle2v2-Compact.yml.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Requires libmongocrypt 1.8.0.
1+
# Requires libmongocrypt 1.8.0. libmongocrypt 1.10.0 has a bug (MONGOCRYPT-699) that may cause this test to fail on server version 7.
22
runOn:
33
- minServerVersion: "7.0.0"
44
# Skip QEv2 (also referred to as FLE2v2) tests on Serverless. Unskip once Serverless enables the QEv2 protocol.
@@ -22,6 +22,8 @@ tests:
2222
arguments:
2323
command:
2424
compactStructuredEncryptionData: *collection_name
25+
result:
26+
ok: 1
2527
expectations:
2628
- command_started_event:
2729
command:
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Requires libmongocrypt 1.10.1.
2+
runOn:
3+
- minServerVersion: "8.0.0" # Require range v2 support on server.
4+
# FLE 2 Encrypted collections are not supported on standalone.
5+
topology: [ "replicaset", "sharded", "load-balanced" ]
6+
database_name: "default"
7+
collection_name: &collection_name "default"
8+
data: []
9+
encrypted_fields: &encrypted_fields {{ yamlfile("range-encryptedFields-Int.json") }}
10+
key_vault_data: [ {{ yamlfile("keys/key1-document.json") }} ]
11+
tests:
12+
- description: "Compact works with 'range' fields"
13+
clientOptions:
14+
autoEncryptOpts:
15+
kmsProviders:
16+
local: {{ local_provider() }}
17+
operations:
18+
# Insert before running compact to ensure the server errors if `encryptionInformation` is incorrectly omitted.
19+
- name: insertOne
20+
arguments:
21+
document: { _id: 0, encryptedInt: { $numberInt: "0" } }
22+
- name: runCommand
23+
object: database
24+
command_name: compactStructuredEncryptionData
25+
arguments:
26+
command:
27+
compactStructuredEncryptionData: *collection_name
28+
result:
29+
ok: 1
30+
expectations:
31+
- command_started_event:
32+
command:
33+
listCollections: 1
34+
filter:
35+
name: *collection_name
36+
command_name: listCollections
37+
- command_started_event:
38+
command:
39+
find: datakeys
40+
filter: {
41+
"$or": [
42+
{
43+
"_id": {
44+
"$in": [
45+
{{ yamlfile("keys/key1-id.json") }}
46+
]
47+
}
48+
},
49+
{
50+
"keyAltNames": {
51+
"$in": []
52+
}
53+
}
54+
]
55+
}
56+
$db: keyvault
57+
readConcern: { level: "majority" }
58+
command_name: find
59+
- command_started_event:
60+
command:
61+
insert: *collection_name
62+
documents:
63+
- { "_id": 0, "encryptedInt": { $$type: "binData" } }
64+
ordered: true
65+
encryptionInformation: &encryptionInformation
66+
type: 1
67+
schema:
68+
default.default:
69+
# libmongocrypt applies escCollection and ecocCollection to outgoing command.
70+
escCollection: "enxcol_.default.esc"
71+
ecocCollection: "enxcol_.default.ecoc"
72+
<<: *encrypted_fields
73+
command_name: insert
74+
- command_started_event:
75+
command:
76+
compactStructuredEncryptionData: *collection_name
77+
compactionTokens:
78+
"encryptedInt": {
79+
"ecoc": {
80+
"$binary": {
81+
"base64": "noN+05JsuO1oDg59yypIGj45i+eFH6HOTXOPpeZ//Mk=",
82+
"subType": "00"
83+
}
84+
},
85+
"anchorPaddingToken": {
86+
"$binary": {
87+
"base64": "QxKJD2If48p0l8NAXf2Kr0aleMd/dATSjBK6hTpNMyc=",
88+
"subType": "00"
89+
}
90+
}
91+
}
92+
encryptionInformation: *encryptionInformation
93+
command_name: compactStructuredEncryptionData

source/client-side-encryption/tests/legacy/fle2v2-Compact.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/client-side-encryption/tests/legacy/fle2v2-Compact.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Requires libmongocrypt 1.8.0.
1+
# Requires libmongocrypt 1.8.0. libmongocrypt 1.10.0 has a bug (MONGOCRYPT-699) that may cause this test to fail on server version 7.
22
runOn:
33
- minServerVersion: "7.0.0"
44
# Skip QEv2 (also referred to as FLE2v2) tests on Serverless. Unskip once Serverless enables the QEv2 protocol.
@@ -22,6 +22,8 @@ tests:
2222
arguments:
2323
command:
2424
compactStructuredEncryptionData: *collection_name
25+
result:
26+
ok: 1
2527
expectations:
2628
- command_started_event:
2729
command:

0 commit comments

Comments
 (0)