Skip to content

Commit 23537e6

Browse files
authored
test(NODE-4648): pull prepare shell out to script and fix reporter error handling (#3418)
1 parent 5eb3978 commit 23537e6

File tree

10 files changed

+227
-212
lines changed

10 files changed

+227
-212
lines changed

.evergreen/config.in.yml

+28-69
Original file line numberDiff line numberDiff line change
@@ -28,81 +28,44 @@ functions:
2828
params:
2929
directory: "src"
3030
shallow_clone: true # speed things up by limiting clone depth to 100
31+
3132
# Make an evergreen expansion file with dynamic values
32-
- command: shell.exec
33+
- command: subprocess.exec
3334
params:
3435
working_dir: "src"
35-
script: |
36-
# Get the current unique version of this checkout
37-
if [ "${is_patch}" = "true" ]; then
38-
CURRENT_VERSION=$(git describe)-patch-${version_id}
39-
else
40-
CURRENT_VERSION=latest
41-
fi
42-
43-
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
44-
45-
export PROJECT_DIRECTORY="$(pwd)"
46-
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
47-
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
48-
export UPLOAD_BUCKET="${project}"
49-
50-
# fix paths on windows
51-
if [ "Windows_NT" = "$OS" ]; then
52-
export DRIVERS_TOOLS=$(cygpath -m -a $DRIVERS_TOOLS)
53-
export MONGO_ORCHESTRATION_HOME=$(cygpath -m -a $MONGO_ORCHESTRATION_HOME)
54-
export MONGODB_BINARIES=$(cygpath -m -a $MONGODB_BINARIES)
55-
export PROJECT_DIRECTORY=$(cygpath -m -a $PROJECT_DIRECTORY)
56-
fi
57-
58-
cat <<EOT > expansion.yml
59-
CURRENT_VERSION: "$CURRENT_VERSION"
60-
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
61-
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
62-
MONGODB_BINARIES: "$MONGODB_BINARIES"
63-
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
64-
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
65-
PREPARE_SHELL: |
66-
set -o errexit
67-
set -o xtrace
68-
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
69-
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
70-
export MONGODB_BINARIES="$MONGODB_BINARIES"
71-
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
72-
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
73-
74-
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
75-
export PATH="$MONGODB_BINARIES:$PATH"
76-
export PROJECT="${project}"
77-
EOT
78-
# See what we've done
79-
cat expansion.yml
36+
binary: bash
37+
env:
38+
is_patch: ${is_patch}
39+
project: ${project}
40+
args:
41+
- .evergreen/prepare-shell.sh
8042

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

86-
"prepare resources":
87-
- command: shell.exec
88-
params:
89-
script: |
90-
${PREPARE_SHELL}
91-
git clone --depth 1 https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
92-
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config
93-
9448
"bootstrap mongo-orchestration":
95-
- command: shell.exec
49+
- command: subprocess.exec
9650
params:
97-
script: |
98-
${PREPARE_SHELL}
99-
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
100-
AUTH=${AUTH} SSL=${SSL} \
101-
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
102-
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
103-
LOAD_BALANCER=${LOAD_BALANCER} \
104-
COMPRESSOR=${COMPRESSOR} \
105-
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
51+
binary: bash
52+
add_expansions_to_env: true
53+
env:
54+
# The following is the settings for how we want to launch mongodb
55+
MONGODB_VERSION: ${VERSION}
56+
TOPOLOGY: ${TOPOLOGY}
57+
AUTH: ${AUTH}
58+
SSL: ${SSL}
59+
ORCHESTRATION_FILE: ${ORCHESTRATION_FILE}
60+
REQUIRE_API_VERSION: ${REQUIRE_API_VERSION}
61+
LOAD_BALANCER: ${LOAD_BALANCER}
62+
COMPRESSOR: ${COMPRESSOR}
63+
# These are paths necessary for launching mongodb
64+
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
65+
MONGODB_BINARIES: ${MONGODB_BINARIES}
66+
args:
67+
- src/.evergreen/run-orchestration.sh
68+
10669
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
10770
- command: expansions.update
10871
params:
@@ -175,7 +138,7 @@ functions:
175138
MONGODB_URI="${MONGODB_URI}" \
176139
AUTH=${AUTH} SSL=${SSL} TEST_CSFLE=true \
177140
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
178-
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} NO_EXIT=${NO_EXIT|1} \
141+
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} \
179142
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
180143
181144
"run serverless tests":
@@ -244,7 +207,6 @@ functions:
244207
MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}" \
245208
TOPOLOGY="${TOPOLOGY}" \
246209
SKIP_DEPS=${SKIP_DEPS|1} \
247-
NO_EXIT=${NO_EXIT|1} \
248210
LOAD_BALANCER="${LOAD_BALANCER}" \
249211
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
250212
@@ -265,7 +227,6 @@ functions:
265227
TOPOLOGY="${TOPOLOGY}" \
266228
COMPRESSOR="${COMPRESSOR}" \
267229
SKIP_DEPS=${SKIP_DEPS|1} \
268-
NO_EXIT=${NO_EXIT|1} \
269230
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
270231
271232
"run lint checks":
@@ -959,7 +920,6 @@ task_groups:
959920
setup_group_timeout_secs: 1800 # 30 minutes
960921
setup_group:
961922
- func: "fetch source"
962-
- func: "prepare resources"
963923
- command: shell.exec
964924
params:
965925
shell: "bash"
@@ -991,7 +951,6 @@ task_groups:
991951

