Skip to content

Commit 195f791

Browse files
GODRIVER-3445 Cont. w/ CSFLE
1 parent b1d8f81 commit 195f791

File tree

12 files changed

+85
-56
lines changed

12 files changed

+85
-56
lines changed

.evergreen/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ functions:
3232
type: system
3333
params:
3434
directory: src/go.mongodb.org/mongo-driver
35+
- command: shell.exec
36+
params:
37+
working_dir: "src/go.mongodb.org/mongo-driver"
38+
script: |
39+
git submodule update --init
3540
# Make an env.sh and evergreen expansion file with dynamic values
3641
- command: subprocess.exec
3742
params:

bson/benchmark_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ var nestedInstance = nestedtest1{
130130
},
131131
}
132132

133-
const extendedBSONDir = "../testdata/extended_bson"
133+
const extendedBSONDir = "../testdata/extended-bson"
134134

135135
var (
136136
extJSONFiles map[string]map[string]interface{}

bson/bson_binary_vector_spec_test.go

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import (
1515
"testing"
1616

1717
"go.mongodb.org/mongo-driver/v2/internal/require"
18+
"go.mongodb.org/mongo-driver/v2/internal/spectest"
1819
)
1920

20-
const bsonBinaryVectorDir = "../testdata/bson-binary-vector/"
21+
var bsonBinaryVectorDir = spectest.TestPath(1, "bson-binary-vector")
2122

2223
type bsonBinaryVectorTests struct {
2324
Description string `json:"description"`
@@ -128,18 +129,7 @@ func runBsonBinaryVectorTest(t *testing.T, testKey string, test bsonBinaryVector
128129
require.NoError(t, err, "decoding canonical BSON")
129130

130131
t.Run("Unmarshaling", func(t *testing.T) {
131-
skipCases := map[string]string{
132-
"Overflow Vector INT8": "compile-time restriction",
133-
"Underflow Vector INT8": "compile-time restriction",
134-
"INT8 with float inputs": "compile-time restriction",
135-
"Overflow Vector PACKED_BIT": "compile-time restriction",
136-
"Underflow Vector PACKED_BIT": "compile-time restriction",
137-
"Vector with float values PACKED_BIT": "compile-time restriction",
138-
"Negative padding PACKED_BIT": "compile-time restriction",
139-
}
140-
if reason, ok := skipCases[test.Description]; ok {
141-
t.Skipf("skip test case %s: %s", test.Description, reason)
142-
}
132+
spectest.CheckSkip(t)
143133

144134
errMap := map[string]string{
145135
"FLOAT32 with padding": "padding must be 0",
@@ -163,24 +153,7 @@ func runBsonBinaryVectorTest(t *testing.T, testKey string, test bsonBinaryVector
163153
})
164154

165155
t.Run("Marshaling", func(t *testing.T) {
166-
skipCases := map[string]string{
167-
"FLOAT32 with padding": "private padding field",
168-
"Insufficient vector data with 3 bytes FLOAT32": "invalid case",
169-
"Insufficient vector data with 5 bytes FLOAT32": "invalid case",
170-
"Overflow Vector INT8": "compile-time restriction",
171-
"Underflow Vector INT8": "compile-time restriction",
172-
"INT8 with padding": "private padding field",
173-
"INT8 with float inputs": "compile-time restriction",
174-
"Overflow Vector PACKED_BIT": "compile-time restriction",
175-
"Underflow Vector PACKED_BIT": "compile-time restriction",
176-
"Vector with float values PACKED_BIT": "compile-time restriction",
177-
"Padding specified with no vector data PACKED_BIT": "run in alternative case",
178-
"Exceeding maximum padding PACKED_BIT": "run in alternative case",
179-
"Negative padding PACKED_BIT": "compile-time restriction",
180-
}
181-
if reason, ok := skipCases[test.Description]; ok {
182-
t.Skipf("skip test case %s: %s", test.Description, reason)
183-
}
156+
spectest.CheckSkip(t)
184157

185158
t.Parallel()
186159

bson/bson_corpus_spec_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/google/go-cmp/cmp"
2424
"go.mongodb.org/mongo-driver/v2/internal/assert"
2525
"go.mongodb.org/mongo-driver/v2/internal/require"
26+
"go.mongodb.org/mongo-driver/v2/internal/spectest"
2627
)
2728

2829
type testCase struct {
@@ -57,7 +58,7 @@ type parseErrorTestCase struct {
5758
String string `json:"string"`
5859
}
5960

60-
const dataDir = "../testdata/bson-corpus/"
61+
var dataDir = spectest.TestPath(1, "bson-corpus")
6162

6263
func findJSONFilesInDir(dir string) ([]string, error) {
6364
files := make([]string, 0)

internal/integration/client_side_encryption_spec_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ package integration
1111

1212
import (
1313
"os"
14-
"path"
1514
"regexp"
1615
"testing"
17-
)
1816

19-
const (
20-
encryptionSpecName = "client-side-encryption/legacy"
17+
"go.mongodb.org/mongo-driver/v2/internal/spectest"
2118
)
2219

20+
var encryptionSpecDir = spectest.TestPath(2, "client-side-encryption", "legacy")
21+
2322
func verifyClientSideEncryptionVarsSet(t *testing.T) {
2423
t.Helper()
2524

@@ -53,7 +52,7 @@ func verifyClientSideEncryptionVarsSet(t *testing.T) {
5352
func TestClientSideEncryptionSpec(t *testing.T) {
5453
verifyClientSideEncryptionVarsSet(t)
5554

56-
for _, fileName := range jsonFilesInDir(t, path.Join(dataPath, encryptionSpecName)) {
55+
for _, fileName := range jsonFilesInDir(t, encryptionSpecDir) {
5756
t.Run(fileName, func(t *testing.T) {
5857
re := regexp.MustCompile(`fle2\-Range\-.*\-Correctness`)
5958
if re.Match([]byte(fileName)) {
@@ -62,7 +61,7 @@ func TestClientSideEncryptionSpec(t *testing.T) {
6261
if fileName == "kmipKMS.json" && "" == os.Getenv("KMS_MOCK_SERVERS_RUNNING") {
6362
t.Skipf("Skipping test as KMS_MOCK_SERVERS_RUNNING is not set")
6463
}
65-
runSpecTestFile(t, encryptionSpecName, fileName)
64+
runSpecTestFile(t, encryptionSpecDir, fileName)
6665
})
6766
}
6867
}

internal/integration/cmd_monitoring_helpers_test.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,30 @@ func compareValues(mt *mtest.T, key string, expected, actual bson.RawValue) erro
8383
if typeVal, err := e.LookupErr("$$type"); err == nil {
8484
// $$type represents a type assertion
8585
// for example {field: {$$type: "binData"}} should assert that "field" is an element with a binary value
86-
return checkValueType(mt, key, actual.Type, typeVal.StringValue())
86+
types := []string{}
87+
switch typeVal.Type {
88+
case bson.TypeArray:
89+
elems, err := typeVal.Array().Values()
90+
if err != nil {
91+
return fmt.Errorf("error getting expected types: %v", err)
92+
}
93+
94+
for _, elem := range elems {
95+
types = append(types, elem.StringValue())
96+
}
97+
case bson.TypeString:
98+
types = append(types, typeVal.StringValue())
99+
}
100+
101+
// If at least one of the types does not return an error, then the test
102+
// has passed.
103+
for _, t := range types {
104+
if err := checkValueType(mt, key, actual.Type, t); err == nil {
105+
return nil
106+
}
107+
}
108+
109+
return fmt.Errorf("BSON type mismatch for key %s; expected one of %v, got %s", key, types, actual.Type)
87110
}
88111

89112
a := actual.Document()

internal/integration/unified/unified_spec_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ var (
1919
//
2020
//"load-balancers",
2121
//
22-
//spectest.TestPath(3, "unified-test-format", "valid-pass"),
23-
//spectest.TestPath(3, "versioned-api"),
22+
spectest.TestPath(3, "unified-test-format", "valid-pass"),
23+
spectest.TestPath(3, "versioned-api"),
2424
//spectest.TestPath(3, "crud", "unified"),
2525
//spectest.TestPath(3, "change-streams", "unified"),
2626
//spectest.TestPath(3, "transactions", "unified"),
@@ -31,8 +31,7 @@ var (
3131
//spectest.TestPath(3, "connection-monitoring-and-pooling", "logging"),
3232
//spectest.TestPath(3, "sessions"),
3333
//spectest.TestPath(3, "retryable-reads", "unified"),
34-
spectest.TestPath(3, "retryable-writes", "unified"),
35-
//"retryable-writes/unified",
34+
//spectest.TestPath(3, "retryable-writes", "unified"),
3635
//"client-side-encryption/unified",
3736
//"client-side-operations-timeout",
3837
//"gridfs",

internal/integration/unified_spec_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"os"
1616
"path"
1717
"reflect"
18+
"strings"
1819
"sync"
1920
"testing"
2021
"time"
@@ -157,14 +158,12 @@ type operationError struct {
157158
ErrorLabelsOmit []string `bson:"errorLabelsOmit"`
158159
}
159160

160-
const dataPath string = "../../testdata/"
161-
162161
var directories = []string{
163-
"transactions/legacy",
164-
"convenient-transactions",
165-
"retryable-reads/legacy",
166-
"read-write-concern/operation",
167-
"atlas-data-lake-testing",
162+
"../../testdata/transactions/legacy",
163+
"../../testdata/convenient-transactions",
164+
"../../testdata/retryable-reads/legacy",
165+
"../../testdata/read-write-concern/operation",
166+
"../../testdata/atlas-data-lake-testing",
168167
}
169168

170169
var checkOutcomeOpts = options.Collection().SetReadPreference(readpref.Primary()).SetReadConcern(readconcern.Local())
@@ -177,8 +176,10 @@ var specTestRegistry = func() *bson.Registry {
177176

178177
func TestUnifiedSpecs(t *testing.T) {
179178
for _, specDir := range directories {
180-
t.Run(specDir, func(t *testing.T) {
181-
for _, fileName := range jsonFilesInDir(t, path.Join(dataPath, specDir)) {
179+
index := strings.Index(specDir, "testdata/")
180+
dirTestName := specDir[index+len("testdata/"):]
181+
t.Run(dirTestName, func(t *testing.T) {
182+
for _, fileName := range jsonFilesInDir(t, specDir) {
182183
t.Run(fileName, func(t *testing.T) {
183184
runSpecTestFile(t, specDir, fileName)
184185
})
@@ -190,7 +191,8 @@ func TestUnifiedSpecs(t *testing.T) {
190191
// specDir: name of directory for a spec in the data/ folder
191192
// fileName: name of test file in specDir
192193
func runSpecTestFile(t *testing.T, specDir, fileName string) {
193-
filePath := path.Join(dataPath, specDir, fileName)
194+
filePath := path.Join(specDir, fileName)
195+
194196
content, err := ioutil.ReadFile(filePath)
195197
assert.Nil(t, err, "unable to read spec test file %v: %v", filePath, err)
196198

@@ -206,7 +208,7 @@ func runSpecTestFile(t *testing.T, specDir, fileName string) {
206208
mtOpts := mtest.NewOptions().
207209
RunOn(testFile.RunOn...).
208210
CreateClient(false)
209-
if specDir == "atlas-data-lake-testing" {
211+
if strings.Contains(specDir, "atlas-data-lake-testing") {
210212
mtOpts.AtlasDataLake(true)
211213
}
212214
mt := mtest.New(t, mtOpts)

internal/spectest/skip.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
package spectest
88

9-
import "testing"
9+
import (
10+
"testing"
11+
)
1012

1113
// skipTests is a map of "fully-qualified test name" to "the reason for skipping
1214
// the test".
@@ -343,6 +345,31 @@ var skipTests = map[string]string{
343345
"TestUnifiedSpec/server-discovery-and-monitoring/unified/sharded-emit-topology-changed-before-close.json/Topology_lifecycle": "Implement GODRIVER-2967",
344346
"TestUnifiedSpec/server-discovery-and-monitoring/unified/replicaset-emit-topology-changed-before-close.json/Topology_lifecycle": "Implement GODRIVER-2967",
345347
"TestUnifiedSpec/server-discovery-and-monitoring/unified/standalone-emit-topology-changed-before-close.json/Topology_lifecycle": "Implement GODRIVER-2967",
348+
349+
// Unknown BSON
350+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_FLOAT32/Infinity_Vector_FLOAT32/Marshaling": "Unsupported format",
351+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_FLOAT32/Infinity_Vector_FLOAT32/Unmarshaling": "Unsupported format",
352+
353+
// Unsuported BSON binary vector tests.
354+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_PACKED_BIT/Overflow_Vector_PACKED_BIT/Marshaling": "compile-time restriction",
355+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_INT8/Underflow_Vector_INT8/Marshaling": "compile-time restriction",
356+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_INT8/Overflow_Vector_INT8/Marshaling": "compile-time restriction",
357+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_PACKED_BIT/Negative_padding_PACKED_BIT/Marshaling": "compile-time restriction",
358+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_INT8/INT8_with_padding/Marshaling": "private padding field",
359+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_FLOAT32/Insufficient_vector_data_with_3_bytes_FLOAT32/Marshaling": "invalid case",
360+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_FLOAT32/FLOAT32_with_padding/Marshaling": "private padding field",
361+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_FLOAT32/Insufficient_vector_data_with_5_bytes_FLOAT32/Marshaling": "invalid case",
362+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_PACKED_BIT/Vector_with_float_values_PACKED_BIT/Marshaling": "compile-time restriction",
363+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_PACKED_BIT/Underflow_Vector_PACKED_BIT/Marshaling": "compile-time restriction",
364+
"TestBsonBinaryVectorSpec/Tests_of_Binary_subtype_9,_Vectors,_with_dtype_INT8/INT8_with_float_inputs/Marshaling": "compile-time restriction",
365+
366+
// TODO(GODRIVER-3521): Extend Legacy Unified Spec Runner to include
367+
// client-side-encryption timeoutMS
368+
"TestClientSideEncryptionSpec/timeoutMS.json/remaining_timeoutMS_applied_to_find_to_get_keyvault_data": "Implement GODRIVER-3521",
369+
"TestClientSideEncryptionSpec/timeoutMS.json/timeoutMS_applied_to_listCollections_to_get_collection_schema": "Implement GODRIVER-3521",
370+
371+
// TODO(GODRIVER-3076): CSFLE/QE Support for more than 1 KMS provider per type
372+
"TestClientSideEncryptionSpec/namedKMS.json/Automatically_encrypt_and_decrypt_with_a_named_KMS_provider": "Implement GODRIVER-3076",
346373
}
347374

348375
// CheckSkip checks if the fully-qualified test name matches a skipped test
616 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)