diff --git a/.evergreen/config.yml b/.evergreen/config.yml index a4096c1bfb..c25e2e1afc 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -58,7 +58,6 @@ functions: export PROJECT_DIRECTORY="$(pwd)" export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration" export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" - export UPLOAD_BUCKET="${project}" export PROJECT="${project}" # If on Windows, convert paths with cygpath. GOROOT should not be converted as Windows expects it @@ -70,7 +69,6 @@ functions: export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY) export MONGO_ORCHESTRATION_HOME=$(cygpath -m $MONGO_ORCHESTRATION_HOME) export MONGODB_BINARIES=$(cygpath -m $MONGODB_BINARIES) - export UPLOAD_BUCKET=$(cygpath -m $UPLOAD_BUCKET) export PROJECT=$(cygpath -m $PROJECT) # Set home variables for Windows, too. @@ -97,8 +95,11 @@ functions: go version go env + # Install taskfile. + go install github.com/go-task/task/v3/cmd/task@latest + # Install libmongocrypt. - bash etc/install-libmongocrypt.sh + task install-libmongocrypt if [ "Windows_NT" = "$OS" ]; then export PATH=$PATH:/cygdrive/c/libmongocrypt/bin fi @@ -108,7 +109,6 @@ functions: DRIVERS_TOOLS: "$DRIVERS_TOOLS" MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME" MONGODB_BINARIES: "$MONGODB_BINARIES" - UPLOAD_BUCKET: "$UPLOAD_BUCKET" PROJECT_DIRECTORY: "$PROJECT_DIRECTORY" PREPARE_SHELL: | set -o errexit @@ -120,7 +120,6 @@ functions: export PROJECT_DIRECTORY="$PROJECT_DIRECTORY" export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME" export MONGODB_BINARIES="$MONGODB_BINARIES" - export UPLOAD_BUCKET="$UPLOAD_BUCKET" export PROJECT="$PROJECT" export TMPDIR="$MONGO_ORCHESTRATION_HOME/db" export PKG_CONFIG_PATH=$(pwd)/install/libmongocrypt/lib64/pkgconfig @@ -154,24 +153,29 @@ functions: params: files: - "src/go.mongodb.org/mongo-driver/*.suite" + - command: ec2.assume_role + params: + role_arn: ${assume_role_arn} - command: s3.put params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} + aws_key: ${AWS_ACCESS_KEY_ID} + aws_secret: ${AWS_SECRET_ACCESS_KEY} + aws_session_token: ${AWS_SESSION_TOKEN} local_file: ${DRIVERS_TOOLS}/.evergreen/test_logs.tar.gz - remote_file: ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-drivers-tools-logs.tar.gz - bucket: mciuploads + remote_file: ${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-drivers-tools-logs.tar.gz + bucket: ${aws_bucket} permissions: public-read content_type: ${content_type|application/x-gzip} display_name: "drivers-tools-logs.tar.gz" - command: s3.put params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} + aws_key: ${AWS_ACCESS_KEY_ID} + aws_secret: ${AWS_SECRET_ACCESS_KEY} + aws_session_token: ${AWS_SESSION_TOKEN} optional: true local_file: ${PROJECT_DIRECTORY}/fuzz.tgz - remote_file: ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/${task_id}-${execution}-fuzz.tgz - bucket: mciuploads + remote_file: ${build_variant}/${revision}/${version_id}/${build_id}/${task_id}-${execution}-fuzz.tgz + bucket: ${aws_bucket} permissions: public-read content_type: application/x-gzip display_name: "fuzz.tgz" @@ -184,12 +188,13 @@ functions: find . -name \*.suite | xargs tar czf test_suite.tgz - command: s3.put params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} + aws_key: ${AWS_ACCESS_KEY_ID} + aws_secret: ${AWS_SECRET_ACCESS_KEY} + aws_session_token: ${AWS_SESSION_TOKEN} local_file: src/go.mongodb.org/mongo-driver/test_suite.tgz optional: true - remote_file: ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-test_suite.tgz - bucket: mciuploads + remote_file: ${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-test_suite.tgz + bucket: ${aws_bucket} permissions: public-read content_type: ${content_type|text/plain} display_name: "test_suite.tgz" @@ -276,9 +281,9 @@ functions: script: | ${PREPARE_SHELL} export OIDC="oidc" - bash ${PROJECT_DIRECTORY}/etc/run-oidc-test.sh 'make -s evg-test-oidc-auth' + task test-oidc - run-make: + run-task: - command: shell.exec type: test params: @@ -286,7 +291,7 @@ functions: working_dir: src/go.mongodb.org/mongo-driver script: | ${PREPARE_SHELL} - ${BUILD_ENV|} BUILD_TAGS=${BUILD_TAGS|-tags=cse,gssapi} make ${targets} + ${BUILD_ENV|} BUILD_TAGS=${BUILD_TAGS|-tags=cse,gssapi} task ${targets} run-tests: - command: shell.exec @@ -309,7 +314,7 @@ functions: ${PREPARE_SHELL} export BASE_SHA=${revision} export HEAD_SHA=${github_commit} - bash etc/api_report.sh + task api-report "add PR labels": - command: shell.exec @@ -391,7 +396,7 @@ functions: include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"] script: | ${PREPARE_SHELL} - bash etc/run-atlas-test.sh + task test-atlas run-ocsp-test: - command: shell.exec @@ -411,7 +416,7 @@ functions: TOPOLOGY="server" \ MONGODB_URI="${MONGODB_URI}" \ OCSP_TLS_SHOULD_SUCCEED="${OCSP_TLS_SHOULD_SUCCEED}" \ - make evg-test-ocsp + task evg-test-ocsp run-versioned-api-test: - command: shell.exec @@ -441,7 +446,7 @@ functions: BUILD_TAGS="-tags=cse" \ REQUIRE_API_VERSION="${REQUIRE_API_VERSION}" \ CRYPT_SHARED_LIB_PATH="$CRYPT_SHARED_LIB_PATH" \ - make evg-test-versioned-api \ + task evg-test-versioned-api \ PKG_CONFIG_PATH=$PKG_CONFIG_PATH \ LD_LIBRARY_PATH=$LD_LIBRARY_PATH @@ -488,7 +493,7 @@ functions: MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}" \ TOPOLOGY="${TOPOLOGY}" \ MONGO_GO_DRIVER_COMPRESSOR=${MONGO_GO_DRIVER_COMPRESSOR} \ - make evg-test-load-balancers + task evg-test-load-balancers run-serverless-tests: - command: shell.exec @@ -512,7 +517,7 @@ functions: SSL="nossl" \ TOPOLOGY="server" \ MONGODB_URI="mongodb://mhuser:pencil@localhost" \ - make evg-test-atlas-data-lake + task evg-test-atlas-data-lake run-docker-test: - command: shell.exec @@ -522,8 +527,8 @@ functions: working_dir: src/go.mongodb.org/mongo-driver script: | ${PREPARE_SHELL} - bash etc/run_docker.sh - TOPOLOGY=sharded_cluster bash etc/run_docker.sh test-short + task run-docker + TOPOLOGY=sharded_cluster task run-docker -- test-short run-valid-ocsp-server: - command: shell.exec @@ -608,7 +613,7 @@ functions: script: | ${PREPARE_SHELL} TEST_INDEX_URI="${TEST_INDEX_URI}" \ - make evg-test-search-index + task evg-test-search-index add-aws-auth-variables-to-file: - command: ec2.assume_role @@ -688,7 +693,7 @@ functions: echo "This platform does not support the ECS auth test, skipping..." exit 0 fi - make build-aws-ecs-test + task build-aws-ecs-test - command: shell.exec type: test params: @@ -773,7 +778,7 @@ functions: TOPOLOGY="${TOPOLOGY}" \ MONGO_GO_DRIVER_COMPRESSOR=${MONGO_GO_DRIVER_COMPRESSOR} \ BUILD_TAGS="-tags=cse" \ - make evg-test-kms \ + task evg-test-kms \ PKG_CONFIG_PATH=$PKG_CONFIG_PATH \ LD_LIBRARY_PATH=$LD_LIBRARY_PATH @@ -794,7 +799,7 @@ functions: TOPOLOGY="${TOPOLOGY}" \ MONGO_GO_DRIVER_COMPRESSOR=${MONGO_GO_DRIVER_COMPRESSOR} \ BUILD_TAGS="-tags=cse" \ - make evg-test-kmip \ + task evg-test-kmip \ PKG_CONFIG_PATH=$PKG_CONFIG_PATH \ LD_LIBRARY_PATH=$LD_LIBRARY_PATH @@ -820,7 +825,7 @@ tasks: - name: static-analysis tags: ["static-analysis"] commands: - - func: run-make + - func: run-task vars: targets: "check-fmt check-license check-modules lint" @@ -845,7 +850,7 @@ tasks: TOPOLOGY: "server" AUTH: "noauth" SSL: "nossl" - - func: run-make + - func: run-task vars: targets: driver-benchmark - func: send-perf-data @@ -1591,7 +1596,7 @@ tasks: - name: go1.18-build tags: ["compile-check"] commands: - - func: run-make + - func: run-task vars: targets: "build-compile-check" BUILD_ENV: "PATH=/opt/golang/go1.18/bin:$PATH GOROOT=/opt/golang/go1.18" @@ -1600,7 +1605,7 @@ tasks: - name: build tags: ["compile-check"] commands: - - func: run-make + - func: run-task vars: targets: "build" @@ -1724,7 +1729,7 @@ tasks: echo "Building build-kms-test ... begin" BUILD_TAGS="-tags=cse" \ PKG_CONFIG_PATH=$PKG_CONFIG_PATH \ - make build-kms-test + task build-kms-test echo "Building build-kms-test ... end" source $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/secrets-export.sh echo "Copying files ... begin" @@ -1760,7 +1765,7 @@ tasks: echo "Building build-kms-test ... begin" BUILD_TAGS="-tags=cse" \ PKG_CONFIG_PATH=$PKG_CONFIG_PATH \ - make build-kms-test + task build-kms-test echo "Building build-kms-test ... end" LD_LIBRARY_PATH=./install/libmongocrypt/lib64 \ MONGODB_URI='mongodb://localhost:27017/' \ @@ -1777,7 +1782,7 @@ tasks: working_dir: src/go.mongodb.org/mongo-driver script: | ${PREPARE_SHELL} - bash etc/run-awskms-test.sh + task test-awskms - name: "testawskms-fail-task" # testawskms-fail-task runs without environment variables. @@ -1791,7 +1796,7 @@ tasks: script: | ${PREPARE_SHELL} export EXPECT_ERROR='status=400' - bash etc/run-awskms-test.sh + task test-awskms - name: "testazurekms-task" commands: @@ -1805,7 +1810,7 @@ tasks: echo "Building build-kms-test ... begin" BUILD_TAGS="-tags=cse" \ PKG_CONFIG_PATH=$PKG_CONFIG_PATH \ - make build-kms-test + task build-kms-test echo "Building build-kms-test ... end" echo "Copying files ... begin" @@ -1825,7 +1830,7 @@ tasks: script: | ${PREPARE_SHELL} source $DRIVERS_TOOLS/.evergreen/csfle/azurekms/secrets-export.sh - AZUREKMS_CMD="LD_LIBRARY_PATH=./install/libmongocrypt/lib64 MONGODB_URI='mongodb://localhost:27017' PROVIDER='azure' AZUREKMS_KEY_NAME='${AZUREKMS_KEY_NAME}' AZUREKMS_KEY_VAULT_ENDPOINT='${AZUREKMS_KEY_VAULT_ENDPOINT}' ./testkms" $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh + AZUREKMS_CMD="LD_LIBRARY_PATH=./install/libmongocrypt/lib64 MONGODB_URI='mongodb://localhost:27017' PROVIDER='azure' AZUREKMS_KEY_NAME=$AZUREKMS_KEYNAME AZUREKMS_KEY_VAULT_ENDPOINT=$AZUREKMS_KEYVAULTENDPOINT ./testkms" $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh - name: "testazurekms-fail-task" # testazurekms-fail-task runs without environment variables. @@ -1841,13 +1846,14 @@ tasks: echo "Building build-kms-test ... begin" BUILD_TAGS="-tags=cse" \ PKG_CONFIG_PATH=$PKG_CONFIG_PATH \ - make build-kms-test + task build-kms-test echo "Building build-kms-test ... end" + . ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/setup-secrets.sh LD_LIBRARY_PATH=./install/libmongocrypt/lib64 \ MONGODB_URI='mongodb://localhost:27017' \ EXPECT_ERROR='unable to retrieve azure credentials' \ - PROVIDER='azure' AZUREKMS_KEY_NAME='${AZUREKMS_KEY_NAME}' AZUREKMS_KEY_VAULT_ENDPOINT='${AZUREKMS_KEY_VAULT_ENDPOINT}' \ + PROVIDER='azure' AZUREKMS_KEY_NAME=$AZUREKMS_KEYNAME AZUREKMS_KEY_VAULT_ENDPOINT=$AZUREKMS_KEYVAULTENDPOINT \ ./testkms - name: "test-fuzz" diff --git a/.evergreen/run-fuzz.sh b/.evergreen/run-fuzz.sh index 3538da7f34..bb914d9027 100755 --- a/.evergreen/run-fuzz.sh +++ b/.evergreen/run-fuzz.sh @@ -63,7 +63,9 @@ done # If the fuzz directory exists, then tar it up in preparation to upload to S3. if [ -d $PROJECT_DIRECTORY/fuzz ]; then echo "Tarring up fuzz directory" - tar -czf $PROJECT_DIRECTORY/fuzz.tgz $PROJECT_DIRECTORY/fuzz + + cd $PROJECT_DIRECTORY + tar cfz fuzz.tgz ./fuzz # Exit with code 1 to indicate that errors occurred in fuzz tests, resulting in corpus files being generated. # This will trigger a notification to be sent to the Go Driver team. diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 1430b94fa4..63d37af2a5 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -76,12 +76,12 @@ else echo "crypt_shared library will be loaded from path: $CRYPT_SHARED_LIB_PATH" fi -if [ -z ${MAKEFILE_TARGET+x} ]; then +if [ -z ${TASKFILE_TARGET+x} ]; then if [ "$(uname -s)" = "Darwin" ]; then # Run a subset of the tests on Darwin - MAKEFILE_TARGET="evg-test-load-balancers" + TASKFILE_TARGET="evg-test-load-balancers" else - MAKEFILE_TARGET="evg-test" + TASKFILE_TARGET="evg-test" fi fi @@ -99,4 +99,4 @@ CRYPT_SHARED_LIB_PATH=$CRYPT_SHARED_LIB_PATH \ PKG_CONFIG_PATH=$PKG_CONFIG_PATH \ LD_LIBRARY_PATH=$LD_LIBRARY_PATH \ MACOS_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH \ -make $MAKEFILE_TARGET +task $TASKFILE_TARGET diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index dd93c729a5..23fa9c87d2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -33,9 +33,11 @@ jobs: languages: go build-mode: manual + - name: Install Taskfile support + uses: arduino/setup-task@v2 + - shell: bash - run: | - make build + run: task build - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 diff --git a/Dockerfile b/Dockerfile index b3d62a1564..06b88f5abd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,9 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get -qqy install --option Acquire::Retries=100 --option Acquire::http::Timeout="60" --no-install-recommends golang-go && \ rm -rf /var/lib/apt/lists/* +# Install taskfile +RUN go install github.com/go-task/task/v3/cmd/task@latest + COPY ./etc/docker_entry.sh /root/docker_entry.sh COPY --from=libmongocrypt /root/install /root/install diff --git a/Makefile b/Makefile deleted file mode 100644 index 0fe4ec0afa..0000000000 --- a/Makefile +++ /dev/null @@ -1,214 +0,0 @@ -TEST_TIMEOUT = 1800 - -### Utility targets. ### -.PHONY: default -default: build check-license check-fmt check-modules lint test-short - -.PHONY: add-license -add-license: - etc/check_license.sh -a - -.PHONY: check-license -check-license: - etc/check_license.sh - -.PHONY: build -build: cross-compile build-tests build-compile-check - go build ./... - go build $(BUILD_TAGS) ./... - -# Use ^$ to match no tests so that no tests are actually run but all tests are -# compiled. Run with -short to ensure none of the TestMain functions try to -# connect to a server. -.PHONY: build-tests -build-tests: - go test -short $(BUILD_TAGS) -run ^$$ ./... - -.PHONY: build-compile-check -build-compile-check: - etc/compile_check.sh - -# Cross-compiling on Linux for architectures 386, arm, arm64, amd64, ppc64le, and s390x. -# Omit any build tags because we don't expect our build environment to support compiling the C -# libraries for other architectures. -.PHONY: cross-compile -cross-compile: - GOOS=linux GOARCH=386 go build ./... - GOOS=linux GOARCH=arm go build ./... - GOOS=linux GOARCH=arm64 go build ./... - GOOS=linux GOARCH=amd64 go build ./... - GOOS=linux GOARCH=ppc64le go build ./... - GOOS=linux GOARCH=s390x go build ./... - -.PHONY: install-lll -install-lll: - go install github.com/walle/lll/...@latest - -.PHONY: check-fmt -check-fmt: install-lll - etc/check_fmt.sh - -.PHONY: check-modules -check-modules: - etc/check_modules.sh - -.PHONY: doc -doc: - godoc -http=:6060 -index - -.PHONY: fmt -fmt: - go fmt ./... - -# NOTE: A golangci-lint version is also pinned in .pre-commit-config.yaml. Make -# sure to change it there to keep it in-sync with what's used here! -.PHONY: install-golangci-lint -install-golangci-lint: - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 - -# Lint with various GOOS and GOARCH targets to catch static analysis failures that may only affect -# specific operating systems or architectures. For example, staticcheck will only check for 64-bit -# alignment of atomically accessed variables on 32-bit architectures (see -# https://staticcheck.io/docs/checks#SA1027) -.PHONY: lint -lint: install-golangci-lint - GOOS=linux GOARCH=386 golangci-lint run --config .golangci.yml ./... - GOOS=linux GOARCH=arm golangci-lint run --config .golangci.yml ./... - GOOS=linux GOARCH=arm64 golangci-lint run --config .golangci.yml ./... - GOOS=linux GOARCH=amd64 golangci-lint run --config .golangci.yml ./... - GOOS=linux GOARCH=ppc64le golangci-lint run --config .golangci.yml ./... - GOOS=linux GOARCH=s390x golangci-lint run --config .golangci.yml ./... - -.PHONY: update-notices -update-notices: - etc/generate_notices.pl > THIRD-PARTY-NOTICES - -### Local testing targets. ### -.PHONY: test -test: - go test $(BUILD_TAGS) -timeout $(TEST_TIMEOUT)s -p 1 ./... - -.PHONY: test-cover -test-cover: - go test $(BUILD_TAGS) -timeout $(TEST_TIMEOUT)s -cover $(COVER_ARGS) -p 1 ./... - -.PHONY: test-race -test-race: - go test $(BUILD_TAGS) -timeout $(TEST_TIMEOUT)s -race -p 1 ./... - -.PHONY: test-short -test-short: - go test $(BUILD_TAGS) -timeout 60s -short ./... - -### Local FaaS targets. ### -.PHONY: build-faas-awslambda -build-faas-awslambda: - $(if $(MONGODB_URI),,$(error MONGODB_URI is not set)) - $(MAKE) -C internal/cmd/faas/awslambda - -### Evergreen specific targets. ### -.PHONY: build-aws-ecs-test -build-aws-ecs-test: - go build $(BUILD_TAGS) ./internal/cmd/testaws/main.go - -.PHONY: evg-test -evg-test: - 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 - -.PHONY: evg-test-atlas-data-lake -evg-test-atlas-data-lake: - ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./internal/integration -run TestUnifiedSpecs/atlas-data-lake-testing >> spec_test.suite - ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./internal/integration -run TestAtlasDataLake >> spec_test.suite - -.PHONY: evg-test-enterprise-auth -evg-test-enterprise-auth: - go run -tags gssapi ./internal/cmd/testentauth/main.go - -.PHONY: evg-test-oidc-auth -evg-test-oidc-auth: - go run ./internal/cmd/testoidcauth/main.go - go run -race ./internal/cmd/testoidcauth/main.go - -.PHONY: evg-test-kmip -evg-test-kmip: - 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 ./internal/integration -run TestClientSideEncryptionSpec/kmipKMS >> test.suite - 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 ./internal/integration -run TestClientSideEncryptionProse/data_key_and_double_encryption >> test.suite - 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 ./internal/integration -run TestClientSideEncryptionProse/corpus >> test.suite - 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 ./internal/integration -run TestClientSideEncryptionProse/custom_endpoint >> test.suite - 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 ./internal/integration -run TestClientSideEncryptionProse/kms_tls_options_test >> test.suite - -.PHONY: evg-test-kms -evg-test-kms: - go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./internal/integration -run TestClientSideEncryptionProse/kms_tls_tests >> test.suite - -.PHONY: evg-test-load-balancers -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 -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 - go test $(BUILD_TAGS) ./internal/integration/unified -run TestUnifiedSpec -v -timeout $(TEST_TIMEOUT)s >> test.suite - -.PHONY: evg-test-search-index -evg-test-search-index: - # Double the timeout to wait for the responses from the server. - go test ./internal/integration -run TestSearchIndexProse -v -timeout $(shell echo "$$(( $(TEST_TIMEOUT) * 2))")s >> test.suite - -.PHONY: evg-test-ocsp -evg-test-ocsp: - go test -v ./mongo -run TestOCSP $(OCSP_TLS_SHOULD_SUCCEED) >> test.suite - -.PHONY: evg-test-serverless -evg-test-serverless: - # Serverless should be tested with all unified tests as well as tests in the following components: CRUD, load balancer, - # retryable reads, retryable writes, sessions, transactions and cursor behavior. - go test $(BUILD_TAGS) ./internal/integration -run TestCrudSpec -v -timeout $(TEST_TIMEOUT)s >> test.suite - go test $(BUILD_TAGS) ./internal/integration -run TestWriteErrorsWithLabels -v -timeout $(TEST_TIMEOUT)s >> test.suite - go test $(BUILD_TAGS) ./internal/integration -run TestWriteErrorsDetails -v -timeout $(TEST_TIMEOUT)s >> test.suite - go test $(BUILD_TAGS) ./internal/integration -run TestHintErrors -v -timeout $(TEST_TIMEOUT)s >> test.suite - 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 - 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 ./internal/integration -run TestClientSideEncryptionSpec >> test.suite - 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 ./internal/integration -run TestClientSideEncryptionProse >> test.suite - -.PHONY: evg-test-versioned-api -evg-test-versioned-api: - # Versioned API related tests are in the mongo, integration and unified packages. - 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 - 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 ./internal/integration >> test.suite - 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 ./internal/integration/unified >> test.suite - -.PHONY: build-kms-test -build-kms-test: - go build $(BUILD_TAGS) ./internal/cmd/testkms - -### Benchmark specific targets and support. ### -.PHONY: benchmark -benchmark:perf - go test $(BUILD_TAGS) -benchmem -bench=. ./benchmark | test benchmark.suite - -.PHONY: driver-benchmark -driver-benchmark:perf - @go run ./internal/cmd/benchmark | tee perf.suite - -perf:driver-test-data.tar.gz - tar -zxf $< $(if $(eq $(UNAME_S),Darwin),-s , --transform=s)/testdata/perf/ - @touch $@ - -driver-test-data.tar.gz: - 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 diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000000..7f955eb6ec --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,197 @@ +# See https://taskfile.dev/usage/ +version: '3' + +env: + TEST_TIMEOUT: 1800 + LONG_TEST_TIMEOUT: 3600 + +tasks: + + ### Utility tasks. ### + default: + deps: [build, check-license, check-fmt, check-modules, lint, test-short] + + add-license: bash etc/check_license.sh -a + + check-license: bash etc/check_license.sh + + build: + deps: [cross-compile, build-tests, build-compile-check] + cmds: + - go build ./... + - go build ${BUILD_TAGS} ./... + + build-tests: go test -short ${BUILD_TAGS} -run ^$$ ./... + + build-compile-check: bash etc/compile_check.sh + + cross-compile: + - GOOS=linux GOARCH=386 go build ./... + - GOOS=linux GOARCH=arm go build ./... + - GOOS=linux GOARCH=arm64 go build ./... + - GOOS=linux GOARCH=amd64 go build ./... + - GOOS=linux GOARCH=ppc64le go build ./... + - GOOS=linux GOARCH=s390x go build ./... + + check-fmt: + deps: [install-lll] + cmds: + - bash etc/check_fmt.sh + + check-modules: bash etc/check_modules.sh + + doc: godoc -http=:6060 -index + + fmt: go fmt ./... + + api-report: bash etc/api_report.sh + + install-libmongocrypt: bash etc/install-libmongocrypt.sh + + run-docker: bash etc/run_docker.sh + + cherry-picker: bash etc/cherry-picker.sh + + # Lint with various GOOS and GOARCH tasks to catch static analysis failures that may only affect + # specific operating systems or architectures. For example, staticcheck will only check for 64-bit + # alignment of atomically accessed variables on 32-bit architectures (see + # https://staticcheck.io/docs/checks#SA1027) + lint: + deps: [install-golangci-lint] + cmds: + - GOOS=linux GOARCH=386 golangci-lint run --config .golangci.yml ./... + - GOOS=linux GOARCH=arm golangci-lint run --config .golangci.yml ./... + - GOOS=linux GOARCH=arm64 golangci-lint run --config .golangci.yml ./... + - GOOS=linux GOARCH=amd64 golangci-lint run --config .golangci.yml ./... + - GOOS=linux GOARCH=ppc64le golangci-lint run --config .golangci.yml ./... + - GOOS=linux GOARCH=s390x golangci-lint run --config .golangci.yml ./... + + update-notices: bash etc/generate_notices.pl > THIRD-PARTY-NOTICES + + ### Local testing tasks. ### + test: go test ${BUILD_TAGS} -timeout {{.TEST_TIMEOUT}}s -p 1 ./... + + test-cover: + - go test ${BUILD_TAGS} -timeout {{.TEST_TIMEOUT}}s -cover ${COVER_ARGS} -p 1 ./... + + test-race: + - go test ${BUILD_TAGS} -timeout {{.TEST_TIMEOUT}}s -race -p 1 ./... + + test-short: go test ${BUILD_TAGS} -timeout 60s -short ./... + + test-oidc: bash etc/run-oidc-test.sh 'task --silent evg-test-oidc-auth' + + test-atlas: bash etc/run-atlas-test.sh + + test-awskms: bash etc/run-awskms-test.sh + + ### Local FaaS tasks. ### + build-faas-awslambda: + requires: + vars: [MONGODB_URI] + cmds: + - make -c internal/cmd/faas/awslambda + + ### Evergreen specific tasks. ### + build-aws-ecs-test: go build ${BUILD_TAGS} ./internal/cmd/testaws/main.go + + evg-test: + - 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 + + evg-test-atlas-data-lake: + - ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./internal/integration -run TestUnifiedSpecs/atlas-data-lake-testing >> spec_test.suite + - ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./internal/integration -run TestAtlasDataLake >> spec_test.suite + + evg-test-enterprise-auth: go run -tags gssapi ./internal/cmd/testentauth/main.go + + evg-test-oidc-auth: + - go run ./internal/cmd/testoidcauth/main.go + - go run -race ./internal/cmd/testoidcauth/main.go + + evg-test-kmip: + - 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 ./internal/integration -run TestClientSideEncryptionSpec/kmipKMS >> test.suite + - 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 ./internal/integration -run TestClientSideEncryptionProse/data_key_and_double_encryption >> test.suite + - 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 ./internal/integration -run TestClientSideEncryptionProse/corpus >> test.suite + - 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 ./internal/integration -run TestClientSideEncryptionProse/custom_endpoint >> test.suite + - 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 ./internal/integration -run TestClientSideEncryptionProse/kms_tls_options_test >> test.suite + + evg-test-kms: + - go test -exec "env PKG_CONFIG_PATH=${PKG_CONFIG_PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" ${BUILD_TAGS} -v -timeout {{.TEST_TIMEOUT}}s ./internal/integration -run TestClientSideEncryptionProse/kms_tls_tests >> test.suite + + 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 -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 + - go test ${BUILD_TAGS} ./internal/integration/unified -run TestUnifiedSpec -v -timeout {{.TEST_TIMEOUT}}s >> test.suite + + evg-test-search-index: + # Use the long timeout to wait for the responses from the server. + - go test ./internal/integration -run TestSearchIndexProse -v -timeout {{.LONG_TEST_TIMEOUT}}s >> test.suite + + evg-test-ocsp: + - go test -v ./mongo -run TestOCSP ${OCSP_TLS_SHOULD_SUCCEED} >> test.suite + + evg-test-serverless: + # Serverless should be tested with all unified tests as well as tests in the following components: CRUD, load balancer, + # retryable reads, retryable writes, sessions, transactions and cursor behavior. + - go test ${BUILD_TAGS} ./internal/integration -run TestCrudSpec -v -timeout {{.TEST_TIMEOUT}}s >> test.suite + - go test ${BUILD_TAGS} ./internal/integration -run TestWriteErrorsWithLabels -v -timeout {{.TEST_TIMEOUT}}s >> test.suite + - go test ${BUILD_TAGS} ./internal/integration -run TestWriteErrorsDetails -v -timeout {{.TEST_TIMEOUT}}s >> test.suite + - go test ${BUILD_TAGS} ./internal/integration -run TestHintErrors -v -timeout {{.TEST_TIMEOUT}}s >> test.suite + - 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 + - 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 ./internal/integration -run TestClientSideEncryptionSpec >> test.suite + - 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 ./internal/integration -run TestClientSideEncryptionProse >> test.suite + + evg-test-versioned-api: + # Versioned API related tests are in the mongo, integration and unified packages. + - 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 + - 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 ./internal/integration >> test.suite + - 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 ./internal/integration/unified >> test.suite + + build-kms-test: go build ${BUILD_TAGS} ./internal/cmd/testkms + + ### Benchmark specific tasks and support. ### + benchmark: + deps: [perf-files] + cmds: + - go test ${BUILD_TAGS} -benchmem -bench=. ./benchmark | test benchmark.suite + + driver-benchmark: + deps: [perf-files] + cmds: + - go run ./internal/cmd/benchmark | tee perf.suite + + ### Internal tasks. ### + perf-files: + internal: true + cmds: + - bash etc/prep-perf.sh + + install-lll: + internal: true + cmds: + - go install github.com/walle/lll/...@latest + + # NOTE: A golangci-lint version is also pinned in .pre-commit-config.yaml. Make + # sure to change it there to keep it in-sync with what's used here! + install-golangci-lint: + internal: true + cmds: + - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 \ No newline at end of file diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 900fc32fdb..fcca800429 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -6,7 +6,7 @@ We are building this software together and strongly encourage contributions from ## Requirements -Go 1.22 or higher is required to run the driver test suite. +Go 1.22 or higher is required to run the driver test suite. We use [task](https://taskfile.dev/) as our task runner. ## Bug Fixes and New Features @@ -17,12 +17,12 @@ 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.18 and requires Go 1.22 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.22 for development. Please run the following `Taskfile` 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` -- `make test-race` +- `task fmt` +- `task lint` +- `task test` +- `task test-race` **Running the tests requires that you have a `mongod` server running on localhost, listening on the default port (27017). At minimum, please test against the latest release version of the MongoDB server.** @@ -75,13 +75,13 @@ git config --global github.user If a Pull Request needs to be cherry-picked to a new branch, get the sha of the commit in the base branch, and then run ```bash -bash etc/cherry-picker.sh +task cherry-picker -- ``` By default it will use `master` as the target branch. The branch can be specified as the second argument, e.g. ```bash -bash etc/cherry-picker.sh branch +task cherry-picker -- branch ``` It will create a new checkout in a temp dir, create a new branch, perform the cherry-pick, and then @@ -89,9 +89,9 @@ prompt before creating a PR to the target branch. ## Testing / Development -The driver tests can be run against several database configurations. The most simple configuration is a standalone mongod with no auth, no ssl, and no compression. To run these basic driver tests, make sure a standalone MongoDB server instance is running at localhost:27017. To run the tests, you can run `make` (on Windows, run `nmake`). This will run coverage, run go-lint, run go-vet, and build the examples. +The driver tests can be run against several database configurations. The most simple configuration is a standalone mongod with no auth, no ssl, and no compression. To run these basic driver tests, make sure a standalone MongoDB server instance is running at localhost:27017. To run the tests, you can run `task`. This will run coverage, run go-lint, run go-vet, and build the examples. -You can install `libmongocrypt` locally by running `bash etc/build-libmongocrypt.sh`, which will create an `install` directory +You can install `libmongocrypt` locally by running `task install-libmongocrypt`, which will create an `install` directory in the repository top level directory. On Windows you will also need to add `c:/libmongocrypt/` to your `PATH`. ### Testing Different Topologies @@ -164,10 +164,10 @@ The following are the requirements for running the AWS Lambda tests locally: 1. [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) 1. [Docker](https://www.docker.com/products/docker-desktop/) -Local testing requires exporting the `MONGODB_URI` environment variables. To build the AWS Lambda image and invoke the `MongoDBFunction` lambda function use the `build-faas-awslambda` make target: +Local testing requires exporting the `MONGODB_URI` environment variables. To build the AWS Lambda image and invoke the `MongoDBFunction` lambda function use the `build-faas-awslambda` Taskfile target: ```bash -MONGODB_URI="mongodb://host.docker.internal:27017" make build-faas-awslambda +MONGODB_URI="mongodb://host.docker.internal:27017" task build-faas-awslambda ``` The usage of host.docker.internal comes from the [Docker networking documentation](https://docs.docker.com/desktop/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host). @@ -183,7 +183,7 @@ However, some of the tests require secrets handling. Please see the team [Wiki] The test suite can be run with or without the secrets as follows: ```bash -MAKEFILE_TARGET=evg-test-versioned-api bash .evergreen/run-tests.sh +TASKFILE_TARGET=evg-test-versioned-api bash .evergreen/run-tests.sh ``` ### Load Balancer @@ -207,7 +207,7 @@ MONGODB_URI='mongodb://localhost:27017,localhost:27018/' $PWD/drivers-evergreen- - Run the load balancer tests (or use the docker runner below with `evg-test-load-balancers`): ```bash -make evg-test-load-balancers +task evg-test-load-balancers ``` ### Testing in Docker @@ -227,18 +227,18 @@ See the readme in `$DRIVERS_TOOLS/.evergreen/docker` for more information on usa 1. Finally, run the Go Driver tests using the following script in this repo: ```bash -bash etc/run_docker.sh +make run-docker ``` -The script takes an optional argument for the `MAKEFILE_TARGET` and allows for some environment variable overrides. +The script takes an optional argument for the `TASKFILE_TARGET` and allows for some environment variable overrides. The docker container has the required binaries, including libmongocrypt. -The entry script executes the desired `MAKEFILE_TARGET`. +The entry script executes the desired `TASKFILE_TARGET`. For example, to test against a sharded cluster (make sure you started the server with a sharded_cluster), using enterprise auth, run: ```bash -TOPOLOGY=sharded_cluster bash etc/run_docker.sh evg-test-enterprise-auth +TOPOLOGY=sharded_cluster task run-docker -- evg-test-enterprise-auth ``` ## Talk To Us diff --git a/etc/check_license.sh b/etc/check_license.sh index 7648797621..36a32bf342 100755 --- a/etc/check_license.sh +++ b/etc/check_license.sh @@ -34,7 +34,7 @@ add_copyright() { return fi - echo "Missing copyright notice in \"$file\". Run \"make add-license\" to add missing licenses." + echo "Missing copyright notice in \"$file\". Run \"task add-license\" to add missing licenses." exit 1 } diff --git a/etc/docker_entry.sh b/etc/docker_entry.sh index 4e3e325970..654ab98a47 100755 --- a/etc/docker_entry.sh +++ b/etc/docker_entry.sh @@ -9,7 +9,7 @@ cd /src rm -f test.suite cp -r $HOME/install ./install -export PATH="$MONGODB_BINARIES:$PATH" +export PATH="$MONGODB_BINARIES:$HOME/go/bin:$PATH" # Run the test. bash ./.evergreen/run-tests.sh diff --git a/etc/prep-perf.sh b/etc/prep-perf.sh new file mode 100755 index 0000000000..9d645e9cde --- /dev/null +++ b/etc/prep-perf.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Prepares perf data. +set -eux + +if [ -d /testdata/perf/ ]; then + echo "/testdata/perf/ already exists, skipping download" + exit 0 +fi + +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 + +if [ $(uname -s) == "Darwin" ]; then + tar -zxf driver-test-data.tar.gz -s /testdata/perf/ +else + tar -zxf driver-test-data.tar.gz --transform=s/testdata/perf/ +fi diff --git a/etc/run-awskms-test.sh b/etc/run-awskms-test.sh index d3caef01c7..d04040fcb6 100755 --- a/etc/run-awskms-test.sh +++ b/etc/run-awskms-test.sh @@ -5,7 +5,7 @@ echo "Building build-kms-test ... begin" BUILD_TAGS="-tags=cse" \ PKG_CONFIG_PATH=$PKG_CONFIG_PATH \ - make build-kms-test + task build-kms-test echo "Building build-kms-test ... end" . ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/atlas_connect diff --git a/etc/run-enterprise-gssapi-test.sh b/etc/run-enterprise-gssapi-test.sh index d9bf57c7be..541c3a54f8 100755 --- a/etc/run-enterprise-gssapi-test.sh +++ b/etc/run-enterprise-gssapi-test.sh @@ -16,4 +16,4 @@ else fi export MONGO_GO_DRIVER_COMPRESSOR="${MONGO_GO_DRIVER_COMPRESSOR:-}" -make -s evg-test-enterprise-auth +task --silent evg-test-enterprise-auth diff --git a/etc/run-enterprise-plain-test.sh b/etc/run-enterprise-plain-test.sh index b508a8584d..f3b31f07c7 100755 --- a/etc/run-enterprise-plain-test.sh +++ b/etc/run-enterprise-plain-test.sh @@ -5,4 +5,4 @@ set -eu . ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/enterprise_auth export MONGODB_URI="mongodb://${SASL_USER}:${SASL_PASS}@${SASL_HOST}:${SASL_PORT}/ldap?authMechanism=PLAIN" export MONGO_GO_DRIVER_COMPRESSOR="${MONGO_GO_DRIVER_COMPRESSOR:-}" -make -s evg-test-enterprise-auth +task --silent evg-test-enterprise-auth diff --git a/etc/run-serverless-test.sh b/etc/run-serverless-test.sh index 9d858a0610..25d3eaac1f 100755 --- a/etc/run-serverless-test.sh +++ b/etc/run-serverless-test.sh @@ -6,5 +6,5 @@ AUTH="auth" \ SSL="ssl" \ MONGODB_URI="${SERVERLESS_URI}" \ SERVERLESS="serverless" \ - MAKEFILE_TARGET=evg-test-serverless \ + TASKFILE_TARGET=evg-test-serverless \ sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh diff --git a/etc/run_docker.sh b/etc/run_docker.sh index b6d0fc9ae5..175fe1239d 100755 --- a/etc/run_docker.sh +++ b/etc/run_docker.sh @@ -10,11 +10,11 @@ fi PLATFORM=${DOCKER_PLATFORM:-} docker build $PLATFORM -t go-test . -# Handle environment variables and optional positional arg for the makefile target. -MAKEFILE_TARGET=${1:-evg-test-versioned-api} +# Handle environment variables and optional positional arg for the taskfile target. +TASKFILE_TARGET=${1:-evg-test-versioned-api} GO_BUILD_TAGS=${GO_BUILD_TAGS:-""} -ARGS=" -e MAKEFILE_TARGET=$MAKEFILE_TARGET" +ARGS=" -e TASKFILE_TARGET=$TASKFILE_TARGET" ARGS="$ARGS -e GO_BUILD_TAGS=$GO_BUILD_TAGS" ARGS="$ARGS go-test"