Skip to content

test(NODE-4648): pull prepare shell out to script and fix reporter error handling #3418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 28 additions & 69 deletions .evergreen/config.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,81 +28,44 @@ functions:
params:
directory: "src"
shallow_clone: true # speed things up by limiting clone depth to 100

# Make an evergreen expansion file with dynamic values
- command: shell.exec
- command: subprocess.exec
params:
working_dir: "src"
script: |
# Get the current unique version of this checkout
if [ "${is_patch}" = "true" ]; then
CURRENT_VERSION=$(git describe)-patch-${version_id}
else
CURRENT_VERSION=latest
fi

export DRIVERS_TOOLS="$(pwd)/../drivers-tools"

export PROJECT_DIRECTORY="$(pwd)"
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
export UPLOAD_BUCKET="${project}"

# fix paths on windows
if [ "Windows_NT" = "$OS" ]; then
export DRIVERS_TOOLS=$(cygpath -m -a $DRIVERS_TOOLS)
export MONGO_ORCHESTRATION_HOME=$(cygpath -m -a $MONGO_ORCHESTRATION_HOME)
export MONGODB_BINARIES=$(cygpath -m -a $MONGODB_BINARIES)
export PROJECT_DIRECTORY=$(cygpath -m -a $PROJECT_DIRECTORY)
fi

cat <<EOT > expansion.yml
CURRENT_VERSION: "$CURRENT_VERSION"
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
set -o xtrace
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
export MONGODB_BINARIES="$MONGODB_BINARIES"
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"

export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
export PATH="$MONGODB_BINARIES:$PATH"
export PROJECT="${project}"
EOT
# See what we've done
cat expansion.yml
binary: bash
env:
is_patch: ${is_patch}
project: ${project}
args:
- .evergreen/prepare-shell.sh

# Load the expansion file to make an evergreen variable with the current unique version
- command: expansions.update
params:
file: src/expansion.yml

"prepare resources":
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
git clone --depth 1 https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config

"bootstrap mongo-orchestration":
- command: shell.exec
- command: subprocess.exec
params:
script: |
${PREPARE_SHELL}
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
AUTH=${AUTH} SSL=${SSL} \
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
LOAD_BALANCER=${LOAD_BALANCER} \
COMPRESSOR=${COMPRESSOR} \
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
binary: bash
add_expansions_to_env: true
env:
# The following is the settings for how we want to launch mongodb
MONGODB_VERSION: ${VERSION}
TOPOLOGY: ${TOPOLOGY}
AUTH: ${AUTH}
SSL: ${SSL}
ORCHESTRATION_FILE: ${ORCHESTRATION_FILE}
REQUIRE_API_VERSION: ${REQUIRE_API_VERSION}
LOAD_BALANCER: ${LOAD_BALANCER}
COMPRESSOR: ${COMPRESSOR}
# These are paths necessary for launching mongodb
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
MONGODB_BINARIES: ${MONGODB_BINARIES}
args:
- src/.evergreen/run-orchestration.sh

# run-orchestration generates expansion file with the MONGODB_URI for the cluster
- command: expansions.update
params:
Expand Down Expand Up @@ -175,7 +138,7 @@ functions:
MONGODB_URI="${MONGODB_URI}" \
AUTH=${AUTH} SSL=${SSL} TEST_CSFLE=true \
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} NO_EXIT=${NO_EXIT|1} \
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh

"run serverless tests":
Expand Down Expand Up @@ -244,7 +207,6 @@ functions:
MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}" \
TOPOLOGY="${TOPOLOGY}" \
SKIP_DEPS=${SKIP_DEPS|1} \
NO_EXIT=${NO_EXIT|1} \
LOAD_BALANCER="${LOAD_BALANCER}" \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh

Expand All @@ -265,7 +227,6 @@ functions:
TOPOLOGY="${TOPOLOGY}" \
COMPRESSOR="${COMPRESSOR}" \
SKIP_DEPS=${SKIP_DEPS|1} \
NO_EXIT=${NO_EXIT|1} \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh

