Skip to content

GODRIVER-3445 Use Git submodules for spec tests (#1996) #2006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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: 4 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ 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
6 changes: 5 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: "weekly"
interval: "weekly"
- package-ecosystem: "gitsubmodule"
directory: "/"
schedule:
interval: "weekly"
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
11 changes: 5 additions & 6 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ tasks:

check-license: bash etc/check_license.sh

init-submodule: git submodule update --init

build:
deps: [install-libmongocrypt]
cmds:
Expand Down Expand Up @@ -149,9 +151,9 @@ tasks:
evg-test-load-balancers:
# Load balancer should be tested with all unified tests as well as tests in the following
# components: retryable reads, retryable writes, change streams, initial DNS seedlist discovery.
- go test ${BUILD_TAGS} ./internal/integration -run TestUnifiedSpecs/retryable-reads -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestRetryableWritesSpec -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestChangeStreamSpec -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration/unified -run TestUnifiedSpec/retryable-reads -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration/unified -run TestUnifiedSpec/retryable-writes -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration/unified -run TestUnifiedSpec/change-streams -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestInitialDNSSeedlistDiscoverySpec/load_balanced -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestLoadBalancerSupport -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestLoadBalancedConnectionHandshake -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
Expand All @@ -174,13 +176,10 @@ tasks:
- go test ${BUILD_TAGS} ./internal/integration -run TestWriteConcernError -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestErrorsCodeNamePropagated -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestLoadBalancerSupport -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestUnifiedSpecs/retryable-reads -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestRetryableReadsProse -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestRetryableWritesSpec -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestRetryableWritesProse -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestUnifiedSpecs/sessions -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestSessionsProse -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestUnifiedSpecs/transactions/legacy -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestConvenientTransactions -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration -run TestCursor -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
- go test ${BUILD_TAGS} ./internal/integration/unified -run TestUnifiedSpec -v -timeout {{.TEST_TIMEOUT}}s >> test.suite
Expand Down
86 changes: 0 additions & 86 deletions internal/integration/retryable_writes_spec_test.go

This file was deleted.

3 changes: 3 additions & 0 deletions internal/integration/unified/unified_spec_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func runTestFile(t *testing.T, filepath string, expectValidFail bool, opts ...*O
mtOpts := mtest.NewOptions().
RunOn(fileReqs...).
CreateClient(false)
if strings.Contains(filepath, "atlas-data-lake-testing") {
mtOpts.AtlasDataLake(true)
}
mt := mtest.New(t, mtOpts)

for _, testCase := range testCases {
Expand Down
55 changes: 27 additions & 28 deletions internal/integration/unified/unified_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,41 @@ package unified

import (
"context"
"path"
"testing"

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

var (
passDirectories = []string{
"unified-test-format/valid-pass",
"versioned-api",
"crud/unified",
"change-streams",
"transactions/unified",
"load-balancers",
"collection-management",
"command-monitoring",
"command-monitoring/logging",
"connection-monitoring-and-pooling/logging",
"sessions",
"retryable-reads/unified",
"retryable-writes/unified",
"client-side-encryption/unified",
"client-side-operations-timeout",
"gridfs",
"server-selection/logging",
"server-discovery-and-monitoring/unified",
"run-command",
"index-management",
"unified-test-format/tests/valid-pass",
"versioned-api/tests",
"crud/tests/unified",
"change-streams/tests/unified",
"transactions/tests/unified",
"load-balancers/tests",
"collection-management/tests",
"command-logging-and-monitoring/tests/monitoring",
"command-logging-and-monitoring/tests/logging",
"connection-monitoring-and-pooling/tests/logging",
"sessions/tests",
"retryable-reads/tests/unified",
"retryable-writes/tests/unified",
"client-side-encryption/tests/unified",
"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/valid-fail",
"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 @@ -52,13 +51,13 @@ func TestUnifiedSpec(t *testing.T) {

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

for _, testDir := range failDirectories {
t.Run(testDir, func(t *testing.T) {
runTestDirectory(t, path.Join(dataDirectory, testDir), true)
runTestDirectory(t, spectest.Path(testDir), true)
})
}
}
20 changes: 5 additions & 15 deletions internal/integration/unified_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"reflect"
"sync"
"testing"
Expand Down Expand Up @@ -157,14 +157,8 @@ type operationError struct {
ErrorLabelsOmit []string `bson:"errorLabelsOmit"`
}

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

var directories = []string{
"transactions/legacy",
"convenient-transactions",
"retryable-reads/legacy",
"read-write-concern/operation",
"atlas-data-lake-testing",
"read-write-concern/tests/operation",
}

var checkOutcomeOpts = options.Collection().SetReadPreference(readpref.Primary()).SetReadConcern(readconcern.Local())
Expand All @@ -178,9 +172,9 @@ var specTestRegistry = func() *bson.Registry {
func TestUnifiedSpecs(t *testing.T) {
for _, specDir := range directories {
t.Run(specDir, func(t *testing.T) {
for _, fileName := range jsonFilesInDir(t, path.Join(dataPath, specDir)) {
for _, fileName := range jsonFilesInDir(t, spectest.Path(specDir)) {
t.Run(fileName, func(t *testing.T) {
runSpecTestFile(t, specDir, fileName)
runSpecTestFile(t, filepath.Join(specDir, fileName))
})
}
})
Expand All @@ -189,8 +183,7 @@ func TestUnifiedSpecs(t *testing.T) {

// specDir: name of directory for a spec in the data/ folder
// fileName: name of test file in specDir
func runSpecTestFile(t *testing.T, specDir, fileName string) {
filePath := path.Join(dataPath, specDir, fileName)
func runSpecTestFile(t *testing.T, filePath string) {
content, err := ioutil.ReadFile(filePath)
assert.Nil(t, err, "unable to read spec test file %v: %v", filePath, err)

Expand All @@ -206,9 +199,6 @@ func runSpecTestFile(t *testing.T, specDir, fileName string) {
mtOpts := mtest.NewOptions().
RunOn(testFile.RunOn...).
CreateClient(false)
if specDir == "atlas-data-lake-testing" {
mtOpts.AtlasDataLake(true)
}
mt := mtest.New(t, mtOpts)

for _, test := range testFile.Tests {
Expand Down
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.Path("max-staleness/tests")

// 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.Path("server-selection/tests")

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
Loading
Loading