Skip to content

Commit

Permalink
Merge branch 'master' into godriver2617
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu authored Sep 26, 2023
2 parents cfd0ffc + 3e34fa3 commit a6d3aca
Show file tree
Hide file tree
Showing 280 changed files with 2,693 additions and 80,387 deletions.
81 changes: 69 additions & 12 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ functions:
echo "crypt_shared library will be loaded from path: $CRYPT_SHARED_LIB_PATH"
fi
export GOFLAGS=-mod=vendor
AUTH="${AUTH}" \
SSL="${SSL}" \
MONGODB_URI="${MONGODB_URI}" \
Expand Down Expand Up @@ -571,7 +570,6 @@ functions:
# Per the LB testing spec, the URI of an LB fronting a single mongos should be used to configure internal
# testing Client instances, so we set MONGODB_URI to SINGLE_MONGOS_LB_URI.
export GOFLAGS=-mod=vendor
AUTH="${AUTH}" \
SSL="${SSL}" \
MONGODB_URI="${SINGLE_MONGOS_LB_URI}" \
Expand Down Expand Up @@ -688,6 +686,17 @@ functions:
params:
file: lb-expansion.yml

run-search-index-tests:
- command: shell.exec
type: test
params:
shell: "bash"
working_dir: src/go.mongodb.org/mongo-driver
script: |
${PREPARE_SHELL}
TEST_INDEX_URI="${TEST_INDEX_URI}" \
make evg-test-search-index
stop-load-balancer:
- command: shell.exec
params:
Expand Down Expand Up @@ -1108,7 +1117,6 @@ functions:
${PREPARE_SHELL}
export KMS_TLS_TESTCASE="${KMS_TLS_TESTCASE}"
export GOFLAGS=-mod=vendor
AUTH="${AUTH}" \
SSL="${SSL}" \
MONGODB_URI="${MONGODB_URI}" \
Expand Down Expand Up @@ -1136,7 +1144,6 @@ functions:
${PREPARE_SHELL}
export KMS_MOCK_SERVERS_RUNNING="true"
export GOFLAGS=-mod=vendor
AUTH="${AUTH}" \
SSL="${SSL}" \
MONGODB_URI="${MONGODB_URI}" \
Expand Down Expand Up @@ -1923,15 +1930,13 @@ tasks:
MONGO_GO_DRIVER_COMPRESSOR: "snappy"

# Build with the oldest supported version of Go.
- name: go1.13-build
- name: go1.18-build
tags: ["compile-check"]
commands:
- func: run-make
vars:
# We only test building the compilecheck submodule with Go 1.13 because the root module's
# go.mod file contains retract directives, which are not supported until Go 1.16.
targets: "build-compile-check"
BUILD_ENV: "PATH=/opt/golang/go1.13/bin:$PATH GOROOT=/opt/golang/go1.13"
BUILD_ENV: "PATH=/opt/golang/go1.18/bin:$PATH GOROOT=/opt/golang/go1.18"

# Build with the same Go version that we're using for tests.
- name: build
Expand Down Expand Up @@ -2259,6 +2264,14 @@ tasks:
${PREPARE_SHELL}
./.evergreen/run-deployed-lambda-aws-tests.sh
- name: "test-search-index"
commands:
- func: "bootstrap-mongo-orchestration"
vars:
VERSION: "latest"
TOPOLOGY: "replica_set"
- func: "run-search-index-tests"

axes:
- id: version
display_name: MongoDB Version
Expand Down Expand Up @@ -2314,7 +2327,7 @@ axes:
VENV_BIN_DIR: "Scripts"
- id: "rhel87-64-go-1-20"
display_name: "RHEL 8.7"
run_on: rhel8.7-large
run_on: rhel8.7-large
variables:
GO_DIST: "/opt/golang/go1.20"
- id: "macos11-go-1-20"
Expand Down Expand Up @@ -2618,6 +2631,44 @@ task_groups:
tasks:
- test-aws-lambda-deployed

- name: test-search-index-task-group
setup_group:
- func: fetch-source
- func: prepare-resources
- command: subprocess.exec
params:
working_dir: src/go.mongodb.org/mongo-driver
binary: bash
add_expansions_to_env: true
env:
MONGODB_VERSION: "7.0"
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
- command: expansions.update
params:
file: src/go.mongodb.org/mongo-driver/atlas-expansion.yml
- command: shell.exec
params:
working_dir: src/go.mongodb.org/mongo-driver
shell: bash
script: |-
echo "TEST_INDEX_URI: ${MONGODB_URI}" > atlas-expansion.yml
- command: expansions.update
params:
file: src/go.mongodb.org/mongo-driver/atlas-expansion.yml
teardown_group:
- command: subprocess.exec
params:
working_dir: src/go.mongodb.org/mongo-driver
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800
tasks:
- test-search-index

buildvariants:
- name: static-analysis
display_name: "Static Analysis"
Expand Down Expand Up @@ -2645,11 +2696,11 @@ buildvariants:
GO_DIST: "/opt/golang/go1.20"
tasks:
- name: ".compile-check"

