Skip to content

Commit 6d24dfa

Browse files
committed
Merge remote-tracking branch 'origin/master' into GODRIVER-3241
2 parents badac9d + ad1166b commit 6d24dfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1476
-857
lines changed

.evergreen/config.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ functions:
299299
params:
300300
shell: "bash"
301301
working_dir: src/go.mongodb.org/mongo-driver
302-
include_expansions_in_env: ["TOPOLOGY", "AUTH", "SSL", "MONGODB_URI", "CRYPT_SHARED_LIB_PATH", "SKIP_CRYPT_SHARED_LIB", "RACE", "MONGO_GO_DRIVER_COMPRESSOR", "REQUIRE_API_VERSION", "LOAD_BALANCER"]
302+
include_expansions_in_env: ["TOPOLOGY", "AUTH", "SSL", "SKIP_CSOT_TESTS", "MONGODB_URI", "CRYPT_SHARED_LIB_PATH", "SKIP_CRYPT_SHARED_LIB", "RACE", "MONGO_GO_DRIVER_COMPRESSOR", "REQUIRE_API_VERSION", "LOAD_BALANCER"]
303303
script: |
304304
${PREPARE_SHELL}
305305
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
@@ -2005,6 +2005,8 @@ axes:
20052005
GCC_PATH: "/cygdrive/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin"
20062006
GO_DIST: "C:\\golang\\go1.22"
20072007
VENV_BIN_DIR: "Scripts"
2008+
# CSOT tests are unreliable on our slow Windows hosts.
2009+
SKIP_CSOT_TESTS: true
20082010
- id: "rhel87-64"
20092011
display_name: "RHEL 8.7"
20102012
run_on: rhel8.7-large
@@ -2016,6 +2018,8 @@ axes:
20162018
batchtime: 1440 # Run at most once per 24 hours.
20172019
variables:
20182020
GO_DIST: "/opt/golang/go1.22"
2021+
# CSOT tests are unreliable on our slow macOS hosts.
2022+
SKIP_CSOT_TESTS: true
20192023

20202024
# OSes that require >= 4.0 for SSL
20212025
- id: os-ssl-40
@@ -2029,6 +2033,8 @@ axes:
20292033
GCC_PATH: "/cygdrive/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin"
20302034
GO_DIST: "C:\\golang\\go1.22"
20312035
VENV_BIN_DIR: "Scripts"
2036+
# CSOT tests are unreliable on our slow Windows hosts.
2037+
SKIP_CSOT_TESTS: true
20322038
- id: "rhel87-64"
20332039
display_name: "RHEL 8.7"
20342040
run_on: rhel8.7-large
@@ -2040,6 +2046,8 @@ axes:
20402046
batchtime: 1440 # Run at most once per 24 hours.
20412047
variables:
20422048
GO_DIST: "/opt/golang/go1.22"
2049+
# CSOT tests are unreliable on our slow macOS hosts.
2050+
SKIP_CSOT_TESTS: true
20432051

20442052
- id: ocsp-rhel-87
20452053
display_name: OS
@@ -2061,6 +2069,8 @@ axes:
20612069
GCC_PATH: "/cygdrive/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin"
20622070
GO_DIST: "C:\\golang\\go1.22"
20632071
SKIP_ECS_AUTH_TEST: true
2072+
# CSOT tests are unreliable on our slow Windows hosts.
2073+
SKIP_CSOT_TESTS: true
20642074
- id: "ubuntu2004-64"
20652075
display_name: "Ubuntu 20.04"
20662076
run_on: ubuntu2004-test
@@ -2075,6 +2085,8 @@ axes:
20752085
SKIP_ECS_AUTH_TEST: true
20762086
SKIP_EC2_AUTH_TEST: true
20772087
SKIP_WEB_IDENTITY_AUTH_TEST: true
2088+
# CSOT tests are unreliable on our slow macOS hosts.
2089+
SKIP_CSOT_TESTS: true
20782090

