Skip to content

Commit 14d26bc

Browse files
committed
[1/x] Migrate all pre and most post scripts to subprocess in /scripts
1 parent 2742a00 commit 14d26bc

11 files changed

+227
-200
lines changed

.evergreen/config.yml

Lines changed: 48 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,11 @@ functions:
4848
file: src/expansion.yml
4949

5050
"prepare resources":
51-
- command: shell.exec
51+
- command: subprocess.exec
5252
params:
53-
script: |
54-
. src/.evergreen/scripts/env.sh
55-
set -o xtrace
56-
rm -rf $DRIVERS_TOOLS
57-
if [ "$PROJECT" = "drivers-tools" ]; then
58-
# If this was a patch build, doing a fresh clone would not actually test the patch
59-
cp -R ${PROJECT_DIRECTORY}/ ${DRIVERS_TOOLS}
60-
else
61-
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git ${DRIVERS_TOOLS}
62-
fi
63-
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config
53+
binary: bash
54+
args:
55+
- src/.evergreen/scripts/prepare-resources.sh
6456

6557
"upload coverage" :
6658
- command: ec2.assume_role
@@ -124,15 +116,12 @@ functions:
124116
- command: ec2.assume_role
125117
params:
126118
role_arn: ${assume_role_arn}
127-
- command: shell.exec
119+
- command: subprocess.exec
128120
params:
129-
script: |
130-
. src/.evergreen/scripts/env.sh
131-
set -o xtrace
132-
mkdir out_dir
133-
find $MONGO_ORCHESTRATION_HOME -name \*.log -exec sh -c 'x="{}"; mv $x $PWD/out_dir/$(basename $(dirname $x))_$(basename $x)' \;
134-
tar zcvf mongodb-logs.tar.gz -C out_dir/ .
135-
rm -rf out_dir
121+
binary: bash
122+
args:
123+
- src/.evergreen/scripts/archive-mongodb-logs.sh
124+
136125
- command: archive.targz_pack
137126
params:
138127
target: "mongo-coredumps.tgz"
@@ -226,54 +215,11 @@ functions:
226215
file: "src/xunit-results/TEST-*.xml"
227216

228217
"bootstrap mongo-orchestration":
229-
- command: shell.exec
218+
- command: subprocess.exec
230219
params:
231-
script: |
232-
. src/.evergreen/scripts/env.sh
233-
set -o xtrace
234-
235-
# Enable core dumps if enabled on the machine
236-
# Copied from https://github.com/mongodb/mongo/blob/master/etc/evergreen.yml
237-
if [ -f /proc/self/coredump_filter ]; then
238-
# Set the shell process (and its children processes) to dump ELF headers (bit 4),
239-
# anonymous shared mappings (bit 1), and anonymous private mappings (bit 0).
240-
echo 0x13 > /proc/self/coredump_filter
241-
242-
if [ -f /sbin/sysctl ]; then
243-
# Check that the core pattern is set explicitly on our distro image instead
244-
# of being the OS's default value. This ensures that coredump names are consistent
245-
# across distros and can be picked up by Evergreen.
246-
core_pattern=$(/sbin/sysctl -n "kernel.core_pattern")
247-
if [ "$core_pattern" = "dump_%e.%p.core" ]; then
248-
echo "Enabling coredumps"
249-
ulimit -c unlimited
250-
fi
251-
fi
252-
fi
253-
254-
if [ $(uname -s) = "Darwin" ]; then
255-
core_pattern_mac=$(/usr/sbin/sysctl -n "kern.corefile")
256-
if [ "$core_pattern_mac" = "dump_%N.%P.core" ]; then
257-
echo "Enabling coredumps"
258-
ulimit -c unlimited
259-
fi
260-
fi
261-
262-
if [ -n "${skip_crypt_shared}" ]; then
263-
export SKIP_CRYPT_SHARED=1
264-
fi
265-
266-
MONGODB_VERSION=${VERSION} \
267-
TOPOLOGY=${TOPOLOGY} \
268-
AUTH=${AUTH} \
269-
SSL=${SSL} \
270-
STORAGE_ENGINE=${STORAGE_ENGINE} \
271-
DISABLE_TEST_COMMANDS=${DISABLE_TEST_COMMANDS} \
272-
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
273-
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
274-
LOAD_BALANCER=${LOAD_BALANCER} \
275-
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
276-
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
220+
binary: bash
221+
args:
222+
- src/.evergreen/scripts/bootstrap-mongo-orchestration.sh
277223
- command: expansions.update
278224
params:
279225
file: mo-expansion.yml
@@ -284,28 +230,25 @@ functions:
284230
value: "1"
285231

