diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 3a8bfb061d..490cf91311 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -166,7 +166,7 @@ functions: . ${DRIVERS_TOOLS}/.evergreen/venv-utils.sh . ${DRIVERS_TOOLS}/.evergreen/find-python3.sh - export PYTHON3_BINARY="$(find_python3)" + export PYTHON3_BINARY="$(find_python3 2>/dev/null)" venvcreate "$PYTHON3_BINARY" venv echo "PYTHON3_BINARY: $PYTHON3_BINARY" >>expansion.yml @@ -175,7 +175,11 @@ functions: params: file: src/go.mongodb.org/mongo-driver/expansion.yml - upload-mo-artifacts: + handle-test-artifacts: + - command: gotest.parse_files + params: + files: + - "src/go.mongodb.org/mongo-driver/*.suite" - command: shell.exec params: shell: "bash" @@ -196,12 +200,31 @@ functions: params: aws_key: ${aws_key} aws_secret: ${aws_secret} + 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 permissions: public-read content_type: application/x-gzip display_name: "fuzz.tgz" + - command: shell.exec + params: + shell: "bash" + working_dir: src/go.mongodb.org/mongo-driver + script: | + ${PREPARE_SHELL} + find . -name \*.suite | xargs tar czf test_suite.tgz + - command: s3.put + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + 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 + permissions: public-read + content_type: ${content_type|text/plain} + display_name: "test_suite.tgz" bootstrap-mongohoused: - command: shell.exec @@ -263,15 +286,26 @@ functions: params: shell: "bash" script: | - ${PREPARE_SHELL} - cd "$MONGO_ORCHESTRATION_HOME" - # source the mongo-orchestration virtualenv if it exists - if [ -f venv/bin/activate ]; then - . venv/bin/activate - elif [ -f venv/Scripts/activate ]; then - . venv/Scripts/activate + # Ensure the instance profile is reassigned for aws tests. + cd "${DRIVERS_TOOLS}/.evergreen/auth_aws" + if [ -f "./aws_e2e_setup.json" ]; then + . ./activate-authawsvenv.sh + python ./lib/aws_assign_instance_profile.py fi - mongo-orchestration stop + - command: shell.exec + params: + shell: "bash" + script: | + # Attempt to shut down a running load balancer. Ignore any errors that happen if the load + # balancer is not running. + DRIVERS_TOOLS=${DRIVERS_TOOLS} MONGODB_URI=${MONGODB_URI} bash ${DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh stop || echo "Ignoring load balancer stop error" + - command: shell.exec + params: + shell: "bash" + script: | + ${PREPARE_SHELL} + # Stop orchestration and remove drivers tools. + bash ${DRIVERS_TOOLS}/.evergreen/stop-orchestration.sh cd - rm -rf $DRIVERS_TOOLS || true @@ -703,26 +737,6 @@ functions: TEST_INDEX_URI="${TEST_INDEX_URI}" \ make evg-test-search-index - stop-load-balancer: - - command: shell.exec - params: - shell: "bash" - script: | - # Attempt to shut down a running load balancer. Ignore any errors that happen if the load - # balancer is not running. - DRIVERS_TOOLS=${DRIVERS_TOOLS} MONGODB_URI=${MONGODB_URI} bash ${DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh stop || echo "Ignoring load balancer stop error" - - teardown-aws: - - command: shell.exec - params: - shell: "bash" - script: | - cd "${DRIVERS_TOOLS}/.evergreen/auth_aws" - if [ -f "./aws_e2e_setup.json" ]; then - . ./activate-authawsvenv.sh - python ./lib/aws_assign_instance_profile.py - fi - add-aws-auth-variables-to-file: - command: ec2.assume_role params: @@ -903,17 +917,11 @@ functions: background: true script: | cd ${DRIVERS_TOOLS}/.evergreen/csfle - if [ "Windows_NT" = "$OS" ]; then - kmstlsvenv/Scripts/python.exe -u kms_kmip_server.py \ - --port 5698 \ - --ca_file "${PROJECT_DIRECTORY}/testdata/kmip-certs/ca-ec.pem" \ - --cert_file "${PROJECT_DIRECTORY}/testdata/kmip-certs/server-ec.pem" - else - ./kmstlsvenv/bin/python3 -u kms_kmip_server.py \ + . ./activate-kmstlsvenv.sh + python -u kms_kmip_server.py \ --port 5698 \ --ca_file "${PROJECT_DIRECTORY}/testdata/kmip-certs/ca-ec.pem" \ --cert_file "${PROJECT_DIRECTORY}/testdata/kmip-certs/server-ec.pem" - fi - command: shell.exec params: @@ -921,11 +929,8 @@ functions: background: true script: | cd ${DRIVERS_TOOLS}/.evergreen/csfle - if [ "Windows_NT" = "$OS" ]; then - kmstlsvenv/Scripts/python.exe bottle.py fake_azure:imds - else - ./kmstlsvenv/bin/python3 bottle.py fake_azure:imds - fi + . ./activate-kmstlsvenv.sh + python bottle.py fake_azure:imds - command: shell.exec params: @@ -1022,16 +1027,9 @@ pre: - func: windows-fix - func: fix-absolute-paths - func: make-files-executable - - func: start-cse-servers post: - - command: gotest.parse_files - params: - files: - - "src/go.mongodb.org/mongo-driver/*.suite" - - func: upload-mo-artifacts - - func: stop-load-balancer - - func: teardown-aws + - func: handle-test-artifacts - func: cleanup tasks: @@ -1065,6 +1063,7 @@ tasks: TOPOLOGY: "server" AUTH: "noauth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "server" @@ -1079,6 +1078,7 @@ tasks: TOPOLOGY: "server" AUTH: "noauth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "server" @@ -1094,6 +1094,7 @@ tasks: TOPOLOGY: "server" AUTH: "noauth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "server" @@ -1109,6 +1110,7 @@ tasks: TOPOLOGY: "server" AUTH: "noauth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "server" @@ -1124,6 +1126,7 @@ tasks: TOPOLOGY: "server" AUTH: "auth" SSL: "ssl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "server" @@ -1138,6 +1141,7 @@ tasks: TOPOLOGY: "server" AUTH: "auth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "server" @@ -1152,6 +1156,7 @@ tasks: TOPOLOGY: "server" AUTH: "auth" SSL: "ssl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "server" @@ -1167,6 +1172,7 @@ tasks: TOPOLOGY: "server" AUTH: "auth" SSL: "ssl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "server" @@ -1182,6 +1188,7 @@ tasks: TOPOLOGY: "server" AUTH: "auth" SSL: "ssl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "server" @@ -1561,6 +1568,7 @@ tasks: TOPOLOGY: "replica_set" AUTH: "noauth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "replica_set" @@ -1576,6 +1584,7 @@ tasks: TOPOLOGY: "replica_set" AUTH: "noauth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "replica_set" @@ -1590,6 +1599,7 @@ tasks: TOPOLOGY: "replica_set" AUTH: "auth" SSL: "ssl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "replica_set" @@ -1604,6 +1614,7 @@ tasks: TOPOLOGY: "replica_set" AUTH: "auth" SSL: "ssl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "replica_set" @@ -1621,6 +1632,7 @@ tasks: TOPOLOGY: "replica_set" AUTH: "auth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "replica_set" @@ -1635,6 +1647,7 @@ tasks: TOPOLOGY: "sharded_cluster" AUTH: "noauth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "sharded_cluster" @@ -1649,6 +1662,7 @@ tasks: TOPOLOGY: "sharded_cluster" AUTH: "noauth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "sharded_cluster" @@ -1664,6 +1678,7 @@ tasks: TOPOLOGY: "sharded_cluster" AUTH: "noauth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "sharded_cluster" @@ -1679,6 +1694,7 @@ tasks: TOPOLOGY: "sharded_cluster" AUTH: "noauth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "sharded_cluster" @@ -1694,6 +1710,7 @@ tasks: TOPOLOGY: "sharded_cluster" AUTH: "auth" SSL: "ssl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "sharded_cluster" @@ -1708,6 +1725,7 @@ tasks: TOPOLOGY: "sharded_cluster" AUTH: "auth" SSL: "ssl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "sharded_cluster" @@ -1723,6 +1741,7 @@ tasks: TOPOLOGY: "sharded_cluster" AUTH: "auth" SSL: "ssl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "sharded_cluster" @@ -1738,6 +1757,7 @@ tasks: TOPOLOGY: "sharded_cluster" AUTH: "auth" SSL: "ssl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "sharded_cluster" @@ -1753,6 +1773,7 @@ tasks: TOPOLOGY: "sharded_cluster" AUTH: "auth" SSL: "nossl" + - func: start-cse-servers - func: run-tests vars: TOPOLOGY: "sharded_cluster" @@ -1826,6 +1847,7 @@ tasks: AUTH: "auth" SSL: "nossl" REQUIRE_API_VERSION: true + - func: start-cse-servers - func: run-versioned-api-test vars: TOPOLOGY: "server" @@ -1842,6 +1864,7 @@ tasks: AUTH: "noauth" SSL: "nossl" ORCHESTRATION_FILE: "versioned-api-testing.json" + - func: start-cse-servers - func: run-versioned-api-test vars: TOPOLOGY: "server" @@ -1915,6 +1938,7 @@ tasks: - name: "test-serverless" tags: ["serverless"] commands: + - func: start-cse-servers - func: "run-serverless-tests" vars: MONGO_GO_DRIVER_COMPRESSOR: "snappy" @@ -2351,20 +2375,8 @@ task_groups: SERVERLESS_API_PRIVATE_KEY=${SERVERLESS_API_PRIVATE_KEY} \ SERVERLESS_INSTANCE_NAME=${SERVERLESS_INSTANCE_NAME} \ bash ${DRIVERS_TOOLS}/.evergreen/serverless/delete-instance.sh - - command: gotest.parse_files - params: - files: - - "src/go.mongodb.org/mongo-driver/*.suite" - - command: s3.put - params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} - local_file: mongodb-logs.tar.gz - remote_file: ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-mongodb-logs.tar.gz - bucket: mciuploads - permissions: public-read - content_type: ${content_type|application/x-gzip} - display_name: "mongodb-logs.tar.gz" + - func: handle-test-artifacts + - func: cleanup tasks: - ".serverless" @@ -2401,8 +2413,11 @@ task_groups: export GCPKMS_ZONE=${GCPKMS_ZONE} export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/delete-instance.sh + - func: handle-test-artifacts + - func: cleanup tasks: - testgcpkms-task + - name: testazurekms_task_group setup_group_can_fail_task: true teardown_group_can_fail_task: true @@ -2439,6 +2454,8 @@ task_groups: export AZUREKMS_SCOPE=${AZUREKMS_SCOPE} export AZUREKMS_RESOURCEGROUP=${AZUREKMS_RESOURCEGROUP} $DRIVERS_TOOLS/.evergreen/csfle/azurekms/delete-vm.sh + - func: handle-test-artifacts + - func: cleanup tasks: - testazurekms-task @@ -2470,6 +2487,8 @@ task_groups: AWS_REGION: us-east-1 args: - ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh + - func: handle-test-artifacts + - func: cleanup setup_group_can_fail_task: true setup_group_timeout_secs: 1800 tasks: @@ -2508,6 +2527,8 @@ task_groups: add_expansions_to_env: true args: - ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh + - func: handle-test-artifacts + - func: cleanup setup_group_can_fail_task: true setup_group_timeout_secs: 1800 tasks: diff --git a/.evergreen/run-mongodb-aws-test.sh b/.evergreen/run-mongodb-aws-test.sh index 3b213b249c..9d5c71376d 100644 --- a/.evergreen/run-mongodb-aws-test.sh +++ b/.evergreen/run-mongodb-aws-test.sh @@ -21,4 +21,4 @@ set -x # For Go 1.16+, Go builds requires a go.mod file in the current working directory or a parent # directory. Spawn a new subshell, "cd" to the project directory, then run "go run". -(cd ${PROJECT_DIRECTORY} && go run "./cmd/testaws/main.go") +(cd ${PROJECT_DIRECTORY} && go run "./cmd/testaws/main.go" | tee test.suite) diff --git a/Makefile b/Makefile index e0eb9c9fad..a6c46959ad 100644 --- a/Makefile +++ b/Makefile @@ -201,7 +201,7 @@ build-kms-test: ### Benchmark specific targets and support. ### .PHONY: benchmark benchmark:perf - go test $(BUILD_TAGS) -benchmem -bench=. ./benchmark + go test $(BUILD_TAGS) -benchmem -bench=. ./benchmark | test benchmark.suite .PHONY: driver-benchmark driver-benchmark:perf diff --git a/etc/run-atlas-test.sh b/etc/run-atlas-test.sh index aa89b2dd4b..9a1839993f 100644 --- a/etc/run-atlas-test.sh +++ b/etc/run-atlas-test.sh @@ -8,4 +8,4 @@ set +x . etc/get_aws_secrets.sh drivers/atlas_connect echo "Running cmd/testatlas/main.go" -go run ./cmd/testatlas/main.go "$ATLAS_REPL" "$ATLAS_SHRD" "$ATLAS_FREE" "$ATLAS_TLS11" "$ATLAS_TLS12" "$ATLAS_SERVERLESS" "$ATLAS_SRV_REPL" "$ATLAS_SRV_SHRD" "$ATLAS_SRV_FREE" "$ATLAS_SRV_TLS11" "$ATLAS_SRV_TLS12" "$ATLAS_SRV_SERVERLESS" +go run ./cmd/testatlas/main.go "$ATLAS_REPL" "$ATLAS_SHRD" "$ATLAS_FREE" "$ATLAS_TLS11" "$ATLAS_TLS12" "$ATLAS_SERVERLESS" "$ATLAS_SRV_REPL" "$ATLAS_SRV_SHRD" "$ATLAS_SRV_FREE" "$ATLAS_SRV_TLS11" "$ATLAS_SRV_TLS12" "$ATLAS_SRV_SERVERLESS" | tee test.suite