"run lint checks":
Expand Down Expand Up @@ -959,7 +920,6 @@ task_groups:
setup_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: "fetch source"
- func: "prepare resources"
- command: shell.exec
params:
shell: "bash"
Expand Down Expand Up @@ -991,7 +951,6 @@ task_groups:

pre:
- func: "fetch source"
- func: "prepare resources"
- func: "windows fix"
- func: "fix absolute paths"
- func: "make files executable"
Expand Down
99 changes: 24 additions & 75 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,79 +13,36 @@ functions:
params:
directory: src
shallow_clone: true
- command: shell.exec
- command: subprocess.exec
params:
working_dir: src
script: |
# Get the current unique version of this checkout
if [ "${is_patch}" = "true" ]; then
CURRENT_VERSION=$(git describe)-patch-${version_id}
else
CURRENT_VERSION=latest
fi

export DRIVERS_TOOLS="$(pwd)/../drivers-tools"

export PROJECT_DIRECTORY="$(pwd)"
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
export UPLOAD_BUCKET="${project}"

# fix paths on windows
if [ "Windows_NT" = "$OS" ]; then
export DRIVERS_TOOLS=$(cygpath -m -a $DRIVERS_TOOLS)
export MONGO_ORCHESTRATION_HOME=$(cygpath -m -a $MONGO_ORCHESTRATION_HOME)
export MONGODB_BINARIES=$(cygpath -m -a $MONGODB_BINARIES)
export PROJECT_DIRECTORY=$(cygpath -m -a $PROJECT_DIRECTORY)
fi

cat <<EOT > expansion.yml
CURRENT_VERSION: "$CURRENT_VERSION"
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
set -o xtrace
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
export MONGODB_BINARIES="$MONGODB_BINARIES"
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"

export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
export PATH="$MONGODB_BINARIES:$PATH"
export PROJECT="${project}"
EOT
# See what we've done
cat expansion.yml
binary: bash
env:
is_patch: ${is_patch}
project: ${project}
args:
- .evergreen/prepare-shell.sh
- command: expansions.update
params:
file: src/expansion.yml
prepare resources:
- command: shell.exec
params:
script: >
${PREPARE_SHELL}

git clone --depth 1 https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS

echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" >
$MONGO_ORCHESTRATION_HOME/orchestration.config
bootstrap mongo-orchestration:
- command: shell.exec
- command: subprocess.exec
params:
script: |
${PREPARE_SHELL}
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
AUTH=${AUTH} SSL=${SSL} \
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
LOAD_BALANCER=${LOAD_BALANCER} \
COMPRESSOR=${COMPRESSOR} \
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
binary: bash
add_expansions_to_env: true
env:
MONGODB_VERSION: ${VERSION}
TOPOLOGY: ${TOPOLOGY}
AUTH: ${AUTH}
SSL: ${SSL}
ORCHESTRATION_FILE: ${ORCHESTRATION_FILE}
REQUIRE_API_VERSION: ${REQUIRE_API_VERSION}
LOAD_BALANCER: ${LOAD_BALANCER}
COMPRESSOR: ${COMPRESSOR}
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
MONGODB_BINARIES: ${MONGODB_BINARIES}
args:
- src/.evergreen/run-orchestration.sh
- command: expansions.update
params:
file: mo-expansion.yml
Expand Down Expand Up @@ -155,7 +112,7 @@ functions:
MONGODB_URI="${MONGODB_URI}" \
AUTH=${AUTH} SSL=${SSL} TEST_CSFLE=true \
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} NO_EXIT=${NO_EXIT|1} \
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
run serverless tests:
- command: timeout.update
Expand Down Expand Up @@ -220,7 +177,6 @@ functions:
MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}" \
TOPOLOGY="${TOPOLOGY}" \
SKIP_DEPS=${SKIP_DEPS|1} \
NO_EXIT=${NO_EXIT|1} \
LOAD_BALANCER="${LOAD_BALANCER}" \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
run-compression-tests:
Expand All @@ -240,7 +196,6 @@ functions:
TOPOLOGY="${TOPOLOGY}" \
COMPRESSOR="${COMPRESSOR}" \
SKIP_DEPS=${SKIP_DEPS|1} \
NO_EXIT=${NO_EXIT|1} \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
run lint checks:
- command: subprocess.exec
Expand Down Expand Up @@ -1230,10 +1185,6 @@ tasks:
REQUIRE_API_VERSION: '1'
AUTH: auth
- func: bootstrap kms servers
- func: run tests
vars:
MONGODB_API_VERSION: '1'
NO_EXIT: ''
- name: test-atlas-connectivity
tags:
- atlas-connect
Expand Down Expand Up @@ -2253,7 +2204,6 @@ task_groups:
setup_group_timeout_secs: 1800
setup_group:
- func: fetch source
- func: prepare resources
- command: shell.exec
params:
shell: bash
Expand Down Expand Up @@ -2284,7 +2234,6 @@ task_groups:
- .serverless
pre:
- func: fetch source
- func: prepare resources
- func: windows fix
- func: fix absolute paths
- func: make files executable
Expand Down
14 changes: 7 additions & 7 deletions .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ BASE_TASKS.push({
}
},
{ func: 'bootstrap kms servers' },
{
func: 'run tests',
vars: {
MONGODB_API_VERSION: '1',
NO_EXIT: ''
}
}
// TODO(NODE-4642): Fix versioned API tests
// {
// func: 'run tests',
// vars: {
// MONGODB_API_VERSION: '1'
// }
// }
]
});

Expand Down
64 changes: 64 additions & 0 deletions .evergreen/prepare-shell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#! /usr/bin/env bash

set -o xtrace
set -o errexit

# This script prepares a shell to run the remaining scripts in this folder
# It MUST be kept idempotent! It will overwrite the orchestration config and expansion.yml file upon every run
# and it will only clone drivers-tools if they do not exist one directory above our driver src

PROJECT_DIRECTORY="$(pwd)"
DRIVERS_TOOLS=$(cd .. && echo "$(pwd)/drivers-tools")
MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
UPLOAD_BUCKET="$PROJECT"

if [ "Windows_NT" = "${OS:-notWindows}" ]; then
# fix paths on windows
DRIVERS_TOOLS=$(cygpath -m -a "$DRIVERS_TOOLS")
MONGO_ORCHESTRATION_HOME=$(cygpath -m -a "$MONGO_ORCHESTRATION_HOME")
MONGODB_BINARIES=$(cygpath -m -a "$MONGODB_BINARIES")
PROJECT_DIRECTORY=$(cygpath -m -a "$PROJECT_DIRECTORY")
fi

export PROJECT_DIRECTORY
export DRIVERS_TOOLS
export MONGO_ORCHESTRATION_HOME
export MONGODB_BINARIES

export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
export PATH="$MONGODB_BINARIES:$PATH"

if [ ! -d "$DRIVERS_TOOLS" ]; then
# Only clone driver tools if it does not exist
git clone --depth=1 "https://github.com/mongodb-labs/drivers-evergreen-tools.git" "${DRIVERS_TOOLS}"
fi

cat <<EOT > "$MONGO_ORCHESTRATION_HOME/orchestration.config"
{
"releases": {
"default": "$MONGODB_BINARIES"
}
}
EOT

cat <<EOT > expansion.yml
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
set -o xtrace
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
export MONGODB_BINARIES="$MONGODB_BINARIES"
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
export PATH="$MONGODB_BINARIES:$PATH"
export PROJECT="${PROJECT}"
EOT
# See what we've done
cat expansion.yml
Loading