286232
"bootstrap data lake":
287-
- command: shell.exec
233+
- command: subprocess.exec
288234
type: setup
289235
params:
290-
script: |
291-
. src/.evergreen/scripts/env.sh
292-
bash ${DRIVERS_TOOLS}/.evergreen/atlas_data_lake/pull-mongohouse-image.sh
293-
- command: shell.exec
236+
binary: bash
237+
args:
238+
- ${DRIVERS_TOOLS}/.evergreen/atlas_data_lake/pull-mongohouse-image.sh
239+
- command: subprocess.exec
294240
type: setup
295241
params:
296-
script: |
297-
. src/.evergreen/scripts/env.sh
298-
bash ${DRIVERS_TOOLS}/.evergreen/atlas_data_lake/run-mongohouse-image.sh
299-
sleep 1
300-
docker ps
242+
binary: bash
243+
args:
244+
- ${DRIVERS_TOOLS}/.evergreen/atlas_data_lake/run-mongohouse-image.sh
301245

302246
"stop mongo-orchestration":
303-
- command: shell.exec
247+
- command: subprocess.exec
304248
params:
305-
script: |
306-
. src/.evergreen/scripts/env.sh
307-
set -o xtrace
308-
bash ${DRIVERS_TOOLS}/.evergreen/stop-orchestration.sh
249+
binary: bash
250+
args:
251+
- ${DRIVERS_TOOLS}/.evergreen/stop-orchestration.sh
309252

310253
"run mod_wsgi tests":
311254
- command: shell.exec
@@ -341,76 +284,14 @@ functions:
341284
PYTHON_BINARY=${PYTHON_BINARY} bash ${PROJECT_DIRECTORY}/.evergreen/hatch.sh doctest:test
342285
343286
"run tests":
344-
- command: shell.exec
345-
params:
346-
working_dir: "src"
347-
shell: bash
348-
background: true
349-
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
350-
script: |
351-
. .evergreen/scripts/env.sh
352-
if [ -n "${test_encryption}" ]; then
353-
./.evergreen/hatch.sh encryption:setup
354-
fi
355-
- command: shell.exec
287+
- command: subprocess.exec
356288
type: test
357289
params:
290+
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
358291
working_dir: "src"
359-
shell: bash
360-
script: |
361-
# Disable xtrace
362-
set +x
363-
. .evergreen/scripts/env.sh
364-
if [ -n "${MONGODB_STARTED}" ]; then
365-
export PYMONGO_MUST_CONNECT=true
366-
fi
367-
if [ -n "${DISABLE_TEST_COMMANDS}" ]; then
368-
export PYMONGO_DISABLE_TEST_COMMANDS=1
369-
fi
370-
if [ -n "${test_encryption}" ]; then
371-
# Disable xtrace (just in case it was accidentally set).
372-
set +x
373-
bash ${DRIVERS_TOOLS}/.evergreen/csfle/await-servers.sh
374-
export TEST_ENCRYPTION=1
375-
if [ -n "${test_encryption_pyopenssl}" ]; then
376-
export TEST_ENCRYPTION_PYOPENSSL=1
377-
fi
378-
fi
379-
if [ -n "${test_crypt_shared}" ]; then
380-
export TEST_CRYPT_SHARED=1
381-
export CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH}
382-
fi
383-
if [ -n "${test_pyopenssl}" ]; then
384-
export TEST_PYOPENSSL=1
385-
fi
386-
if [ -n "${SETDEFAULTENCODING}" ]; then
387-
export SETDEFAULTENCODING="${SETDEFAULTENCODING}"
388-
fi
389-
if [ -n "${test_loadbalancer}" ]; then
390-
export TEST_LOADBALANCER=1
391-
export SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}"
392-
export MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}"
393-
fi
394-
if [ -n "${test_serverless}" ]; then
395-
export TEST_SERVERLESS=1
396-
fi
397-
if [ -n "${TEST_INDEX_MANAGEMENT}" ]; then
398-
export TEST_INDEX_MANAGEMENT=1
399-
fi
400-
if [ -n "${SKIP_CSOT_TESTS}" ]; then
401-
export SKIP_CSOT_TESTS=1
402-
fi
403-
404-
GREEN_FRAMEWORK=${GREEN_FRAMEWORK} \
405-
PYTHON_BINARY=${PYTHON_BINARY} \
406-
NO_EXT=${NO_EXT} \
407-
COVERAGE=${COVERAGE} \
408-
COMPRESSORS=${COMPRESSORS} \
409-
AUTH=${AUTH} \
410-
SSL=${SSL} \
411-
TEST_DATA_LAKE=${TEST_DATA_LAKE} \
412-
MONGODB_API_VERSION=${MONGODB_API_VERSION} \
413-
bash ${PROJECT_DIRECTORY}/.evergreen/hatch.sh test:test-eg
292+
binary: bash
293+
args:
294+
- .evergreen/scripts/run-tests.sh
414295

