...

Text file src/go.mongodb.org/mongo-driver/Makefile

Documentation: go.mongodb.org/mongo-driver

     1TEST_TIMEOUT = 1800
     2
     3### Utility targets. ###
     4.PHONY: default
     5default: build check-license check-fmt check-modules lint test-short
     6
     7.PHONY: add-license
     8add-license:
     9	etc/check_license.sh -a
    10
    11.PHONY: check-license
    12check-license:
    13	etc/check_license.sh
    14
    15.PHONY: build
    16build: cross-compile build-tests build-compile-check
    17	go build ./...
    18	go build $(BUILD_TAGS) ./...
    19
    20# Use ^$ to match no tests so that no tests are actually run but all tests are
    21# compiled. Run with -short to ensure none of the TestMain functions try to
    22# connect to a server.
    23.PHONY: build-tests
    24build-tests:
    25	go test -short $(BUILD_TAGS) -run ^$$ ./...
    26
    27.PHONY: build-compile-check
    28build-compile-check:
    29	etc/compile_check.sh
    30
    31# Cross-compiling on Linux for architectures 386, arm, arm64, amd64, ppc64le, and s390x.
    32# Omit any build tags because we don't expect our build environment to support compiling the C
    33# libraries for other architectures.
    34.PHONY: cross-compile
    35cross-compile:
    36	GOOS=linux GOARCH=386 go build ./...
    37	GOOS=linux GOARCH=arm go build ./...
    38	GOOS=linux GOARCH=arm64 go build ./...
    39	GOOS=linux GOARCH=amd64 go build ./...
    40	GOOS=linux GOARCH=ppc64le go build ./...
    41	GOOS=linux GOARCH=s390x go build ./...
    42
    43.PHONY: install-lll
    44install-lll:
    45	go install github.com/walle/lll/...@latest
    46
    47.PHONY: check-fmt
    48check-fmt: install-lll
    49	etc/check_fmt.sh
    50
    51# check-modules runs "go mod tidy" then "go mod vendor" and exits with a non-zero exit code if there
    52# are any module or vendored modules changes. The intent is to confirm two properties:
    53#
    54# 1. Exactly the required modules are declared as dependencies. We should always be able to run
    55# "go mod tidy" and expect that no unrelated changes are made to the "go.mod" file.
    56#
    57# 2. All required modules are copied into the vendor/ directory and are an exact copy of the
    58# original module source code (i.e. the vendored modules are not modified from their original code).
    59.PHONY: check-modules
    60check-modules:
    61	go mod tidy -v
    62	go mod vendor
    63	git diff --exit-code go.mod go.sum ./vendor
    64
    65.PHONY: doc
    66doc:
    67	godoc -http=:6060 -index
    68
    69.PHONY: fmt
    70fmt:
    71	go fmt ./...
    72
    73.PHONY: install-golangci-lint
    74install-golangci-lint:
    75	go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
    76
    77# Lint with various GOOS and GOARCH targets to catch static analysis failures that may only affect
    78# specific operating systems or architectures. For example, staticcheck will only check for 64-bit
    79# alignment of atomically accessed variables on 32-bit architectures (see
    80# https://staticcheck.io/docs/checks#SA1027)
    81.PHONY: lint
    82lint: install-golangci-lint
    83	GOOS=linux GOARCH=386 golangci-lint run --config .golangci.yml ./...
    84	GOOS=linux GOARCH=arm golangci-lint run --config .golangci.yml ./...
    85	GOOS=linux GOARCH=arm64 golangci-lint run --config .golangci.yml ./...
    86	GOOS=linux GOARCH=amd64 golangci-lint run --config .golangci.yml ./...
    87	GOOS=linux GOARCH=ppc64le golangci-lint run --config .golangci.yml ./...
    88	GOOS=linux GOARCH=s390x golangci-lint run --config .golangci.yml ./...
    89
    90.PHONY: update-notices
    91update-notices:
    92	etc/generate_notices.pl > THIRD-PARTY-NOTICES
    93
    94### Local testing targets. ###
    95.PHONY: test
    96test:
    97	go test $(BUILD_TAGS) -timeout $(TEST_TIMEOUT)s -p 1 ./...
    98
    99.PHONY: test-cover
   100test-cover:
   101	go test $(BUILD_TAGS) -timeout $(TEST_TIMEOUT)s -cover $(COVER_ARGS) -p 1 ./...
   102
   103.PHONY: test-race
   104test-race:
   105	go test $(BUILD_TAGS) -timeout $(TEST_TIMEOUT)s -race -p 1 ./...
   106
   107.PHONY: test-short
   108test-short:
   109	go test $(BUILD_TAGS) -timeout 60s -short ./...
   110
   111### Local FaaS targets. ###
   112.PHONY: build-faas-awslambda
   113build-faas-awslambda:
   114	$(if $(MONGODB_URI),,$(error MONGODB_URI is not set))
   115	$(MAKE) -C internal/test/faas/awslambda
   116
   117### Evergreen specific targets. ###
   118.PHONY: build-aws-ecs-test
   119build-aws-ecs-test:
   120	go build $(BUILD_TAGS) ./cmd/testaws/main.go
   121
   122.PHONY: evg-test
   123evg-test:
   124	go test -exec "env PKG_CONFIG_PATH=${PKG_CONFIG_PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)}" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s -p 1 ./... >> test.suite
   125
   126.PHONY: evg-test-atlas-data-lake
   127evg-test-atlas-data-lake:
   128	ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./mongo/integration -run TestUnifiedSpecs/atlas-data-lake-testing >> spec_test.suite
   129	ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./mongo/integration -run TestAtlasDataLake >> spec_test.suite
   130
   131.PHONY: evg-test-enterprise-auth
   132evg-test-enterprise-auth:
   133	go run -tags gssapi ./cmd/testentauth/main.go
   134
   135.PHONY: evg-test-kmip
   136evg-test-kmip:
   137	go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionSpec/kmipKMS >> test.suite
   138	go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionProse/data_key_and_double_encryption >> test.suite
   139	go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionProse/corpus >> test.suite
   140	go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionProse/custom_endpoint >> test.suite
   141	go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionProse/kms_tls_options_test >> test.suite
   142
   143.PHONY: evg-test-kms
   144evg-test-kms:
   145	go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionProse/kms_tls_tests >> test.suite
   146
   147.PHONY: evg-test-load-balancers
   148evg-test-load-balancers:
   149	# Load balancer should be tested with all unified tests as well as tests in the following
   150	# components: retryable reads, retryable writes, change streams, initial DNS seedlist discovery.
   151	go test $(BUILD_TAGS) ./mongo/integration -run TestUnifiedSpecs/retryable-reads -v -timeout $(TEST_TIMEOUT)s >> test.suite
   152	go test $(BUILD_TAGS) ./mongo/integration -run TestRetryableWritesSpec -v -timeout $(TEST_TIMEOUT)s >> test.suite
   153	go test $(BUILD_TAGS) ./mongo/integration -run TestChangeStreamSpec -v -timeout $(TEST_TIMEOUT)s >> test.suite
   154	go test $(BUILD_TAGS) ./mongo/integration -run TestInitialDNSSeedlistDiscoverySpec/load_balanced -v -timeout $(TEST_TIMEOUT)s >> test.suite
   155	go test $(BUILD_TAGS) ./mongo/integration -run TestLoadBalancerSupport -v -timeout $(TEST_TIMEOUT)s >> test.suite
   156	go test $(BUILD_TAGS) ./mongo/integration -run TestLoadBalancedConnectionHandshake -v -timeout $(TEST_TIMEOUT)s >> test.suite
   157	go test $(BUILD_TAGS) ./mongo/integration/unified -run TestUnifiedSpec -v -timeout $(TEST_TIMEOUT)s >> test.suite
   158
   159.PHONY: evg-test-search-index
   160evg-test-search-index:
   161	go test ./mongo/integration -run TestSearchIndexProse -v -timeout $(TEST_TIMEOUT)s >> test.suite
   162
   163.PHONY: evg-test-ocsp
   164evg-test-ocsp:
   165	go test -v ./mongo -run TestOCSP $(OCSP_TLS_SHOULD_SUCCEED) >> test.suite
   166
   167.PHONY: evg-test-serverless
   168evg-test-serverless:
   169	# Serverless should be tested with all unified tests as well as tests in the following components: CRUD, load balancer,
   170	# retryable reads, retryable writes, sessions, transactions and cursor behavior.
   171	go test $(BUILD_TAGS) ./mongo/integration -run TestCrudSpec -v -timeout $(TEST_TIMEOUT)s >> test.suite
   172	go test $(BUILD_TAGS) ./mongo/integration -run TestWriteErrorsWithLabels -v -timeout $(TEST_TIMEOUT)s >> test.suite
   173	go test $(BUILD_TAGS) ./mongo/integration -run TestWriteErrorsDetails -v -timeout $(TEST_TIMEOUT)s >> test.suite
   174	go test $(BUILD_TAGS) ./mongo/integration -run TestHintErrors -v -timeout $(TEST_TIMEOUT)s >> test.suite
   175	go test $(BUILD_TAGS) ./mongo/integration -run TestWriteConcernError -v -timeout $(TEST_TIMEOUT)s >> test.suite
   176	go test $(BUILD_TAGS) ./mongo/integration -run TestErrorsCodeNamePropagated -v -timeout $(TEST_TIMEOUT)s >> test.suite
   177	go test $(BUILD_TAGS) ./mongo/integration -run TestLoadBalancerSupport -v -timeout $(TEST_TIMEOUT)s >> test.suite
   178	go test $(BUILD_TAGS) ./mongo/integration -run TestUnifiedSpecs/retryable-reads -v -timeout $(TEST_TIMEOUT)s >> test.suite
   179	go test $(BUILD_TAGS) ./mongo/integration -run TestRetryableReadsProse -v -timeout $(TEST_TIMEOUT)s >> test.suite
   180	go test $(BUILD_TAGS) ./mongo/integration -run TestRetryableWritesSpec -v -timeout $(TEST_TIMEOUT)s >> test.suite
   181	go test $(BUILD_TAGS) ./mongo/integration -run TestRetryableWritesProse -v -timeout $(TEST_TIMEOUT)s >> test.suite
   182	go test $(BUILD_TAGS) ./mongo/integration -run TestUnifiedSpecs/sessions -v -timeout $(TEST_TIMEOUT)s >> test.suite
   183	go test $(BUILD_TAGS) ./mongo/integration -run TestSessionsProse -v -timeout $(TEST_TIMEOUT)s >> test.suite
   184	go test $(BUILD_TAGS) ./mongo/integration -run TestUnifiedSpecs/transactions/legacy -v -timeout $(TEST_TIMEOUT)s >> test.suite
   185	go test $(BUILD_TAGS) ./mongo/integration -run TestConvenientTransactions -v -timeout $(TEST_TIMEOUT)s >> test.suite
   186	go test $(BUILD_TAGS) ./mongo/integration -run TestCursor -v -timeout $(TEST_TIMEOUT)s >> test.suite
   187	go test $(BUILD_TAGS) ./mongo/integration/unified -run TestUnifiedSpec -v -timeout $(TEST_TIMEOUT)s >> test.suite
   188	go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionSpec >> test.suite
   189	go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionProse >> test.suite
   190
   191.PHONY: evg-test-versioned-api
   192evg-test-versioned-api:
   193	# Versioned API related tests are in the mongo, integration and unified packages.
   194	go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo >> test.suite
   195	go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration >> test.suite
   196	go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration/unified >> test.suite
   197
   198.PHONY: build-kms-test
   199build-kms-test:
   200	go build $(BUILD_TAGS) ./cmd/testkms
   201
   202### Benchmark specific targets and support. ###
   203.PHONY: benchmark
   204benchmark:perf
   205	go test $(BUILD_TAGS) -benchmem -bench=. ./benchmark | test benchmark.suite
   206
   207.PHONY: driver-benchmark
   208driver-benchmark:perf
   209	@go run cmd/godriver-benchmark/main.go | tee perf.suite
   210
   211perf:driver-test-data.tar.gz
   212	tar -zxf $< $(if $(eq $(UNAME_S),Darwin),-s , --transform=s)/testdata/perf/
   213	@touch $@
   214
   215driver-test-data.tar.gz:
   216	curl --retry 5 "https://s3.amazonaws.com/boxes.10gen.com/build/driver-test-data.tar.gz" -o driver-test-data.tar.gz --silent --max-time 120

View as plain text