Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
250192f
GODRIVER-3445 Remove tesdata from git and repo
prestonvasquez Mar 25, 2025
cba91b7
Replace testdata with submodules
prestonvasquez Mar 24, 2025
5ef2244
Cont. working on dep
prestonvasquez Mar 24, 2025
2ef1591
GODRIVER-3445 Resolve conflict in spectest
prestonvasquez Mar 25, 2025
6feb7ba
GODRIVER-3445 Continue updating
prestonvasquez Mar 25, 2025
3ecc73c
GODRIVER-3445 unified-test-format
prestonvasquez Mar 25, 2025
dd173ec
GODRIVER-3445 versioned-api
prestonvasquez Mar 25, 2025
6f54cb8
GODRIVER-3445 crud
prestonvasquez Mar 25, 2025
c8d684b
GODRIVER-3445 change-streams
prestonvasquez Mar 25, 2025
f6882ec
GODRIVER-3445 transactions
prestonvasquez Mar 26, 2025
00126a5
GODRIVER-3445 collection-management
prestonvasquez Mar 26, 2025
75d24c3
GODRIVER-3445 collection-management
prestonvasquez Mar 26, 2025
70670c4
GODRIVER-3445 command-monitoring
prestonvasquez Mar 26, 2025
2012ce3
GODRIVER-3445 command-logging-and-monitoring
prestonvasquez Mar 26, 2025
ca95b0c
GODRIVER-3445 connection-monitoring-and-pooling
prestonvasquez Mar 26, 2025
5dca3f7
GODRIVER-3445 sessions
prestonvasquez Mar 26, 2025
d103fea
GODRIVER-3445 retryable-reads
prestonvasquez Mar 26, 2025
b1d8f81
GODRIVER-3445 retryable-writes
prestonvasquez Mar 26, 2025
195f791
GODRIVER-3445 Cont. w/ CSFLE
prestonvasquez Mar 27, 2025
6a94619
GODRIVER-3445 Cont. working on submodule integration
prestonvasquez Mar 28, 2025
842ca1f
GODRIVER-3445 Resolve merge conflicts
prestonvasquez Mar 31, 2025
4e4337b
GODRIVER-3445 Update skip
prestonvasquez Mar 31, 2025
37f6419
GODRIVER-3445 Remote submodule init subprocess
prestonvasquez Mar 31, 2025
a841fab
GODRIVER-3445 Skip CS tests
prestonvasquez Apr 1, 2025
903b7db
GODRIVER-3445 Add testdata back
prestonvasquez Apr 2, 2025
4b283ae
GODRIVER-3445 Fix merge conflicts
prestonvasquez Apr 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 5 additions & 4 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ functions:
type: system
params:
directory: src/go.mongodb.org/mongo-driver
- command: shell.exec
params:
working_dir: "src/go.mongodb.org/mongo-driver"
script: |
git submodule update --init
# Make an env.sh and evergreen expansion file with dynamic values
- command: subprocess.exec
params:
Expand All @@ -44,10 +49,6 @@ functions:
# Define an alias for the task runner script.
TASK_RUNNER_ALIAS: &task-runner src/go.mongodb.org/mongo-driver/.evergreen/run-task.sh
args: [.evergreen/setup-system.sh]
- command: subprocess.exec
params:
binary: bash
args: [*task-runner, init-submodule]
- command: expansions.update
params:
file: src/go.mongodb.org/mongo-driver/expansion.yml
Expand Down
2 changes: 1 addition & 1 deletion bson/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var nestedInstance = nestedtest1{
},
}

const extendedBSONDir = "../testdata/extended_bson"
const extendedBSONDir = "../testdata/extended-bson"