415296
"run enterprise auth tests":
416297
- command: shell.exec
@@ -535,25 +416,13 @@ functions:
535416
.evergreen/run-mongodb-aws-test.sh session-creds
536417
537418
"run aws ECS auth test":
538-
- command: shell.exec
419+
- command: subprocess.exec
539420
type: test
540421
params:
541-
shell: "bash"
422+
binary: "bash"
542423
working_dir: "src"
543-
script: |
544-
if [ "${skip_ECS_auth_test}" = "true" ]; then
545-
echo "This platform does not support the ECS auth test, skipping..."
546-
exit 0
547-
fi
548-
. .evergreen/scripts/env.sh
549-
set -ex
550-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
551-
. ./activate-authawsvenv.sh
552-
. aws_setup.sh ecs
553-
export MONGODB_BINARIES="$MONGODB_BINARIES";
554-
export PROJECT_DIRECTORY="${PROJECT_DIRECTORY}";
555-
python aws_tester.py ecs
556-
cd -
424+
args:
425+
- .evergreen/scripts/run-aws-ecs-auth-test.sh
557426

558427
"cleanup":
559428
- command: shell.exec
@@ -568,54 +437,33 @@ functions:
568437
"fix absolute paths":
569438
- command: shell.exec
570439
params:
571-
script: |
572-
set +x
573-
. src/.evergreen/scripts/env.sh
574-
for filename in $(find ${DRIVERS_TOOLS} -name \*.json); do
575-
perl -p -i -e "s|ABSOLUTE_PATH_REPLACEMENT_TOKEN|${DRIVERS_TOOLS}|g" $filename
576-
done
440+
args:
441+
- src/.evergreen/scripts/fix-absolute-paths.sh
577442

578443
"windows fix":
579-
- command: shell.exec
444+
- command: subprocess.exec
580445
params:
581-
script: |
582-
set +x
583-
. src/.evergreen/scripts/env.sh
584-
for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do
585-
cat $i | tr -d '\r' > $i.new
586-
mv $i.new $i
587-
done
588-
# Copy client certificate because symlinks do not work on Windows.
589-
cp ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem $MONGO_ORCHESTRATION_HOME/lib/client.pem
446+
args:
447+
- src/.evergreen/scripts/windows-fix.sh
590448

591449
"make files executable":
592-
- command: shell.exec
450+
- command: subprocess.exec
593451
params:
594-
script: |
595-
set +x
596-
. src/.evergreen/scripts/env.sh
597-
for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do
598-
chmod +x $i
599-
done
452+
args:
453+
- src/.evergreen/scripts/make-files-executable.sh
600454

