Skip to content

Commit 399ea1e

Browse files
authored
GODRIVER-2236 Fix atomic op alignment and run linters on multiple architectures. (#810)
1 parent 14339a4 commit 399ea1e

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ EXAMPLES_TEST_PKGS = $(shell etc/list_test_pkgs.sh ./examples)
1313
PKGS = $(BSON_PKGS) $(EVENT_PKGS) $(MONGO_PKGS) $(UNSTABLE_PKGS) $(TAG_PKG) $(EXAMPLES_PKGS)
1414
TEST_PKGS = $(BSON_TEST_PKGS) $(EVENT_TEST_PKGS) $(MONGO_TEST_PKGS) $(UNSTABLE_TEST_PKGS) $(TAG_PKG) $(EXAMPLES_TEST_PKGS)
1515
ATLAS_URIS = "$(ATLAS_FREE)" "$(ATLAS_REPLSET)" "$(ATLAS_SHARD)" "$(ATLAS_TLS11)" "$(ATLAS_TLS12)" "$(ATLAS_FREE_SRV)" "$(ATLAS_REPLSET_SRV)" "$(ATLAS_SHARD_SRV)" "$(ATLAS_TLS11_SRV)" "$(ATLAS_TLS12_SRV)" "$(ATLAS_SERVERLESS)" "$(ATLAS_SERVERLESS_SRV)"
16+
GODISTS=linux/amd64 linux/386 linux/arm64 linux/arm linux/s390x
1617

1718
TEST_TIMEOUT = 1800
1819

@@ -59,7 +60,13 @@ fmt:
5960

6061
.PHONY: lint
6162
lint:
62-
golangci-lint run --config .golangci.yml ./...
63+
for dist in $(GODISTS); do \
64+
goos=$$(echo $$dist | cut -d/ -f 1) ; \
65+
goarch=$$(echo $$dist | cut -d/ -f 2) ; \
66+
command="GOOS=$$goos GOARCH=$$goarch golangci-lint run --config .golangci.yml ./..." ; \
67+
echo $$command ; \
68+
eval $$command ; \
69+
done
6370

6471
.PHONY: test
6572
test:

mongo/integration/mtest/mongotest.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ type WriteConcernErrorData struct {
8484

8585
// T is a wrapper around testing.T.
8686
type T struct {
87+
// connsCheckedOut is the net number of connections checked out during test execution.
88+
// It must be accessed using the atomic package and should be at the beginning of the struct.
89+
// - atomic bug: https://pkg.go.dev/sync/atomic#pkg-note-BUG
90+
// - suggested layout: https://go101.org/article/memory-layout.html
91+
connsCheckedOut int64
92+
8793
*testing.T
8894

8995
// members for only this T instance
@@ -104,7 +110,6 @@ type T struct {
104110
dataLake *bool
105111
ssl *bool
106112
collCreateOpts bson.D
107-
connsCheckedOut int64 // net number of connections checked out during test execution
108113
requireAPIVersion *bool
109114

110115
// options copied to sub-tests

x/mongo/driver/topology/server.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,15 @@ func connectionStateString(state int64) string {
8282

8383
// Server is a single server within a topology.
8484
type Server struct {
85-
cfg *serverConfig
86-
address address.Address
85+
// connectionstate must be accessed using the atomic package and should be at the beginning of
86+
// the struct.
87+
// - atomic bug: https://pkg.go.dev/sync/atomic#pkg-note-BUG
88+
// - suggested layout: https://go101.org/article/memory-layout.html
8789
connectionstate int64
8890

91+
cfg *serverConfig
92+
address address.Address
93+
8994
// connection related fields
9095
pool *pool
9196

0 commit comments

Comments
 (0)