Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "specifications"]
path = specifications
url = git@github.com:mongodb/specifications.git
path = testdata/specifications
url = https://github.com/mongodb/specifications
6 changes: 3 additions & 3 deletions internal/serverselector/server_selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func compareServers(t *testing.T, expected []*serverDesc, actual []description.S
}
}

const maxStalenessTestsDir = "../../testdata/max-staleness"
var maxStalenessTestsDir = spectest.TestPath(2, "max-staleness")

// Test case for all max staleness spec tests.
func TestMaxStalenessSpec(t *testing.T) {
Expand All @@ -176,7 +176,7 @@ func TestMaxStalenessSpec(t *testing.T) {
}
}

const selectorTestsDir = "../../testdata/server-selection/server_selection"
var selectorTestsDir = spectest.TestPath(2, "server-selection")

func selectServers(t *testing.T, test *testCase) error {
servers := make([]description.Server, 0, len(test.TopologyDescription.Servers))
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestServerSelectionSpec(t *testing.T) {
"LoadBalanced",
} {
for _, subdir := range [...]string{"read", "write"} {
subdirPath := path.Join(topology, subdir)
subdirPath := path.Join("server_selection", topology, subdir)

for _, file := range spectest.FindJSONFilesInDir(t,
path.Join(selectorTestsDir, subdirPath)) {
Expand Down
77 changes: 75 additions & 2 deletions internal/spectest/skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import "testing"
// the test".
var skipTests = map[string]string{
"TestURIOptionsSpec/single-threaded-options.json/Valid_options_specific_to_single-threaded_drivers_are_parsed_correctly": "The Go Driver is not single-threaded.",
// GODRIVER-2348: The wtimeoutMS write concern option is not supported.
"TestURIOptionsSpec/concern-options.json/Valid_read_and_write_concern_are_parsed_correctly": "The wtimeoutMS write concern option is not supported",

// SPEC-1403: This test checks to see if the correct error is thrown when
// auto encrypting with a server < 4.2. Currently, the test will fail
Expand Down Expand Up @@ -152,6 +150,81 @@ var skipTests = map[string]string{
"TestUnifiedSpec/server-discovery-and-monitoring/unified/sharded-emit-topology-changed-before-close.json/Topology_lifecycle": "Implement GODRIVER-2967",
"TestUnifiedSpec/server-discovery-and-monitoring/unified/replicaset-emit-topology-changed-before-close.json/Topology_lifecycle": "Implement GODRIVER-2967",
"TestUnifiedSpec/server-discovery-and-monitoring/unified/standalone-emit-topology-changed-before-close.json/Topology_lifecycle": "Implement GODRIVER-2967",

// TODO(GODRIVER-2183): Socks5 Proxy Support.
"TestURIOptionsSpec/proxy-options.json/proxyPort_without_proxyHost": "Implement GODRIVER-2183 for Socks5 Proxy Support",
"TestURIOptionsSpec/proxy-options.json/proxyUsername_without_proxyHost": "Implement GODRIVER-2183 for Socks5 Proxy Support",
"TestURIOptionsSpec/proxy-options.json/proxyPassword_without_proxyHost": "Implement GODRIVER-2183 for Socks5 Proxy Support",
"TestURIOptionsSpec/proxy-options.json/all_other_proxy_options_without_proxyHost": "Implement GODRIVER-2183 for Socks5 Proxy Support",
"TestURIOptionsSpec/proxy-options.json/proxyUsername_without_proxyPassword": "Implement GODRIVER-2183 for Socks5 Proxy Support",
"TestURIOptionsSpec/proxy-options.json/proxyPassword_without_proxyUsername": "Implement GODRIVER-2183 for Socks5 Proxy Support",
"TestURIOptionsSpec/proxy-options.json/multiple_proxyHost_parameters": "Implement GODRIVER-2183 for Socks5 Proxy Support",
"TestURIOptionsSpec/proxy-options.json/multiple_proxyPort_parameters": "Implement GODRIVER-2183 for Socks5 Proxy Support",
"TestURIOptionsSpec/proxy-options.json/multiple_proxyUsername_parameters": "Implement GODRIVER-2183 for Socks5 Proxy Support",
"TestURIOptionsSpec/proxy-options.json/multiple_proxyPassword_parameters": "Implement GODRIVER-2183 for Socks5 Proxy Support",

// wtimeoutMS write concern option is not supported.
"TestURIOptionsSpec/concern-options.json/Valid_read_and_write_concern_are_parsed_correctly": "wtimeoutMS is deprecated",
"TestURIOptionsSpec/concern-options.json/Non-numeric_wTimeoutMS_causes_a_warning": "wtimeoutMS is deprecated",
"TestURIOptionsSpec/concern-options.json/Too_low_wTimeoutMS_causes_a_warning": "wtimeoutMS is deprecated",
"TestReadWriteConcernSpec/connstring/write-concern.json/wtimeoutMS_as_an_invalid_number": "wtimeoutMS is deprecated",

// Unsupported TLS behavior in connection strings.
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidCertificates_and_tlsDisableCertificateRevocationCheck_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidCertificates=true_and_tlsDisableCertificateRevocationCheck=false_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidCertificates=false_and_tlsDisableCertificateRevocationCheck=true_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidCertificates_and_tlsDisableCertificateRevocationCheck_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck_and_tlsAllowInvalidCertificates_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck=true_and_tlsAllowInvalidCertificates=false_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck=false_and_tlsAllowInvalidCertificates=true_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck_and_tlsAllowInvalidCertificates_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsInsecure_and_tlsDisableCertificateRevocationCheck_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsInsecure=true_and_tlsDisableCertificateRevocationCheck=false_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsInsecure=false_and_tlsDisableCertificateRevocationCheck=true_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsInsecure_and_tlsDisableCertificateRevocationCheck_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck_and_tlsInsecure_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck=true_and_tlsInsecure=false_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck=false_and_tlsInsecure=true_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck_and_tlsInsecure_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck_and_tlsDisableOCSPEndpointCheck_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck=true_and_tlsDisableOCSPEndpointCheck=false_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck=false_and_tlsDisableOCSPEndpointCheck=true_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableCertificateRevocationCheck_and_tlsDisableOCSPEndpointCheck_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableOCSPEndpointCheck_and_tlsDisableCertificateRevocationCheck_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableOCSPEndpointCheck=true_and_tlsDisableCertificateRevocationCheck=false_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableOCSPEndpointCheck=false_and_tlsDisableCertificateRevocationCheck=true_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableOCSPEndpointCheck_and_tlsDisableCertificateRevocationCheck_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidCertificates_and_tlsDisableOCSPEndpointCheck_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidCertificates=true_and_tlsDisableOCSPEndpointCheck=false_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidCertificates=false_and_tlsDisableOCSPEndpointCheck=true_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidCertificates_and_tlsDisableOCSPEndpointCheck_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableOCSPEndpointCheck_and_tlsAllowInvalidCertificates_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableOCSPEndpointCheck=true_and_tlsAllowInvalidCertificates=false_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableOCSPEndpointCheck=false_and_tlsAllowInvalidCertificates=true_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsDisableOCSPEndpointCheck_and_tlsAllowInvalidCertificates_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/Invalid_tlsAllowInvalidCertificates_causes_a_warning": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidCertificates_is_parsed_correctly": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidHostnames_is_parsed_correctly": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/Invalid_tlsAllowInvalidHostnames_causes_a_warning": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsInsecure_and_tlsAllowInvalidCertificates_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsInsecure_and_tlsAllowInvalidCertificates_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidCertificates_and_tlsInsecure_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidCertificates_and_tlsInsecure_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsInsecure_and_tlsAllowInvalidHostnames_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsInsecure_and_tlsAllowInvalidHostnames_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidHostnames_and_tlsInsecure_both_present_(and_true)_raises_an_error": "unsupported connstring behavior",
"TestURIOptionsSpec/tls-options.json/tlsAllowInvalidHostnames_and_tlsInsecure_both_present_(and_false)_raises_an_error": "unsupported connstring behavior",

// TODO(GODRIVER-2991): make delimiting slash between hosts and options
// optional.
"TestConnStringSpec/valid-options.json/Missing_delimiting_slash_between_hosts_and_options": "Implement GODRIVER-2991 making delimiting slash between hosts and options optional",

// Connstring tests violate current Go Driver behavior
"TestURIOptionsSpec/connection-pool-options.json/maxConnecting=0_causes_a_warning": "unsupported behavior",
"TestURIOptionsSpec/single-threaded-options.json/Invalid_serverSelectionTryOnce_causes_a_warning": "unsupported behavior",
"TestConnStringSpec/valid-warnings.json/Empty_integer_option_values_are_ignored": "SPEC-1545: unsupported behavior",
"TestConnStringSpec/valid-warnings.json/Empty_boolean_option_value_are_ignored": "SPEC-1545: unsupported behavior",
"TestConnStringSpec/valid-warnings.json/Comma_in_a_key_value_pair_causes_a_warning": "DRIVERS-2915: unsupported behavior",
}

// CheckSkip checks if the fully-qualified test name matches a skipped test
Expand Down
20 changes: 18 additions & 2 deletions internal/spectest/spectest.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
package spectest

import (
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"testing"

"go.mongodb.org/mongo-driver/v2/internal/require"
Expand All @@ -20,7 +22,7 @@ func FindJSONFilesInDir(t *testing.T, dir string) []string {

files := make([]string, 0)

entries, err := ioutil.ReadDir(dir)
entries, err := os.ReadDir(dir)
require.NoError(t, err)

for _, entry := range entries {
Expand All @@ -33,3 +35,17 @@ func FindJSONFilesInDir(t *testing.T, dir string) []string {

return files
}

// TestPath will construct a path to a test file in the specifications git
// submodule. The path will be relative to the current package so a depth should
// be provided to indicate how many directories to go up.
func TestPath(depth int, testDir string, subDirs ...string) string {
const basePath = "testdata/specifications/source/"

// Create a string of "../" repeated 'depth' times
relativePath := strings.Repeat("../", depth)
// Construct the full path
fullPath := relativePath + basePath + testDir + "/tests/" + filepath.Join(subDirs...)

return fullPath
}
11 changes: 5 additions & 6 deletions mongo/read_write_concern_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/internal/assert"
"go.mongodb.org/mongo-driver/v2/internal/spectest"
"go.mongodb.org/mongo-driver/v2/mongo/readconcern"
"go.mongodb.org/mongo-driver/v2/mongo/writeconcern"
"go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore"
Expand All @@ -24,9 +25,8 @@ import (
)

const (
readWriteConcernTestsDir = "../testdata/read-write-concern"
connstringTestsDir = "connection-string"
documentTestsDir = "document"
connstringTestsDir = "connection-string"
documentTestsDir = "document"
)

var (
Expand All @@ -36,6 +36,7 @@ var (
reg.RegisterTypeMapEntry(bson.TypeEmbeddedDocument, reflect.TypeOf(bson.Raw{}))
return reg
}()
readWriteConcernTestsDir = spectest.TestPath(1, "read-write-concern")
)

type connectionStringTestFile struct {
Expand Down Expand Up @@ -103,9 +104,7 @@ func runConnectionStringTestFile(t *testing.T, filePath string) {
}

func runConnectionStringTest(t *testing.T, test connectionStringTest) {
if test.SkipReason != "" {
t.Skip(test.SkipReason)
}
spectest.CheckSkip(t)

cs, err := connstring.ParseAndValidate(test.URI)
if !test.Valid {
Expand Down
53 changes: 0 additions & 53 deletions testdata/atlas-data-lake-testing/aggregate.json

This file was deleted.

23 changes: 0 additions & 23 deletions testdata/atlas-data-lake-testing/aggregate.yml

This file was deleted.

27 changes: 0 additions & 27 deletions testdata/atlas-data-lake-testing/estimatedDocumentCount.json

This file was deleted.

18 changes: 0 additions & 18 deletions testdata/atlas-data-lake-testing/estimatedDocumentCount.yml

This file was deleted.

65 changes: 0 additions & 65 deletions testdata/atlas-data-lake-testing/find.json

This file was deleted.

Loading
Loading