20792091
- id: os-faas-80
20802092
display_name: OS
@@ -2348,6 +2360,7 @@ buildvariants:
23482360
run_on:
23492361
- rhel8.7-small
23502362
expansions:
2363+
# Keep this in sync with go version used in etc/golangci-lint.sh
23512364
GO_DIST: "/opt/golang/go1.22"
23522365
tasks:
23532366
- name: ".static-analysis"
@@ -2386,7 +2399,7 @@ buildvariants:
23862399
run_on:
23872400
- rhel8.7-small
23882401
expansions:
2389-
GO_DIST: "/opt/golang/go1.20"
2402+
GO_DIST: "/opt/golang/go1.22"
23902403
tasks:
23912404
- name: "backport-pr"
23922405

.evergreen/run-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ fi
8787

8888
AUTH=${AUTH} \
8989
SSL=${SSL} \
90+
SKIP_CSOT_TESTS=${SKIP_CSOT_TESTS} \
9091
MONGO_GO_DRIVER_CA_FILE=${MONGO_GO_DRIVER_CA_FILE} \
9192
MONGO_GO_DRIVER_KEY_FILE=${MONGO_GO_DRIVER_KEY_FILE} \
9293
MONGO_GO_DRIVER_PKCS8_ENCRYPTED_KEY_FILE=${MONGO_GO_DRIVER_PKCS8_ENCRYPTED_KEY_FILE} \

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v4
2020
- uses: actions/setup-python@v5
21+
- uses: actions/setup-go@v5
22+
with:
23+
go-version: 'stable'
2124
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,18 @@ repos:
5050
- id: markdown-link-check
5151
exclude: ^(vendor)
5252

53-
- repo: https://github.com/golangci/golangci-lint
54-
rev: v1.60.1
55-
hooks:
56-
- id: golangci-lint
57-
5853
- repo: local
5954
hooks:
6055
- id: executable-shell
6156
name: executable-shell
6257
entry: chmod +x
6358
language: system
6459
types: [shell]
60+
61+
- id: golangci-lint
62+
name: golangci-lint
63+
language: system
64+
types: [go]
65+
require_serial: true
66+
pass_filenames: false
67+
entry: etc/golangci-lint.sh

Taskfile.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,13 @@ tasks:
5757
# alignment of atomically accessed variables on 32-bit architectures (see
5858
# https://staticcheck.io/docs/checks#SA1027)
5959
lint:
60-
deps: [install-golangci-lint]
6160
cmds:
62-
- GOOS=linux GOARCH=386 golangci-lint run --config .golangci.yml ./...
63-
- GOOS=linux GOARCH=arm golangci-lint run --config .golangci.yml ./...
64-
- GOOS=linux GOARCH=arm64 golangci-lint run --config .golangci.yml ./...
65-
- GOOS=linux GOARCH=amd64 golangci-lint run --config .golangci.yml ./...
66-
- GOOS=linux GOARCH=ppc64le golangci-lint run --config .golangci.yml ./...
67-
- GOOS=linux GOARCH=s390x golangci-lint run --config .golangci.yml ./...
61+
- GOOS=linux GOARCH=386 etc/golangci-lint.sh
62+
- GOOS=linux GOARCH=arm etc/golangci-lint.sh
63+
- GOOS=linux GOARCH=arm64 etc/golangci-lint.sh
64+
- GOOS=linux GOARCH=amd64 etc/golangci-lint.sh
65+
- GOOS=linux GOARCH=ppc64le etc/golangci-lint.sh
66+
- GOOS=linux GOARCH=s390x etc/golangci-lint.sh
6867

6968
update-notices: bash etc/generate_notices.pl > THIRD-PARTY-NOTICES
7069

@@ -188,10 +187,3 @@ tasks:
188187
internal: true
189188
cmds:
190189
- go install github.com/walle/lll/...@latest
191-
192-
# NOTE: A golangci-lint version is also pinned in .pre-commit-config.yaml. Make
193-
# sure to change it there to keep it in-sync with what's used here!
194-
install-golangci-lint:
195-
internal: true
196-
cmds:
197-
- go install github.com/golangci/golangci-lint/cmd/[email protected]