var (
extJSONFiles map[string]map[string]interface{}
Expand Down
35 changes: 4 additions & 31 deletions bson/bson_binary_vector_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import (
"testing"

"go.mongodb.org/mongo-driver/v2/internal/require"
"go.mongodb.org/mongo-driver/v2/internal/spectest"
)

const bsonBinaryVectorDir = "../testdata/bson-binary-vector/"
var bsonBinaryVectorDir = spectest.Path("bson-binary-vector")

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

t.Run("Unmarshaling", func(t *testing.T) {
skipCases := map[string]string{
"Overflow Vector INT8": "compile-time restriction",
"Underflow Vector INT8": "compile-time restriction",
"INT8 with float inputs": "compile-time restriction",
"Overflow Vector PACKED_BIT": "compile-time restriction",
"Underflow Vector PACKED_BIT": "compile-time restriction",
"Vector with float values PACKED_BIT": "compile-time restriction",
"Negative padding PACKED_BIT": "compile-time restriction",
}
if reason, ok := skipCases[test.Description]; ok {
t.Skipf("skip test case %s: %s", test.Description, reason)
}
spectest.CheckSkip(t)

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

t.Run("Marshaling", func(t *testing.T) {
skipCases := map[string]string{
"FLOAT32 with padding": "private padding field",
"Insufficient vector data with 3 bytes FLOAT32": "invalid case",
"Insufficient vector data with 5 bytes FLOAT32": "invalid case",
"Overflow Vector INT8": "compile-time restriction",
"Underflow Vector INT8": "compile-time restriction",
"INT8 with padding": "private padding field",
"INT8 with float inputs": "compile-time restriction",
"Overflow Vector PACKED_BIT": "compile-time restriction",
"Underflow Vector PACKED_BIT": "compile-time restriction",
"Vector with float values PACKED_BIT": "compile-time restriction",
"Padding specified with no vector data PACKED_BIT": "run in alternative case",
"Exceeding maximum padding PACKED_BIT": "run in alternative case",
"Negative padding PACKED_BIT": "compile-time restriction",
}
if reason, ok := skipCases[test.Description]; ok {
t.Skipf("skip test case %s: %s", test.Description, reason)
}
spectest.CheckSkip(t)

t.Parallel()

Expand Down
3 changes: 2 additions & 1 deletion bson/bson_corpus_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/google/go-cmp/cmp"
"go.mongodb.org/mongo-driver/v2/internal/assert"
"go.mongodb.org/mongo-driver/v2/internal/require"
"go.mongodb.org/mongo-driver/v2/internal/spectest"
)

type testCase struct {
Expand Down Expand Up @@ -57,7 +58,7 @@ type parseErrorTestCase struct {
String string `json:"string"`
}

const dataDir = "../testdata/bson-corpus/"
var dataDir = spectest.Path("bson-corpus/tests")

func findJSONFilesInDir(dir string) ([]string, error) {
files := make([]string, 0)
Expand Down
12 changes: 6 additions & 6 deletions internal/integration/client_side_encryption_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ package integration

import (
"os"
"path"
"path/filepath"
"regexp"
"testing"
)

const (
encryptionSpecName = "client-side-encryption/legacy"
"go.mongodb.org/mongo-driver/v2/internal/spectest"
)

var encryptionSpecDir = spectest.Path("client-side-encryption/tests/legacy")

func verifyClientSideEncryptionVarsSet(t *testing.T) {
t.Helper()

Expand Down Expand Up @@ -53,7 +53,7 @@ func verifyClientSideEncryptionVarsSet(t *testing.T) {
func TestClientSideEncryptionSpec(t *testing.T) {
verifyClientSideEncryptionVarsSet(t)

for _, fileName := range jsonFilesInDir(t, path.Join(dataPath, encryptionSpecName)) {
for _, fileName := range jsonFilesInDir(t, encryptionSpecDir) {
t.Run(fileName, func(t *testing.T) {
re := regexp.MustCompile(`fle2\-Range\-.*\-Correctness`)
if re.Match([]byte(fileName)) {
Expand All @@ -62,7 +62,7 @@ func TestClientSideEncryptionSpec(t *testing.T) {
if fileName == "kmipKMS.json" && "" == os.Getenv("KMS_MOCK_SERVERS_RUNNING") {
t.Skipf("Skipping test as KMS_MOCK_SERVERS_RUNNING is not set")
}
runSpecTestFile(t, encryptionSpecName, fileName)
runSpecTestFile(t, filepath.Join(encryptionSpecDir, fileName))
})
}
}
25 changes: 24 additions & 1 deletion internal/integration/cmd_monitoring_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,30 @@ func compareValues(mt *mtest.T, key string, expected, actual bson.RawValue) erro
if typeVal, err := e.LookupErr("$$type"); err == nil {
// $$type represents a type assertion
// for example {field: {$$type: "binData"}} should assert that "field" is an element with a binary value
return checkValueType(mt, key, actual.Type, typeVal.StringValue())
types := []string{}
switch typeVal.Type {
case bson.TypeArray:
elems, err := typeVal.Array().Values()
if err != nil {
return fmt.Errorf("error getting expected types: %v", err)
}

for _, elem := range elems {
types = append(types, elem.StringValue())
}
case bson.TypeString:
types = append(types, typeVal.StringValue())
}

// If at least one of the types does not return an error, then the test
// has passed.
for _, t := range types {
if err := checkValueType(mt, key, actual.Type, t); err == nil {
return nil
}
}

return fmt.Errorf("BSON type mismatch for key %s; expected one of %v, got %s", key, types, actual.Type)
}

a := actual.Document()
Expand Down
5 changes: 2 additions & 3 deletions internal/integration/initial_dns_seedlist_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"go.mongodb.org/mongo-driver/v2/internal/assert"
"go.mongodb.org/mongo-driver/v2/internal/integration/mtest"
"go.mongodb.org/mongo-driver/v2/internal/serverselector"
"go.mongodb.org/mongo-driver/v2/internal/spectest"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
"go.mongodb.org/mongo-driver/v2/mongo/readpref"
Expand All @@ -29,9 +30,7 @@ import (
"go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology"
)

const (
seedlistDiscoveryTestsBaseDir = "../../testdata/initial-dns-seedlist-discovery"
)
var seedlistDiscoveryTestsBaseDir = spectest.Path("initial-dns-seedlist-discovery/tests")

type seedlistTest struct {
URI string `bson:"uri"`
Expand Down
1 change: 1 addition & 0 deletions internal/integration/unified/unified_spec_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func runTestDirectory(t *testing.T, directoryPath string, expectValidFail bool)

// runTestFile runs the tests in the given file, with expectValidFail determining whether the tests should expect to pass or fail
func runTestFile(t *testing.T, filepath string, expectValidFail bool, opts ...*Options) {
//spectest.CheckSkip(t)
content, err := ioutil.ReadFile(filepath)
assert.Nil(t, err, "ReadFile error for file %q: %v", filepath, err)

Expand Down
16 changes: 13 additions & 3 deletions internal/integration/unified/unified_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ package unified

import (
"context"
"path"
"testing"

"go.mongodb.org/mongo-driver/v2/internal/spectest"
)

var (
nonGitSubmodulePassDirectories = []string{
"unified-test-format/valid-pass",
}
passDirectories = []string{
"unified-test-format/tests/valid-pass",
"versioned-api/tests",
"crud/tests/unified",
"change-streams/tests/unified",
Expand All @@ -29,20 +32,21 @@ var (
"retryable-reads/tests/unified",
"retryable-writes/tests/unified",
"client-side-encryption/tests/unified",
"client-side-operations-timeout/tests",
//"client-side-operations-timeout/tests",
"gridfs/tests",
"server-selection/tests/logging",
"server-discovery-and-monitoring/tests/unified",
"run-command/tests/unified",
"index-management/tests",
"transactions-convenient-api/tests/unified",
"atlas-data-lake-testing/tests/unified",
}
failDirectories = []string{
"unified-test-format/tests/valid-fail",
}
)

const dataDirectory = "../../../testdata"

func TestUnifiedSpec(t *testing.T) {
// Ensure the cluster is in a clean state before test execution begins.
if err := terminateOpenSessions(context.Background()); err != nil {
Expand All @@ -55,6 +59,12 @@ func TestUnifiedSpec(t *testing.T) {
})
}

for _, testDir := range nonGitSubmodulePassDirectories {
t.Run(testDir, func(t *testing.T) {
runTestDirectory(t, path.Join(dataDirectory, testDir), false)
})
}

for _, testDir := range failDirectories {
t.Run(testDir, func(t *testing.T) {
runTestDirectory(t, spectest.Path(testDir), true)
Expand Down
21 changes: 21 additions & 0 deletions internal/integration/unified_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"reflect"
"sync"
Expand Down Expand Up @@ -161,6 +162,12 @@ var directories = []string{
"read-write-concern/tests/operation",
}

var nonGitSubmodulePassDirectories = []string{
"convenient-transactions",
}

const dataPath string = "../../testdata/"

var checkOutcomeOpts = options.Collection().SetReadPreference(readpref.Primary()).SetReadConcern(readconcern.Local())
var specTestRegistry = func() *bson.Registry {
reg := bson.NewRegistry()
Expand All @@ -179,11 +186,25 @@ func TestUnifiedSpecs(t *testing.T) {
}
})
}

for _, specDir := range nonGitSubmodulePassDirectories {
t.Run(specDir, func(t *testing.T) {
for _, fileName := range jsonFilesInDir(t, path.Join(dataPath, specDir)) {
fmt.Println(fileName)
t.Run(fileName, func(t *testing.T) {
runSpecTestFile(t, filepath.Join(dataPath, specDir, fileName))
})
}
})
}
}

// specDir: name of directory for a spec in the data/ folder
// fileName: name of test file in specDir
func runSpecTestFile(t *testing.T, filePath string) {
// It's possible that a JSON blob does not conform to our spec test format.
spectest.CheckSkip(t)

content, err := ioutil.ReadFile(filePath)
assert.Nil(t, err, "unable to read spec test file %v: %v", filePath, err)

Expand Down
Loading
Loading