992952
pre:
993953
- func: "fetch source"
994-
- func: "prepare resources"
995954
- func: "windows fix"
996955
- func: "fix absolute paths"
997956
- func: "make files executable"

.evergreen/config.yml

+24-75
Original file line numberDiff line numberDiff line change
@@ -13,79 +13,36 @@ functions:
1313
params:
1414
directory: src
1515
shallow_clone: true
16-
- command: shell.exec
16+
- command: subprocess.exec
1717
params:
1818
working_dir: src
19-
script: |
20-
# Get the current unique version of this checkout
21-
if [ "${is_patch}" = "true" ]; then
22-
CURRENT_VERSION=$(git describe)-patch-${version_id}
23-
else
24-
CURRENT_VERSION=latest
25-
fi
26-
27-
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
28-
29-
export PROJECT_DIRECTORY="$(pwd)"
30-
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
31-
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
32-
export UPLOAD_BUCKET="${project}"
33-
34-
# fix paths on windows
35-
if [ "Windows_NT" = "$OS" ]; then
36-
export DRIVERS_TOOLS=$(cygpath -m -a $DRIVERS_TOOLS)
37-
export MONGO_ORCHESTRATION_HOME=$(cygpath -m -a $MONGO_ORCHESTRATION_HOME)
38-
export MONGODB_BINARIES=$(cygpath -m -a $MONGODB_BINARIES)
39-
export PROJECT_DIRECTORY=$(cygpath -m -a $PROJECT_DIRECTORY)
40-
fi
41-
42-
cat <<EOT > expansion.yml
43-
CURRENT_VERSION: "$CURRENT_VERSION"
44-
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
45-
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
46-
MONGODB_BINARIES: "$MONGODB_BINARIES"
47-
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
48-
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
49-
PREPARE_SHELL: |
50-
set -o errexit
51-
set -o xtrace
52-
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
53-
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
54-
export MONGODB_BINARIES="$MONGODB_BINARIES"
55-
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
56-
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
57-
58-
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
59-
export PATH="$MONGODB_BINARIES:$PATH"
60-
export PROJECT="${project}"
61-
EOT
62-
# See what we've done
63-
cat expansion.yml
19+
binary: bash
20+
env:
21+
is_patch: ${is_patch}
22+
project: ${project}
23+
args:
24+
- .evergreen/prepare-shell.sh
6425
- command: expansions.update
6526
params:
6627
file: src/expansion.yml
67-
prepare resources:
68-
- command: shell.exec
69-
params:
70-
script: >
71-
${PREPARE_SHELL}
72-
73-
git clone --depth 1 https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
74-
75-
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" >
76-
$MONGO_ORCHESTRATION_HOME/orchestration.config
7728
bootstrap mongo-orchestration:
78-
- command: shell.exec
29+
- command: subprocess.exec
7930
params:
80-
script: |
81-
${PREPARE_SHELL}
82-
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
83-
AUTH=${AUTH} SSL=${SSL} \
84-
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
85-
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
86-
LOAD_BALANCER=${LOAD_BALANCER} \
87-
COMPRESSOR=${COMPRESSOR} \
88-
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
31+
binary: bash
32+
add_expansions_to_env: true
33+
env:
34+
MONGODB_VERSION: ${VERSION}
35+
TOPOLOGY: ${TOPOLOGY}
36+
AUTH: ${AUTH}
37+
SSL: ${SSL}
38+
ORCHESTRATION_FILE: ${ORCHESTRATION_FILE}
39+
REQUIRE_API_VERSION: ${REQUIRE_API_VERSION}
40+
LOAD_BALANCER: ${LOAD_BALANCER}
41+
COMPRESSOR: ${COMPRESSOR}
42+
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
43+
MONGODB_BINARIES: ${MONGODB_BINARIES}
44+
args:
45+
- src/.evergreen/run-orchestration.sh
8946
- command: expansions.update
9047
params:
9148
file: mo-expansion.yml
@@ -155,7 +112,7 @@ functions:
155112
MONGODB_URI="${MONGODB_URI}" \
156113
AUTH=${AUTH} SSL=${SSL} TEST_CSFLE=true \
157114
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
158-
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} NO_EXIT=${NO_EXIT|1} \
115+
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} \
159116
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
160117
run serverless tests:
161118
- command: timeout.update
@@ -220,7 +177,6 @@ functions:
220177
MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}" \
221178
TOPOLOGY="${TOPOLOGY}" \
222179
SKIP_DEPS=${SKIP_DEPS|1} \
223-
NO_EXIT=${NO_EXIT|1} \
224180
LOAD_BALANCER="${LOAD_BALANCER}" \
225181
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
226182
run-compression-tests:
@@ -240,7 +196,6 @@ functions:
240196
TOPOLOGY="${TOPOLOGY}" \
241197
COMPRESSOR="${COMPRESSOR}" \
242198
SKIP_DEPS=${SKIP_DEPS|1} \
243-
NO_EXIT=${NO_EXIT|1} \
244199
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
245200
run lint checks:
246201
- command: subprocess.exec
@@ -1230,10 +1185,6 @@ tasks:
12301185
REQUIRE_API_VERSION: '1'
12311186
AUTH: auth
12321187
- func: bootstrap kms servers
1233-
- func: run tests
1234-
vars:
1235-
MONGODB_API_VERSION: '1'
1236-
NO_EXIT: ''
12371188
- name: test-atlas-connectivity
12381189
tags:
12391190
- atlas-connect
@@ -2253,7 +2204,6 @@ task_groups:
22532204
setup_group_timeout_secs: 1800
22542205
setup_group:
22552206
- func: fetch source
2256-
- func: prepare resources
22572207
- command: shell.exec
22582208
params:
22592209
shell: bash
@@ -2284,7 +2234,6 @@ task_groups:
22842234
- .serverless
22852235
pre:
22862236
- func: fetch source
2287-
- func: prepare resources
22882237
- func: windows fix
22892238
- func: fix absolute paths
22902239
- func: make files executable