- name: atlas-test
display_name: "Atlas test"
run_on:
- rhel8.7-large
- rhel8.7-large
expansions:
GO_DIST: "/opt/golang/go1.20"
tasks:
Expand All @@ -2658,7 +2709,7 @@ buildvariants:
- name: atlas-data-lake-test
display_name: "Atlas Data Lake Test"
run_on:
- rhel8.7-large
- rhel8.7-large
expansions:
GO_DIST: "/opt/golang/go1.20"
tasks:
Expand Down Expand Up @@ -2766,6 +2817,12 @@ buildvariants:
tasks:
- test-aws-lambda-task-group

- matrix_name: "searchindex-test"
matrix_spec: { version: ["7.0"], os-faas-80: ["rhel87-large-go-1-20"] }
display_name: "Search Index ${version} ${os-faas-80}"
tasks:
- test-search-index-task-group

- name: testgcpkms-variant
display_name: "GCP KMS"
run_on:
Expand Down
1 change: 0 additions & 1 deletion .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export PATH="${GOROOT}/bin:${GCC_PATH}:$GOPATH/bin:$PATH"
export PROJECT="${project}"
export PKG_CONFIG_PATH=$(pwd)/install/libmongocrypt/lib64/pkgconfig:$(pwd)/install/mongo-c-driver/lib/pkgconfig
export LD_LIBRARY_PATH=$(pwd)/install/libmongocrypt/lib64
export GOFLAGS=-mod=vendor

SSL=${SSL:-nossl}
if [ "$SSL" != "nossl" -a -z "${SERVERLESS+x}" ]; then
Expand Down
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,14 @@ install-lll:
check-fmt: install-lll
etc/check_fmt.sh

# check-modules runs "go mod tidy" then "go mod vendor" and exits with a non-zero exit code if there
# are any module or vendored modules changes. The intent is to confirm two properties:
#
# 1. Exactly the required modules are declared as dependencies. We should always be able to run
# "go mod tidy" and expect that no unrelated changes are made to the "go.mod" file.
#
# 2. All required modules are copied into the vendor/ directory and are an exact copy of the
# original module source code (i.e. the vendored modules are not modified from their original code).
# check-modules runs "go mod tidy" and exits with a non-zero exit code if there
# are any module changes. The intent is to confirm that exactly the required
# modules are declared as dependencies. We should always be able to run "go mod
# tidy" and expect that no unrelated changes are made to the "go.mod" file.
.PHONY: check-modules
check-modules:
go mod tidy -v
go mod vendor
git diff --exit-code go.mod go.sum ./vendor
git diff --exit-code go.mod go.sum

.PHONY: doc
doc:
Expand Down Expand Up @@ -159,6 +154,10 @@ evg-test-load-balancers:
go test $(BUILD_TAGS) ./mongo/integration -run TestLoadBalancerSupport -v -timeout $(TEST_TIMEOUT)s >> test.suite
go test $(BUILD_TAGS) ./mongo/integration/unified -run TestUnifiedSpec -v -timeout $(TEST_TIMEOUT)s >> test.suite

.PHONY: evg-test-search-index
evg-test-search-index:
go test ./mongo/integration -run TestSearchIndexProse -v -timeout $(TEST_TIMEOUT)s >> test.suite

.PHONY: evg-test-ocsp
evg-test-ocsp:
go test -v ./mongo -run TestOCSP $(OCSP_TLS_SHOULD_SUCCEED) >> test.suite
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ The MongoDB supported driver for Go.
-------------------------
## Requirements

