/
evergreen.yml
9531 lines (9048 loc) · 301 KB
/
evergreen.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#####################################################
# A note on expansions #
#####################################################
# Expansions usually appear in the form ${key|default}
# If 'key' is found in the executor's map of currently known
# expansions, the corresponding value is used. If the key can
# not be found, the default is used.
#
# Arbitrary expansions can be specified in the YAML configuration
# files in the following places:
# - The 'expansions' field for buildvariants (branch file)
# - The 'expansions' field for distros (distros file)
#
# A number of 'built-in' expansions are also available for use; these include:
# - environment variables available on the host machine
# - 'workdir' (references the executor's work directory).
# - 'task_id' (references the task id of the task the executor is working on).
# - 'build_variant' (references the executing task's buildvariant).
# - 'config_root' (references the root directory for the executor's configuration artifacts).
stepback: true
command_type: system
# Files that match an ignore-list pattern will not trigger a build, if they're the only modified
# files in the patch.
ignore:
- ".*"
- "!.clang-format"
- "!.eslintrc.yml"
- "*.md"
- "*.rst"
- "*.txt"
- "/distsrc/**"
- "/docs/**"
- "/etc/*.yml"
- "!/etc/evergreen.yml"
- "README"
## Some variables for convenience:
variables:
# Used when the tests it runs depend only on mongod, mongos, the mongo shell and the tools.
- &task_template
name: template
depends_on:
- name: compile
commands:
- func: "do setup"
- func: "run tests"
vars:
resmoke_args: --help
run_multiple_jobs: false
max_jobs: 0 # If set in combination with run_multiple_jobs, will cap the number of jobs used.
# Used for tests that invoke resmoke.py and require no additional setup.
- &task_depending_on_all_template
<<: *task_template
depends_on:
- name: compile_all
# Used to list modules to retrieve from GitHub and apply patches if necessary.
- &git_get_project
command: git.get_project
params:
directory: src
revisions: # for each module include revision as <module_name> : ${<module_name>_rev}
enterprise: ${enterprise_rev}
rocksdb: ${rocksdb_rev}
- &generate_compile_expansions
command: shell.exec
params:
working_dir: src
script: |
set -o errexit
set -o verbose
# We get the raw version string (r1.2.3-45-gabcdef) from git
MONGO_VERSION=$(git describe)
# If this is a patch build, we add the patch version id to the version string so we know
# this build was a patch, and which evergreen task it came from
if [ "${is_patch|}" = "true" ]; then
MONGO_VERSION="$MONGO_VERSION-patch-${version_id}"
fi
# This script converts the generated version string into a sanitized version string for
# use by scons and uploading artifacts as well as information about for the scons cache.
echo $MONGO_VERSION | SCONS_CACHE_MODE=${scons_cache_mode|nolinked} USE_SCONS_CACHE=${use_scons_cache|false} ${python|/opt/mongodbtoolchain/v2/bin/python2} buildscripts/generate_compile_expansions.py | tee compile_expansions.yml
- &apply_compile_expansions
command: expansions.update
params:
file: src/compile_expansions.yml
- &jepsen_config_vars
jepsen_key_time_limit: --key-time-limit 15
jepsen_protocol_version: --protocol-version 1
jepsen_read_concern: ""
jepsen_read_with_find_and_modify: ""
jepsen_storage_engine: ""
jepsen_test_name: ""
# Empirically, we've had greater success in reproducing the issues found in MongoDB versions
# 3.4.0-rc3 and 3.4.0-rc4 when running Jepsen with at least --time-limit=600.
jepsen_time_limit: --time-limit 1200
jepsen_write_concern: ""
# Template for running Jepsen tests
- &run_jepsen_template
name: run_jepsen_template
depends_on:
- name: compile
commands:
- func: "do setup"
- func: "do jepsen setup"
- func: "run jepsen test"
vars:
<<: *jepsen_config_vars
- &jstestfuzz_config_vars
resmoke_args: --help # resmoke_args needs to be overridden to specify one of the jstestfuzz suites
should_shuffle: false
continue_on_failure: false
- &run_jstestfuzz_tests
func: "run tests"
# Terminate the function when there has been no output to stdout for 30 minutes. E.g. when something is stuck in an infinite loop.
# resmoke.py writes the test output to logkeeper and only writes to stdout when starting the next test.
# resmoke.py not producing output on stdout means that the test is still running and presumably not going to finish.
# Note that timeout_secs is different from exec_timeout_secs, which applies to a task and times out regardless of whether output has been written to stdout.
timeout_secs: 1800
vars:
<<: *jstestfuzz_config_vars
# Used for tests that invoke 'resmoke.py --suites=jstestfuzz*'.
- &jstestfuzz_template
name: jstestfuzz_template
exec_timeout_secs: 14400 # Time out the task if it runs for more than 4 hours.
depends_on:
- name: compile
commands:
- func: "do setup"
- func: "run jstestfuzz"
- *run_jstestfuzz_tests
#######################################
# Functions #
#######################################
functions:
"fetch artifacts" : &fetch_artifacts
command: s3.get
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
remote_file: mongodb-mongo-master/${build_variant}/${revision}/artifacts/${build_id}.tgz
bucket: mciuploads
extract_to: src
"fetch binaries" : &fetch_binaries
command: s3.get
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
remote_file: mongodb-mongo-master/${build_variant}/${revision}/binaries/mongo-${build_id}.${ext|tgz}
bucket: mciuploads
local_file: src/mongo-binaries.tgz
"extract binaries" : &extract_binaries
command: shell.exec
params:
working_dir: src
script: |
set -o errexit
${decompress} mongo-binaries.tgz
cp mongodb*/bin/* .
"check binary version" : &check_binary_version
command: shell.exec
params:
working_dir: src
script: |
set -o errexit
mongo_binary=$(find mongodb*/bin -name mongo${exe})
# There should only be one mongo shell
if [ $(echo $mongo_binary | wc -w) -ne 1 ]; then
echo "There is more than 1 extracted mongo binary: $mongo_binary"
exit 1
fi
bin_ver=$(${python|/opt/mongodbtoolchain/v2/bin/python2} -c "import yaml; print(yaml.safe_load(open('compile_expansions.yml'))['version']);" | tr -d '[ \r\n]')
# Due to SERVER-23810, we cannot use $mongo_binary --quiet --nodb --eval "version();"
mongo_ver=$($mongo_binary --version | perl -pe '/version v(.*)$/; $_ = $1;' | tr -d '[ \r\n]')
# The versions must match
if [ "$bin_ver" != "$mongo_ver" ]; then
echo "The mongo version is $mongo_ver, expected version is $bin_ver"
exit 1
fi
"get buildnumber" : &get_buildnumber
command: keyval.inc
params:
key: "${build_variant}_master"
destination: "builder_num"
"run diskstats": &run_diskstats
command: shell.exec
params:
background: true
system_log: true
script: |
set -o errexit
set -o verbose
# On Windows we can use typeperf.exe to dump performance counters.
if [ "Windows_NT" = "$OS" ]; then
typeperf -qx PhysicalDisk | grep Disk | grep -v _Total > disk_counters.txt
typeperf -cf disk_counters.txt -si 5 -o mongo-diskstats
# Solaris: iostat -T d option for timestamp.
elif iostat -T d -Mx > /dev/null 2>&1; then
iostat -T d -Mx 5 > mongo-diskstats
# Linux: iostat -t option for timestamp.
elif iostat -tdmx > /dev/null 2>&1; then
iostat -tdmx 5 > mongo-diskstats
# OSX: Simulate the iostat timestamp.
elif iostat -d > /dev/null 2>&1; then
iostat -d -w 5 | while IFS= read -r line; do printf '%s %s\n' "$(date +'%m/%d/%Y %H:%M:%S')" "$line" >> mongo-diskstats; done
# Check if vmstat -t is available.
elif vmstat -td > /dev/null 2>&1; then
vmstat -td 5 > mongo-diskstats
# Check if vmstat -T d is available.
elif vmstat -T d > /dev/null 2>&1; then
vmstat -T d 5 > mongo-diskstats
else
printf "Cannot collect mongo-diskstats on this platform\n"
fi
"collect system resource info": &collect_system_resource_info
command: shell.exec
params:
working_dir: src
background: true
system_log: true
script: |
${python|/opt/mongodbtoolchain/v2/bin/python2} buildscripts/collect_resource_info.py -o system_resource_info_${task_id}.json -i 5
# Run a monitor process as a background, system task to periodically
# display how many threads interesting processes are using.
"monitor process threads": &monitor_process_threads
command: shell.exec
params:
background: true
system_log: true
script: |
proc_list="(bsondump|java|lein|mongo|python|_test$|_test\.exe$)"
if [ "Windows_NT" = "$OS" ]; then
get_pids() {
proc_pids=$(tasklist /fo:csv |
awk -F'","' '{x=$1; gsub("\"","",x); print $2, x}' |
grep -i -E $1 |
cut -f1 -d ' ');
}
get_process_info() {
proc_name="";
proc_info=$(wmic process where "ProcessId=\"$1\"" get "Name,ProcessId,ThreadCount" /format:csv 2> /dev/null | grep $1);
if [ ! -z $proc_info ]; then
proc_name=$(echo $proc_info | cut -f2 -d ',');
proc_threads=$(echo $proc_info | cut -f4 -d ',');
fi;
}
else
get_pids() { proc_pids=$(pgrep $1); }
get_process_info() {
proc_name=$(ps -p $1 -o comm=);
# prstat is available on Solaris
if [ ! -z $(which prstat 2> /dev/null) ]; then
proc_threads=$(prstat -p $1 1 1 | grep $1 | cut -f2 -d "/");
# /proc is available on Linux platforms
elif [ -f /proc/$1/status ]; then
${set_sudo}
proc_threads=$($sudo grep Threads /proc/$1/status | sed "s/\s//g" | cut -f2 -d ":");
else
proc_threads=$(ps -AM $1 | grep -vc PID);
fi;
}
fi
while [ 1 ]
do
get_pids $proc_list
if [ ! -z "$proc_pids" ]; then
printf "Running process/thread counter\n"
printf "PROCESS\tPID\tTHREADS\n"
fi
for pid in $proc_pids
do
get_process_info $pid
if [ ! -z "$proc_name" ]; then
printf "$proc_name\t$pid\t$proc_threads\n"
fi
done
sleep 60
done
"setup credentials" : &setup_credentials
command: shell.exec
params:
working_dir: src
silent: true
script: |
cat > mci.buildlogger <<END_OF_CREDS
slavename='${slave}'
passwd='${passwd}'
builder='MCI_${build_variant}'
build_num=${builder_num}
build_phase='${task_name}_${execution}'
END_OF_CREDS
"upload debugsymbols" : &upload_debugsymbols
command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: src/mongo-debugsymbols.tgz
remote_file: mongodb-mongo-master/${build_variant}/${revision}/debugsymbols/debugsymbols-${build_id}.${ext|tgz}
bucket: mciuploads
permissions: public-read
content_type: ${content_type|application/x-gzip}
"fetch debugsymbols archive" : &fetch_debugsymbols_archive
command: s3.get
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
remote_file: mongodb-mongo-master/${build_variant}/${revision}/debugsymbols/debugsymbols-${build_id}.${ext|tgz}
bucket: mciuploads
local_file: src/mongo-debugsymbols.tgz
"extract debugsymbols" : &extract_debugsymbols
command: shell.exec
params:
working_dir: src
script: |
set -o errexit
set -o verbose
# Debug symbols are not created for every variant
if [ ! -f mongo-debugsymbols.tgz ]; then
exit
fi
${decompress} mongo-debugsymbols.tgz
files="mongo mongod mongos"
file_exts="debug dSYM pdb"
for file_ext in $file_exts
do
for file in $files
do
mv mongodb*/$file.$file_ext . 2>/dev/null || true
done
rm -r mongodb*/*.$file_ext 2>/dev/null || true
done
rm mongo-debugsymbols.tgz 2>/dev/null || true
"build rocksdb" :
command: shell.exec
params:
script: |
set -o errexit
set -o verbose
if [ "${build_rocksdb|}" = "true" ]; then
rm -rf rocksdb
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
make CC=/opt/mongodbtoolchain/v2/bin/gcc CXX=/opt/mongodbtoolchain/v2/bin/g++ static_lib
fi
"build cdriver" :
command: shell.exec
params:
script: |
set -o errexit
set -o verbose
if [ "${build_cdriver|}" = "true" ]; then
CDRIVER_VERSION=1.6.3
rm -rf mongo-c-driver-$CDRIVER_VERSION
rm -rf mongo-c-driver
curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$CDRIVER_VERSION/mongo-c-driver-$CDRIVER_VERSION.tar.gz
tar xzf mongo-c-driver-$CDRIVER_VERSION.tar.gz
mv mongo-c-driver-$CDRIVER_VERSION mongo-c-driver
cd mongo-c-driver
export ${compile_env|}
./configure --prefix=$(pwd)/install --build x86_64-apple-darwin16.6.0 --host arm-apple-darwin --with-libbson=bundled --disable-automatic-init-and-cleanup --disable-ssl --disable-sasl --disable-examples --disable-man-pages --disable-html-docs --disable-shm-counters --disable-shared --enable-static CC="$(xcrun -f --sdk iphoneos clang)" CXX="$(xcrun -f --sdk iphoneos clang++)" CPPFLAGS="-isysroot $(xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=10.2 -arch arm64 -fembed-bitcode" CFLAGS="-isysroot $(xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=10.2 -arch arm64 -fembed-bitcode" CXXFLAGS="-isysroot $(xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=10.2 -arch arm64 -fembed-bitcode" LDFLAGS="-miphoneos-version-min=10.2 -arch arm64"
make
make install
fi
"build new tools" :
command: shell.exec
params:
working_dir: src/src/mongo/gotools
script: |
set -o verbose
set -o errexit
# make sure newlines in the scripts are handled correctly by windows
if [ "Windows_NT" = "$OS" ]; then
set -o igncr
fi;
sed -i.bak "s/built-without-version-string/$(git describe)/" common/options/options.go
sed -i.bak "s/built-without-git-spec/$(git rev-parse HEAD)/" common/options/options.go
. ./${set_tools_gopath|set_gopath.sh}
build_tools="bsondump mongostat mongofiles mongoexport mongoimport mongorestore mongodump mongotop mongooplog"
if [ "${build_mongoreplay}" = "true" ]; then
build_tools="$build_tools mongoreplay"
fi
for i in $build_tools; do
${gorootvars} go build ${tooltags|} -o "../../mongo-tools/$i${exe|}" $i/main/$i.go
"../../mongo-tools/$i${exe|}" --version
done
"do setup" :
- *fetch_artifacts
- *fetch_binaries
- *extract_binaries
- *check_binary_version
- *get_buildnumber
- *setup_credentials
- *run_diskstats
- *monitor_process_threads
- *collect_system_resource_info
"set up virtualenv" :
command: shell.exec
type: test
params:
working_dir: src
script: |
# exit immediately if virtualenv is not found
set -o errexit
set -o verbose
virtualenv --system-site-packages ./venv
"run tests" :
command: shell.exec
type: test
params:
working_dir: src
script: |
set -o errexit
set -o verbose
# check if virtualenv is set up
if [ -d "venv" ]; then
if [ "Windows_NT" = "$OS" ]; then
. ./venv/Scripts/activate
else
. ./venv/bin/activate
fi
fi
if [ -f /proc/self/coredump_filter ]; then
# Set the shell process (and its children processes) to dump ELF headers (bit 4),
# anonymous shared mappings (bit 1), and anonymous private mappings (bit 0).
echo 0x13 > /proc/self/coredump_filter
if [ -f /sbin/sysctl ]; then
# Check that the core pattern is set explicitly on our distro image instead
# of being the OS's default value. This ensures that coredump names are consistent
# across distros and can be picked up by Evergreen.
core_pattern=$(/sbin/sysctl -n "kernel.core_pattern")
if [ "$core_pattern" = "dump_%e.%p.core" ]; then
echo "Enabling coredumps"
ulimit -c unlimited
fi
fi
fi
extra_args=""
if [ ${run_multiple_jobs|false} = true ]; then
processor_architecture=$(uname -m)
num_jobs_available=${num_jobs_available|1}
# Reduce the number of available jobs by half when running any sharding*, replica_sets*
# and select jsCore passthrough tasks on Windows and ARM to avoid overwhelming test hosts.
if [ "Windows_NT" = "$OS" ] || [ "aarch64" = $processor_architecture ]; then
case "${task_name}" in
replica_sets_initsync_jscore_passthrough \
|replica_sets_initsync_static_jscore_passthrough \
|replica_sets_resync_static_jscore_passthrough \
|replica_sets* \
|sharding* \
)
num_jobs_available=$((${num_jobs_available|2} / 2))
echo "Reducing jobs from ${num_jobs_available|1} to $num_jobs_available"
;;
esac
fi
if [ ${max_jobs|0} -gt 0 ] && [ ${max_jobs|0} -lt $num_jobs_available ]; then
extra_args="$extra_args --jobs=${max_jobs}"
else
extra_args="$extra_args --jobs=$num_jobs_available"
fi
fi
if [ ${should_shuffle|true} = true ]; then
extra_args="$extra_args --shuffle"
fi
if [ ${continue_on_failure|true} = true ]; then
extra_args="$extra_args --continueOnFailure"
fi
# Default storageEngineCacheSizeGB to 1. Override on individual test config if needed.
# resmoke will assign to the appropriate parameter on storage engines that support it.
set +o errexit
echo "${resmoke_args}" | grep -q storageEngineCacheSizeGB
if [ $? -eq 1 ]; then
extra_args="$extra_args --storageEngineCacheSizeGB=1"
fi
set -o errexit
path_value="$PATH"
if [ ${variant_path_suffix} ]; then
path_value="$path_value:${variant_path_suffix}"
fi
if [ ${task_path_suffix} ]; then
path_value="$path_value:${task_path_suffix}"
fi
preamble="PATH='$path_value' \
${gcov_environment} \
${rlp_environment} \
${san_options} \
${san_symbolizer} \
${snmp_config_path}"
# The "resmoke_wrapper" expansion is used by the 'burn_in_tests' task to wrap the resmoke.py
# invocation. It must be placed between $preamble and $resmoke.
wrapper="${resmoke_wrapper}"
resmoke="${python|/opt/mongodbtoolchain/v2/bin/python2} buildscripts/resmoke.py \
${resmoke_args} \
$extra_args \
${test_flags} \
--log=buildlogger \
--staggerJobs=on \
--taskId=${task_id}"
# Set variables for mainline builds. Patch builds will override these values below.
tag_file=etc/test_retrial.yml
retry_on_failure_options="--continueOnFailure --repeat=2"
resmoke_tags="retry_on_failure, \
retry_on_failure|${task_name}, \
retry_on_failure|${task_name}|${build_variant}, \
retry_on_failure|${task_name}|${build_variant}|${distro_id}"
# promote_silent_failures.py is only run on Evergreen mainline. Override in patch builds.
run_promote_silent_failures="${python|/opt/mongodbtoolchain/v2/bin/python2} \
buildscripts/promote_silent_failures.py -o \
report_unreliable.json report_unreliable.json"
# For patch builds, we run reliable and then unreliable tests and combine the reports.
if [ "${is_patch|}" = "true" ]; then
tag_file=etc/test_lifecycle.yml
retry_on_failure_options=""
run_promote_silent_failures=""
resmoke_tags="unreliable, \
unreliable|${task_name}, \
unreliable|${task_name}|${build_variant}, \
unreliable|${task_name}|${build_variant}|${distro_id}"
fi
# Remove spaces from the tags argument.
resmoke_tags=$(echo $resmoke_tags| tr -d " ")
# Set report file for reliable test run.
report_file=report_reliable.json
# Disable errexit, until we run combine_reports, so we can execute the reliable and
# unreliable tests.
set +o errexit
# If the "resmoke_wrapper" expansion is used for 'burn_in_tests' then add the reportFile.
echo "$wrapper" | grep -q burn_in_tests
add_report_file=$?
wrapper_report_file=""
if [ $add_report_file -eq 0 ]; then
wrapper_report_file="--reportFile=$report_file"
fi
# Set up resmoke to run without tagged tests.
resmoke_base="$resmoke \
--excludeWithAnyTags='$resmoke_tags' \
--reportFailureStatus=fail \
--reportFile=$report_file \
--tagFile=$tag_file"
# Run reliable set of tests once.
eval $preamble $wrapper $wrapper_report_file $resmoke_base
reliable_exit_code=$?
# Set report file for unreliable test run.
report_file=report_unreliable.json
# Set up resmoke to run with only tagged tests.
resmoke_base="$resmoke \
--includeWithAnyTags='$resmoke_tags' \
--reportFailureStatus=silentfail \
--reportFile=$report_file \
--tagFile=$tag_file \
$retry_on_failure_options"
if [ $add_report_file -eq 0 ]; then
wrapper_report_file="--reportFile=$report_file"
fi
# Run unreliable set of tests.
eval $preamble $wrapper $wrapper_report_file $resmoke_base
unreliable_exit_code=$?
# Reenable errexit, as the return from combine_reports will return the cumulative error.
set -o errexit
# If both executions of the test with an "retry_on_failure*" tag fail, promote the task as
# a failure. Only promote silent failures on mainline.
eval $run_promote_silent_failures
# Combine reliable and unreliable reports.
${python|/opt/mongodbtoolchain/v2/bin/python2} buildscripts/combine_reports.py -m -o report.json report_reliable.json report_unreliable.json
# We mask any errors from the resmoke runs above (by disabling errexit) until both have
# completed. If any of the resmoke runs failed due to non-test failures
# (i.e fixture failures), we need to exit with non-zero status.
if [ $reliable_exit_code -ne 0 ]; then
echo "resmoke.py reliable run failed with error code: $reliable_exit_code"
exit $reliable_exit_code
fi
# Ignoring the error code 1 that is returned when there are only silent failures.
if [ $unreliable_exit_code -ne 0 ] && [ $unreliable_exit_code -ne 1 ]; then
echo "resmoke.py unreliable run failed with error code: $unreliable_exit_code"
exit $unreliable_exit_code
fi
"do jepsen setup" :
- command: shell.exec
params:
working_dir: src
script: |
set -o errexit
# Build libfaketime. A version of libfaketime at least as new as v0.9.6-9-g75896bd is
# required to use the FAKETIME_NO_CACHE and FAKETIME_TIMESTAMP_FILE environment variables.
# Additionally, a version of libfaketime containing the changes mentioned in SERVER-29336
# is required to avoid needing to use libfaketimeMT.so.1 and serializing all calls to
# fake_clock_gettime() with a mutex.
git clone --branch=for-jepsen --depth=1 git@github.com:10gen/libfaketime.git
cd libfaketime
branch=$(git symbolic-ref --short HEAD)
commit=$(git show -s --pretty=format:"%h - %an, %ar: %s")
echo "Git branch: $branch, commit: $commit"
make PREFIX=$(pwd)/build/ LIBDIRNAME='.' install
# Add libfaketime to mongo-binaries.tgz so it gets uploaded to each of the LXC containers.
# The build/ prefix of the shared object will get removed when Jepsen extracts the tarball
# into the /opt/mongodb/ directory.
gzip --stdout --decompress ../mongo-binaries.tgz > mongo-binaries.tar
tar --append --file=mongo-binaries.tar build/libfaketime.so.1
gzip --stdout mongo-binaries.tar > ../mongo-binaries.tgz
- command: shell.exec
params:
working_dir: src
script: |
set -o errexit
git clone --branch=jepsen-mongodb-master --depth=1 git@github.com:10gen/jepsen.git jepsen-mongodb
cd jepsen-mongodb
branch=$(git symbolic-ref --short HEAD)
commit=$(git show -s --pretty=format:"%h - %an, %ar: %s")
echo "Git branch: $branch, commit: $commit"
lein install
- command: shell.exec
params:
working_dir: src
script: |
# On each LXC host do the following:
# Check to see if it's running, if not try to restart it.
# Copy the mongodb tarball to /root.
numVms=5
exit_failure_code=0
${set_sudo}
for i in $(seq 1 $numVms)
do
hostn=n$i
hostn_log=/var/log/lxc/$hostn.log
$sudo lxc-wait -n $hostn -s 'RUNNING' -t 0
lxc_code=$?
lxc_restarts=0
# If the LXC host is not running, try 5 times to start it.
while [ $lxc_code -ne 0 ]
do
lxc_restarts=$((lxc_restarts+1))
echo "Restarting host $hostn, attempt $lxc_restarts"
# When restarting, increase the logging level to INFO for the LXC log.
$sudo lxc-start -n $hostn --logpriority=INFO --logfile=$hostn_log -d
$sudo lxc-wait -n $hostn -s 'RUNNING' -t 60
lxc_code=$?
if [ $lxc_restarts -eq 5 ]; then
break
fi
done
scp -o ConnectTimeout=30 -o ConnectionAttempts=10 mongo-binaries.tgz root@$hostn:
exit_code=$?
# If the copy fails, then tail the LXC host log.
if [ $exit_code -ne 0 ]; then
echo "Copy to host $hostn failed!"
$sudo tail -n 100 $hostn_log
exit_failure_code=$exit_code
else
# Cleanup any existing logs from previous runs.
ssh root@$hostn "rm -f /root/mongod.log /root/stdout.log /opt/mongod/mongod.log /opt/mongod/stdout.log"
fi
done
exit $exit_failure_code
"run jepsen test" :
- command: shell.exec
type: test
timeout_secs: 2700 # Timeout test if there is no output for more than 45 minutes.
params:
working_dir: src/jepsen-mongodb
script: |
set -o verbose
start_time=$(date +%s)
lein run test --test ${jepsen_test_name} \
--tarball "file:///root/mongo-binaries.tgz" \
--ssh-private-key ~/.ssh/id_rsa_lxc \
--clock-skew faketime \
--libfaketime-path /opt/mongodb/libfaketime.so.1 \
${jepsen_key_time_limit} \
${jepsen_protocol_version} \
${jepsen_read_concern} \
${jepsen_read_with_find_and_modify} \
${jepsen_storage_engine} \
${jepsen_time_limit} \
${jepsen_write_concern} \
2>&1 \
| tee jepsen_${task_name}_${execution}.log
end_time=$(date +%s)
elapsed_secs=$((end_time-start_time))
# Since we cannot use PIPESTATUS to get the exit code from the "lein run ..." pipe in dash shell,
# we will check the output for success, failure or setup error. Note that 'grep' returns with exit code
# 0 if it finds a match, and exit code 1 if no match is found.
grep -q "Everything looks good" jepsen_${task_name}_${execution}.log
grep_exit_code=$?
if [ $grep_exit_code -eq 0 ]; then
status='"pass"'
failures=0
final_exit_code=0
else
grep -q "Analysis invalid" jepsen_${task_name}_${execution}.log
grep_exit_code=$?
if [ $grep_exit_code -eq 0 ]; then
status='"fail"'
failures=1
final_exit_code=1
else
# If the failure is due to setup, then this is considered a system failure.
echo $grep_exit_code > jepsen_system_failure_${task_name}_${execution}
exit 0
fi
fi
# Create report.json
echo "{\"failures\": $failures, \"results\": [{\"status\": $status, \"exit_code\": $final_exit_code, \"test_file\": \"${task_name}\", \"start\": $start_time, \"end\": $end_time, \"elapsed\": $elapsed_secs}]}" > ../report.json
exit $final_exit_code
- command: shell.exec
params:
working_dir: src/jepsen-mongodb
script: |
set -o verbose
# Jepsen system failure if file exists.
if [ -f jepsen_system_failure_${task_name}_${execution} ]; then
exit $(cat jepsen_system_failure_${task_name}_${execution})
fi
"run jstestfuzz":
- command: shell.exec
params:
working_dir: src
script: |
set -o errexit
set -o verbose
git clone git@github.com:10gen/jstestfuzz.git
cp mongodb*/bin/mongod .
- command: shell.exec
params:
working_dir: src
script: |
set -o errexit
set -o verbose
git clone --depth 1 git@github.com:10gen/mongo-enterprise-modules.git jstests/enterprise_tests
git clone --depth 1 git@github.com:10gen/QA.git jstests/qa_tests
- command: shell.exec
type: test
params:
working_dir: src/jstestfuzz
script: |
set -o errexit
set -o verbose
if [ "Windows_NT" = "$OS" ]; then
# An "npm" directory might not have been created in %APPDATA% by the Windows installer.
# Work around the issue by specifying a different %APPDATA% path.
# See: https://github.com/nodejs/node-v0.x-archive/issues/8141
export APPDATA=${workdir}/npm-app-data
export PATH="$PATH:/cygdrive/c/Program Files (x86)/nodejs" # Windows location
else
export PATH="$PATH:/opt/node/bin"
fi
echo "jstestfuzz self-tests are starting"
set +o errexit
npm test > npm_test-${task_id}.log 2>&1
if [ $? -ne 0 ]; then
which node
node --version
which npm
npm --version
cat npm_test-${task_id}.log
exit 1
fi
rm -f npm_test-${task_id}.log
set -o errexit
echo "jstestfuzz self-tests finished"
npm start -- --jsTestsDir ../jstests ${jstestfuzz_vars}
- command: archive.targz_pack
params:
target: "jstests.tgz"
source_dir: "src/jstestfuzz"
include:
- "out/*.js"
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: jstests.tgz
remote_file: mongodb-mongo-master/${build_variant}/${revision}/jstestfuzz/${task_id}-${execution}.tgz
bucket: mciuploads
permissions: public-read
content_type: ${content_type|application/x-gzip}
display_name: Generated Tests - Execution ${execution}
"run idl tests" :
- command: shell.exec
type: test
params:
working_dir: src
script: |
set -o verbose
set -o errexit
${python|/opt/mongodbtoolchain/v2/bin/python2} buildscripts/idl/run_tests.py
"do multiversion setup" :
command: shell.exec
params:
working_dir: src
script: |
set -o errexit
set -o verbose
rm -rf /data/install /data/multiversion
${python|/opt/mongodbtoolchain/v2/bin/python2} buildscripts/setup_multiversion_mongodb.py /data/install /data/multiversion ${multiversion_edition|"base"} ${multiversion_platform_arch|"linux/x86_64"} "3.0" "3.2" "3.4"
"do snmp setup" :
command: shell.exec
params:
working_dir: src
script: |
set -o errexit
set -o verbose
mkdir -p snmpconf
cp -f src/mongo/db/modules/enterprise/docs/mongod.conf.master snmpconf/mongod.conf
"do watchdog setup" :
command: shell.exec
params:
working_dir: src
script: |
set -o errexit
set -o verbose
bash src/mongo/db/modules/enterprise/jstests/watchdog/charybdefs_setup.sh
"cleanup environment" :
command: shell.exec
params:
script: |
set -o errexit
set -o verbose
rm -rf src /data/db/* mongo-diskstats* mongo-*.tgz ~/.aws
"kill processes" :
command: shell.exec
params:
silent: true
script: |
process_kill_list="(^cl\.exe$|bsondump|java|lein|lldb|mongo|python|_test$|_test\.exe$)"
# Exclude Evergreen agent processes and other system daemons
process_exclude_list="(main|tuned|evergreen)"
if [ "Windows_NT" = "$OS" ]; then
# Get the list of Windows tasks (tasklist list format):
# - Transpose the Image Name and PID
# - The first column has the process ID
# - The second column (and beyond) has task name
# - Grep for the task names of interest while ignoring any names that are in the exclude list
processes=$(tasklist /fo:csv | awk -F'","' '{x=$1; gsub("\"","",x); print $2, x}' | grep -i -E "$process_kill_list" | grep -i -v -E "$process_exclude_list")
# Kill the Windows process by process ID with force (/f)
kill_process () { pid=$(echo $1 | cut -f1 -d ' '); echo "Killing process $1"; taskkill /pid "$pid" /f; }
else
# Get the list of Unix tasks (pgrep full & long):
# - Grep for the task names of interest while ignoring any names that are in the exclude list
# - The first column has the process ID
# - The second column (and beyond) has task name
# There are 2 "styles" of grep, figure out which one works
grep=grep
echo "a" | $grep -qE "(a)" > /dev/null 2>&1
if [ $? -ne 0 ]; then
# Extended grep on Solaris is in the following location
grep=/usr/xpg4/bin/grep
if [ ! -f $grep ]; then
echo "Extended $grep does not exist"
return 1
fi
fi
# There are 2 "styles" of pgrep, figure out which one works.
# Due to https://bugs.launchpad.net/ubuntu/+source/procps/+bug/1501916
# we cannot rely on the return status ($?) to detect if the option is supported.
pgrep -f --list-full ".*" 2>&1 | $grep -qE "(illegal|invalid|unrecognized) option"
if [ $? -ne 0 ]; then
pgrep_list=$(pgrep -f --list-full "$process_kill_list")
else
pgrep_list=$(pgrep -f -l "$process_kill_list")
fi
# Since a process name might have a CR or LF in it, we need to delete any lines from
# pgrep which do not start with space(s) and 1 digit and trim any leading spaces.
processes=$(echo "$pgrep_list" | $grep -ivE "$process_exclude_list" | sed -e '/^ *[0-9]/!d; s/^ *//; s/[[:cntrl:]]//g;')
# Kill the Unix process ID with signal KILL (9)
kill_process () { pid=$(echo $1 | cut -f1 -d ' '); echo "Killing process $1"; kill -9 $pid; }
fi
# Since a full process name can have spaces, the IFS (internal field separator)
# should not include a space, just a LF & CR
IFS=$(printf "\n\r")
for process in $processes
do
kill_process "$process"
done
"set up kitchen credentials":
command: shell.exec
params:
silent: true
script: |
set -o errexit
mkdir -p ~/.ssh ~/.aws
echo -n "${kitchen_private_key}" > ~/.ssh/kitchen.pem
chmod 0600 ~/.ssh/kitchen.pem
cat <<EOF > ~/.aws/config
[default]
region = us-east-1
EOF
cat <<EOF > ~/.aws/credentials
[default]
aws_access_key_id = ${kitchen_aws_key}
aws_secret_access_key = ${kitchen_aws_secret}
EOF
"run kitchen":
command: shell.exec
type: test
params:
shell: bash
working_dir: src/buildscripts/package_test