.evergreen/generate_evergreen_tasks.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ BASE_TASKS.push({
9191
}
9292
},
9393
{ func: 'bootstrap kms servers' },
94-
{
95-
func: 'run tests',
96-
vars: {
97-
MONGODB_API_VERSION: '1',
98-
NO_EXIT: ''
99-
}
100-
}
94+
// TODO(NODE-4642): Fix versioned API tests
95+
// {
96+
// func: 'run tests',
97+
// vars: {
98+
// MONGODB_API_VERSION: '1'
99+
// }
100+
// }
101101
]
102102
});
103103

.evergreen/prepare-shell.sh

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#! /usr/bin/env bash
2+
3+
set -o xtrace
4+
set -o errexit
5+
6+
# This script prepares a shell to run the remaining scripts in this folder
7+
# It MUST be kept idempotent! It will overwrite the orchestration config and expansion.yml file upon every run
8+
# and it will only clone drivers-tools if they do not exist one directory above our driver src
9+
10+
PROJECT_DIRECTORY="$(pwd)"
11+
DRIVERS_TOOLS=$(cd .. && echo "$(pwd)/drivers-tools")
12+
MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
13+
MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
14+
UPLOAD_BUCKET="$PROJECT"
15+
16+
if [ "Windows_NT" = "${OS:-notWindows}" ]; then
17+
# fix paths on windows
18+
DRIVERS_TOOLS=$(cygpath -m -a "$DRIVERS_TOOLS")
19+
MONGO_ORCHESTRATION_HOME=$(cygpath -m -a "$MONGO_ORCHESTRATION_HOME")
20+
MONGODB_BINARIES=$(cygpath -m -a "$MONGODB_BINARIES")
21+
PROJECT_DIRECTORY=$(cygpath -m -a "$PROJECT_DIRECTORY")
22+
fi
23+
24+
export PROJECT_DIRECTORY
25+
export DRIVERS_TOOLS
26+
export MONGO_ORCHESTRATION_HOME
27+
export MONGODB_BINARIES
28+
29+
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
30+
export PATH="$MONGODB_BINARIES:$PATH"
31+
32+
if [ ! -d "$DRIVERS_TOOLS" ]; then
33+
# Only clone driver tools if it does not exist
34+
git clone --depth=1 "https://github.com/mongodb-labs/drivers-evergreen-tools.git" "${DRIVERS_TOOLS}"
35+
fi
36+
37+
cat <<EOT > "$MONGO_ORCHESTRATION_HOME/orchestration.config"
38+
{
39+
"releases": {
40+
"default": "$MONGODB_BINARIES"
41+
}
42+
}
43+
EOT
44+
45+
cat <<EOT > expansion.yml
46+
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
47+
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
48+
MONGODB_BINARIES: "$MONGODB_BINARIES"
49+
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
50+
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
51+
PREPARE_SHELL: |
52+
set -o errexit
53+
set -o xtrace
54+
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
55+
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
56+
export MONGODB_BINARIES="$MONGODB_BINARIES"
57+
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
58+
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
59+
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
60+
export PATH="$MONGODB_BINARIES:$PATH"
61+
export PROJECT="${PROJECT}"
62+
EOT
63+
# See what we've done
64+
cat expansion.yml

0 commit comments

Comments
 (0)