- Go 1.13 or higher. We aim to support the latest versions of Go.
- `go mod tidy` will error when importing the Go Driver using Go versions older than 1.15 due to dependencies that import [io/fs](https://pkg.go.dev/io/fs). See golang/go issue [#44557](https://github.com/golang/go/issues/44557) for more information.
- Go 1.20 or higher is required to run the driver test suite.
- Go 1.18 or higher. We aim to support the latest versions of Go.
- Go 1.20 or higher is required to run the driver test suite.
- MongoDB 3.6 and higher.

-------------------------
Expand Down
4 changes: 2 additions & 2 deletions benchmark/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func MultiFindMany(ctx context.Context, tm TimerManager, iters int) error {
if err != nil {
return err
}
defer db.Client().Disconnect(ctx)
defer func() { _ = db.Client().Disconnect(ctx) }()

db = db.Client().Database("perftest")
if err = db.Drop(ctx); err != nil {
Expand Down Expand Up @@ -87,7 +87,7 @@ func multiInsertCase(ctx context.Context, tm TimerManager, iters int, data strin
if err != nil {
return err
}
defer db.Client().Disconnect(ctx)
defer func() { _ = db.Client().Disconnect(ctx) }()

db = db.Client().Database("perftest")
if err = db.Drop(ctx); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions benchmark/operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func BenchmarkClientWrite(b *testing.B) {
if err != nil {
b.Fatalf("error connecting: %v", err)
}
defer client.Disconnect(context.Background())
defer func() { _ = client.Disconnect(context.Background()) }()
coll := client.Database("test").Collection("test")
_, err = coll.DeleteMany(context.Background(), bson.D{})
if err != nil {
Expand Down Expand Up @@ -85,7 +85,7 @@ func BenchmarkClientBulkWrite(b *testing.B) {
if err != nil {
b.Fatalf("error connecting: %v", err)
}
defer client.Disconnect(context.Background())
defer func() { _ = client.Disconnect(context.Background()) }()
coll := client.Database("test").Collection("test")
_, err = coll.DeleteMany(context.Background(), bson.D{})
if err != nil {
Expand Down Expand Up @@ -134,7 +134,7 @@ func BenchmarkClientRead(b *testing.B) {
if err != nil {
b.Fatalf("error connecting: %v", err)
}
defer client.Disconnect(context.Background())
defer func() { _ = client.Disconnect(context.Background()) }()
coll := client.Database("test").Collection("test")
_, err = coll.DeleteMany(context.Background(), bson.D{})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions benchmark/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func SingleRunCommand(ctx context.Context, tm TimerManager, iters int) error {
if err != nil {
return err
}
defer db.Client().Disconnect(ctx)
defer func() { _ = db.Client().Disconnect(ctx) }()

cmd := bson.D{{handshake.LegacyHelloLowercase, true}}

Expand Down Expand Up @@ -130,7 +130,7 @@ func singleInsertCase(ctx context.Context, tm TimerManager, iters int, data stri
if err != nil {
return err
}
defer db.Client().Disconnect(ctx)
defer func() { _ = db.Client().Disconnect(ctx) }()

db = db.Client().Database("perftest")
if err = db.Drop(ctx); err != nil {
Expand Down
11 changes: 9 additions & 2 deletions bson/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,19 @@ func (r Raw) LookupErr(key ...string) (RawValue, error) {
// elements. If the document is not valid, the elements up to the invalid point will be returned
// along with an error.
func (r Raw) Elements() ([]RawElement, error) {
elems, err := bsoncore.Document(r).Elements()
doc := bsoncore.Document(r)
if len(doc) == 0 {
return nil, nil
}
elems, err := doc.Elements()
if err != nil {
return nil, err
}
relems := make([]RawElement, 0, len(elems))
for _, elem := range elems {
relems = append(relems, RawElement(elem))
}
return relems, err
return relems, nil
}

// Values returns this document as a slice of values. The returned slice will contain valid values.
Expand Down
2 changes: 1 addition & 1 deletion cmd/testkms/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func main() {
if err != nil {
panic(fmt.Sprintf("Connect error: %v", err))
}
defer keyVaultClient.Disconnect(context.Background())
defer func() { _ = keyVaultClient.Disconnect(context.Background()) }()

kmsProvidersMap := map[string]map[string]interface{}{
provider: {},
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Before starting to write code, look for existing [tickets](https://jira.mongodb.
The Go Driver team uses GitHub to manage and review all code changes. Patches should generally be made against the master (default) branch and include relevant tests, if
applicable.

Code should compile and tests should pass under all Go versions which the driver currently supports. Currently the Go Driver supports a minimum version of Go 1.13 and requires Go 1.20 for development. Please run the following Make targets to validate your changes:
Code should compile and tests should pass under all Go versions which the driver currently supports. Currently the Go Driver supports a minimum version of Go 1.18 and requires Go 1.20 for development. Please run the following Make targets to validate your changes:
- `make fmt`
- `make lint` (requires [golangci-lint](https://github.com/golangci/golangci-lint) and [lll](https://github.com/walle/lll) to be installed and available in the `PATH`)
- `make test`
Expand Down
4 changes: 2 additions & 2 deletions etc/check_license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ do
esac
done

# Find all .go files not in the vendor directory and try to write a license notice.
GO_FILES=$(find . -path ./vendor -prune -o -type f -name "*.go" -print)
# Find all .go files and try to write a license notice.
GO_FILES=$(find . -type f -name "*.go" -print)

for file in $GO_FILES
do
Expand Down
21 changes: 6 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
module go.mongodb.org/mongo-driver

go 1.13

retract (
v1.11.8 // Contains minor changes meant for v1.12.1.
v1.11.5 // Contains import failure.

// Retract v1.11.0 through v1.11.2 because they contain a data race bug in
// operation memory pooling that may cause undefined behavior when reading
// raw BSON responses in error documents. Resolved by GODRIVER-2677.
[v1.11.0, v1.11.2]

v1.10.0 // Contains a possible data corruption bug in RewrapManyDataKey when using libmongocrypt versions less than 1.5.2.
[v1.7.0, v1.7.1] // Contains data race bug in background connection establishment.
[v1.6.0, v1.6.1] // Contains data race bug in background connection establishment.
)
go 1.18

require (
github.com/davecgh/go-spew v1.1.1
Expand All @@ -27,5 +13,10 @@ require (
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
)

require (
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
)
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,19 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
Expand Down
Loading

0 comments on commit a6d3aca

Please sign in to comment.