docs/migration-2.0.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,10 @@ for _, set := range options.Client().ApplyURI(uri).Opts {
627627
return clientOptionAdder{option: &opts}
628628
```
629629

630+
### DeleteManyOptions / DeleteOneOptions
631+
632+
The `DeleteOptions` has been separated into `DeleteManyOptions` and `DeleteOneOptions` to configure the corresponding `DeleteMany` and `DeleteOne` operations.
633+
630634
### FindOneOptions
631635

632636
The following types are not valid for a `findOne` operation and have been removed:
@@ -636,6 +640,10 @@ The following types are not valid for a `findOne` operation and have been remove
636640
- `MaxAwaitTime`
637641
- `NoCursorTimeout`
638642

643+
### UpdateManyOptions / UpdateOneOptions
644+
645+
The `UpdateOptions` has been separated into `UpdateManyOptions` and `UpdateOneOptions` to configure the corresponding `UpdateMany` and `UpdateOne` operations.
646+
639647
### Merge\*Options
640648

641649
All functions that merge options have been removed in favor of a generic solution. See [GODRIVER-2696](https://jira.mongodb.org/browse/GODRIVER-2696) for more information.

etc/golangci-lint.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
# Unset the cross-compiler overrides while downloading binaries.
5+
GOOS_ORIG=${GOOS:-}
6+
export GOOS=
7+
GOARCH_ORIG=${GOARCH:-}
8+
export GOARCH=
9+
10+
# Keep this in sync with go version used in static-analysis Evergreen build variant.
11+
go install golang.org/dl/go1.22.7@latest
12+
go1.22.7 download
13+
export PATH="$(go1.22.7 env GOROOT)/bin:$PATH"
14+
go install github.com/golangci/golangci-lint/cmd/[email protected]
15+
16+
export GOOS=$GOOS_ORIG
17+
export GOARCH=$GOARCH_ORIG
18+
golangci-lint run --config .golangci.yml ./...

internal/failpoint/failpoint.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (C) MongoDB, Inc. 2024-present.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"); you may
4+
// not use this file except in compliance with the License. You may obtain
5+
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
package failpoint
8+
9+
import (
10+
"go.mongodb.org/mongo-driver/v2/bson"
11+
)
12+
13+
const (
14+
// ModeAlwaysOn is the fail point mode that enables the fail point for an
15+
// indefinite number of matching commands.
16+
ModeAlwaysOn = "alwaysOn"
17+
18+
// ModeOff is the fail point mode that disables the fail point.
19+
ModeOff = "off"
20+
)
21+
22+
// FailPoint is used to configure a server fail point. It is intended to be
23+
// passed as the command argument to RunCommand.
24+
//
25+
// For more information about fail points, see
26+
// https://github.com/mongodb/specifications/tree/HEAD/source/transactions/tests#server-fail-point
27+
type FailPoint struct {
28+
ConfigureFailPoint string `bson:"configureFailPoint"`
29+
// Mode should be a string, FailPointMode, or map[string]interface{}
30+
Mode interface{} `bson:"mode"`
31+
Data Data `bson:"data"`
32+
}
33+
34+
// Mode configures when a fail point will be enabled. It is used to set the
35+
// FailPoint.Mode field.
36+
type Mode struct {
37+
Times int32 `bson:"times"`
38+
Skip int32 `bson:"skip"`
39+
}
40+
41+
// Data configures how a fail point will behave. It is used to set the
42+
// FailPoint.Data field.
43+
type Data struct {
44+
FailCommands []string `bson:"failCommands,omitempty"`
45+
CloseConnection bool `bson:"closeConnection,omitempty"`
46+
ErrorCode int32 `bson:"errorCode,omitempty"`
47+
FailBeforeCommitExceptionCode int32 `bson:"failBeforeCommitExceptionCode,omitempty"`
48+
ErrorLabels *[]string `bson:"errorLabels,omitempty"`
49+
WriteConcernError *WriteConcernError `bson:"writeConcernError,omitempty"`
50+
BlockConnection bool `bson:"blockConnection,omitempty"`
51+
BlockTimeMS int32 `bson:"blockTimeMS,omitempty"`
52+
AppName string `bson:"appName,omitempty"`
53+
}
54+
55+
// WriteConcernError is the write concern error to return when the fail point is
56+
// triggered. It is used to set the FailPoint.Data.WriteConcernError field.
57+
type WriteConcernError struct {
58+
Code int32 `bson:"code"`
59+
Name string `bson:"codeName"`
60+
Errmsg string `bson:"errmsg"`
61+
ErrorLabels *[]string `bson:"errorLabels,omitempty"`
62+
ErrInfo bson.Raw `bson:"errInfo,omitempty"`
63+
}

internal/integration/change_stream_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"go.mongodb.org/mongo-driver/v2/event"
1818
"go.mongodb.org/mongo-driver/v2/internal/assert"
1919
"go.mongodb.org/mongo-driver/v2/internal/eventtest"
20+
"go.mongodb.org/mongo-driver/v2/internal/failpoint"
2021
"go.mongodb.org/mongo-driver/v2/internal/integration/mtest"
2122
"go.mongodb.org/mongo-driver/v2/internal/require"
2223
"go.mongodb.org/mongo-driver/v2/mongo"
@@ -523,12 +524,12 @@ func TestChangeStream_ReplicaSet(t *testing.T) {
523524
SetReadConcern(mtest.MajorityRc).
524525
SetRetryReads(false))
525526

526-
mt.SetFailPoint(mtest.FailPoint{
527+
mt.SetFailPoint(failpoint.FailPoint{
527528
ConfigureFailPoint: "failCommand",
528-
Mode: mtest.FailPointMode{
529+
Mode: failpoint.Mode{
529530
Times: 1,
530531
},
531-
Data: mtest.FailPointData{
532+
Data: failpoint.Data{
532533
FailCommands: []string{"aggregate"},
533534
CloseConnection: true,
534535
},
@@ -546,12 +547,12 @@ func TestChangeStream_ReplicaSet(t *testing.T) {
546547
SetReadConcern(mtest.MajorityRc).
547548
SetRetryReads(false))
548549

549-
mt.SetFailPoint(mtest.FailPoint{
550+
mt.SetFailPoint(failpoint.FailPoint{
550551
ConfigureFailPoint: "failCommand",
551-
Mode: mtest.FailPointMode{
552+
Mode: failpoint.Mode{
552553
Times: 1,
553554
},
554-
Data: mtest.FailPointData{
555+
Data: failpoint.Data{
555556
FailCommands: []string{"getMore"},
556557
CloseConnection: true,
557558
},
@@ -574,12 +575,12 @@ func TestChangeStream_ReplicaSet(t *testing.T) {
574575
SetPoolMonitor(tpm.PoolMonitor).
575576
SetRetryReads(true))
576577

577-
mt.SetFailPoint(mtest.FailPoint{
578+
mt.SetFailPoint(failpoint.FailPoint{
578579
ConfigureFailPoint: "failCommand",
579-
Mode: mtest.FailPointMode{
580+
Mode: failpoint.Mode{
580581
Times: 2,
581582
},
582-
Data: mtest.FailPointData{
583+
Data: failpoint.Data{
583584
FailCommands: []string{"aggregate"},
584585
CloseConnection: true,
585586
},

internal/integration/client_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"go.mongodb.org/mongo-driver/v2/event"
2121
"go.mongodb.org/mongo-driver/v2/internal/assert"
2222
"go.mongodb.org/mongo-driver/v2/internal/eventtest"
23+
"go.mongodb.org/mongo-driver/v2/internal/failpoint"
2324
"go.mongodb.org/mongo-driver/v2/internal/handshake"
2425
"go.mongodb.org/mongo-driver/v2/internal/integration/mtest"
2526
"go.mongodb.org/mongo-driver/v2/internal/integtest"
@@ -678,10 +679,10 @@ func TestClient(t *testing.T) {
678679
_, err := mt.Coll.InsertOne(context.Background(), bson.D{})
679680
require.NoError(mt, err)
680681

681-
mt.SetFailPoint(mtest.FailPoint{
682+
mt.SetFailPoint(failpoint.FailPoint{
682683
ConfigureFailPoint: "failCommand",
683-
Mode: "alwaysOn",
684-
Data: mtest.FailPointData{
684+
Mode: failpoint.ModeAlwaysOn,
685+
Data: failpoint.Data{
685686
FailCommands: []string{"find", "insert"},
686687
BlockConnection: true,
687688
BlockTimeMS: 500,

0 commit comments

Comments
 (0)