601455
"init test-results":
602-
- command: shell.exec
456+
- command: subprocess.exec
603457
params:
604-
script: |
605-
set +x
606-
. src/.evergreen/scripts/env.sh
607-
echo '{"results": [{ "status": "FAIL", "test_file": "Build", "log_raw": "No test-results.json found was created" } ]}' > ${PROJECT_DIRECTORY}/test-results.json
458+
args:
459+
- src/.evergreen/scripts/init-test-results.sh
608460

609461
"install dependencies":
610-
- command: shell.exec
462+
- command: subprocess.exec
611463
params:
612464
working_dir: "src"
613-
script: |
614-
. .evergreen/scripts/env.sh
615-
set -o xtrace
616-
file="${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh"
617-
# Don't use ${file} syntax here because evergreen treats it as an empty expansion.
618-
[ -f "$file" ] && bash $file || echo "$file not available, skipping"
465+
args:
466+
- .evergreen/scripts/install-dependencies.sh
619467

620468
"assume ec2 role":
621469
- command: ec2.assume_role
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!bin/bash
2+
3+
. src/.evergreen/scripts/env.sh
4+
set -o xtrace
5+
mkdir out_dir
6+
find $MONGO_ORCHESTRATION_HOME -name \*.log -exec sh -c 'x="{}"; mv $x $PWD/out_dir/$(basename $(dirname $x))_$(basename $x)' \;
7+
tar zcvf mongodb-logs.tar.gz -C out_dir/ .
8+
rm -rf out_dir
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
. src/.evergreen/scripts/env.sh
4+
set -o xtrace
5+
6+
# Enable core dumps if enabled on the machine
7+
# Copied from https://github.com/mongodb/mongo/blob/master/etc/evergreen.yml
8+
if [ -f /proc/self/coredump_filter ]; then
9+
# Set the shell process (and its children processes) to dump ELF headers (bit 4),
10+
# anonymous shared mappings (bit 1), and anonymous private mappings (bit 0).
11+
echo 0x13 >/proc/self/coredump_filter
12+
13+
if [ -f /sbin/sysctl ]; then
14+
# Check that the core pattern is set explicitly on our distro image instead
15+
# of being the OS's default value. This ensures that coredump names are consistent
16+
# across distros and can be picked up by Evergreen.
17+
core_pattern=$(/sbin/sysctl -n "kernel.core_pattern")
18+
if [ "$core_pattern" = "dump_%e.%p.core" ]; then
19+
echo "Enabling coredumps"
20+
ulimit -c unlimited
21+
fi
22+
fi
23+
fi
24+
25+
if [ $(uname -s) = "Darwin" ]; then
26+
core_pattern_mac=$(/usr/sbin/sysctl -n "kern.corefile")
27+
if [ "$core_pattern_mac" = "dump_%N.%P.core" ]; then
28+
echo "Enabling coredumps"
29+
ulimit -c unlimited
30+
fi
31+
fi
32+
33+
if [ -n "${skip_crypt_shared}" ]; then
34+
export SKIP_CRYPT_SHARED=1
35+
fi
36+
37+
MONGODB_VERSION=${VERSION} \
38+
TOPOLOGY=${TOPOLOGY} \
39+
AUTH=${AUTH} \
40+
SSL=${SSL} \
41+
STORAGE_ENGINE=${STORAGE_ENGINE} \
42+
DISABLE_TEST_COMMANDS=${DISABLE_TEST_COMMANDS} \
43+
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
44+
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
45+
LOAD_BALANCER=${LOAD_BALANCER} \
46+
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
47+
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set +x
4+
. src/.evergreen/scripts/env.sh
5+
for filename in $(find $DRIVERS_TOOLS -name \*.json); do
6+
perl -p -i -e "s|ABSOLUTE_PATH_REPLACEMENT_TOKEN|$DRIVERS_TOOLS|g" $filename
7+
done
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set +x
4+
. src/.evergreen/scripts/env.sh
5+
echo '{"results": [{ "status": "FAIL", "test_file": "Build", "log_raw": "No test-results.json found was created" } ]}' >$PROJECT_DIRECTORY/test-results.json

0 commit comments

Comments
 (0)