forked from DataDog/dd-trace-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.continue.yml.j2
1342 lines (1164 loc) · 40.7 KB
/
config.continue.yml.j2
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
version: 2.1
defaults: &defaults
working_directory: ~/dd-trace-java
docker:
- image: &default_container << pipeline.parameters.docker_image >>:<< pipeline.parameters.docker_image_tag >>
test_matrix: &test_matrix
parameters:
testJvm:
{% for jdk in nocov_jdks %}
- "{{ jdk }}"
{% endfor %}
profiling_test_matrix: &profiling_test_matrix
parameters:
testJvm:
{% for jdk in all_jdks %}
- "{{ jdk }}"
{% endfor %}
debugger_test_matrix: &debugger_test_matrix
parameters:
testJvm:
{% for jdk in all_debugger_jdks %}
- "{{ jdk }}"
{% endfor %}
system_test_matrix: &system_test_matrix
parameters:
weblog-variant: [ 'spring-boot', 'spring-boot-jetty', 'spring-boot-openliberty', 'spring-boot-3-native', 'jersey-grizzly2', 'resteasy-netty3','ratpack', 'vertx3' ]
agent_integration_tests_modules: &agent_integration_tests_modules "dd-trace-core|communication|internal-api|utils"
core_modules: &core_modules "dd-java-agent|dd-trace-core|communication|internal-api|telemetry|utils|dd-java-agent/agent-bootstrap|dd-java-agent/agent-installer|dd-java-agent/agent-tooling|dd-java-agent/agent-builder|dd-java-agent/appsec|dd-java-agent/agent-crashtracking"
instrumentation_modules: &instrumentation_modules "dd-java-agent/instrumentation|dd-java-agent/agent-tooling|dd-java-agent/agent-installer|dd-java-agent/agent-builder|dd-java-agent/agent-bootstrap|dd-java-agent/appsec|dd-java-agent/testing|dd-trace-core|dd-trace-api|internal-api"
debugger_modules: &debugger_modules "dd-java-agent/agent-debugger|dd-java-agent/agent-bootstrap|dd-java-agent/agent-builder|internal-api|communication|dd-trace-core"
profiling_modules: &profiling_modules "dd-java-agent/agent-profiling"
default_system_tests_commit: &default_system_tests_commit 268c7ddfba2c45085dc29434e677ff13307445ef
parameters:
nightly:
type: boolean
default: false
weekly:
type: boolean
default: false
gradle_flags:
# Using no-daemon is important for the caches to be in a consistent state
type: string
default: "--stacktrace --no-daemon"
global_pattern:
# Pattern for files that should always trigger a test jobs
type: string
default: "^build.gradle$|^settings.gradle$|^gradle.properties$|^buildSrc/|^gradle/|.circleci"
docker_image:
type: string
default: ghcr.io/datadog/dd-trace-java-docker-build
docker_image_tag:
type: string
default: {{ docker_image_prefix }}base
commands:
check_for_leftover_files:
steps:
- run:
name: Check for leftover files
command: |
LEFTOVER_FILES=$(find . -type f -regex '.*\.orig$')
if [[ "$LEFTOVER_FILES" != "" ]]
then
echo -e "Found leftover files in the commit:\n$LEFTOVER_FILES"
exit 1
fi
generate_cache_ids:
steps:
- run:
name: Generate cache ids
command: |
# Everything falls back to the main cache
BASE_CACHE_ID="main"
if [ "$CIRCLE_BRANCH" == "master" ];
then
# If we're on a the main branch, then they are the same
echo "${BASE_CACHE_ID}" >| _circle_ci_cache_id
else
# If we're on a PR branch, then we use the name of the branch and the
# PR number as a stable identifier for the branch cache
echo "${CIRCLE_BRANCH}-${CIRCLE_PULL_REQUEST##*/}" >| _circle_ci_cache_id
fi
# Have new branches start from the main cache
echo "${BASE_CACHE_ID}" >| _circle_ci_cache_base_id
setup_code:
steps:
- checkout
- run:
name: Checkout merge commit
command: |
CCI_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"
if [[ "$CIRCLE_BRANCH" != "master" && -n "${CCI_PR_NUMBER}" ]]
then
FETCH_REFS="${FETCH_REFS} +refs/pull/${CCI_PR_NUMBER}/merge:refs/pull/${CCI_PR_NUMBER}/merge +refs/pull/${CCI_PR_NUMBER}/head:refs/pull/${CCI_PR_NUMBER}/head"
git fetch -u origin ${FETCH_REFS}
if git merge-base --is-ancestor $(git show-ref --hash refs/pull/${CCI_PR_NUMBER}/head) $(git show-ref --hash refs/pull/${CCI_PR_NUMBER}/merge); then
git checkout "pull/${CCI_PR_NUMBER}/merge"
else
echo "[WARN] There is a merge conflict between master and PR ${CCI_PR_NUMBER}, merge branch cannot be checked out."
git checkout "pull/${CCI_PR_NUMBER}/head"
fi
fi
- check_for_leftover_files
- generate_cache_ids
setup_testcontainers:
description: >-
Sets up remote docker and automatic port forwarding needed for docker on docker
version of Testcontainers.
steps:
- setup_remote_docker:
version: 20.10.18
# DLC shares Docker layers across jobs (at an extra cost).
# But its time to setup (~1min) exceeds the time required to prefetch all images we use.
docker_layer_caching: false
- run:
name: Prepare testcontainers environment
command: .circleci/prepare_docker_env.sh
- run:
name: Testcontainers tunnels
background: true
command: .circleci/start_docker_autoforward.sh
- run:
name: Prefetch Docker images
background: true
command: .circleci/fetch_docker_images.sh
early_return_for_forked_pull_requests:
description: >-
If this build is from a fork, stop executing the current job and return success.
This is useful to avoid steps that will fail due to missing credentials.
steps:
- run:
name: Early return if this build is from a forked PR
command: |
if [[ "$CIRCLE_BRANCH" != "master" && -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
skip_unless_matching_files_changed:
description: >-
If files matching the regular expression haven't changed in the commit, then skip the job
parameters:
pattern:
type: string
steps:
- run:
name: "Check if files relevant to job have changed"
command: |
CCI_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"
if [[ "$CIRCLE_BRANCH" != "master" && -n "$CCI_PR_NUMBER" ]]; then
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [[ "$BRANCH" != "master" ]] && [[ "$BRANCH" != "release/*" ]]; then
# We know that we have checked out the PR merge branch, so the HEAD commit is a merge
# As a backup, if anything goes wrong with the diff, the build will fail
CHANGED_FILES=$(git show HEAD | grep -e "^Merge:" | cut -d ' ' -f 2- | sed 's/ /.../' | xargs git diff --name-only)
# Count the number of matches, and ignore if the grep doesn't match anything
MATCH_COUNT=$(echo "$CHANGED_FILES" | grep -c -E "<< pipeline.parameters.global_pattern >>|<< parameters.pattern >>") || true
if [[ "$MATCH_COUNT" -eq "0" ]]; then
circleci step halt
fi
fi
fi
display_memory_usage:
steps:
- run:
name: Max Memory Used
# The file does not seem to exist when DLC is disabled
command: cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes || true
when: always
# The caching setup of the build dependencies is somewhat involved because of how CircleCI works.
# 1) Caches are immutable, so you can not reuse a cache key (the save will simply be ignored)
# 2) Cache keys are prefix matched, and the most recently updated cache that matches will be picked
#
# There is a weekly job that runs on Monday mornings that builds a new cache from scratch.
{% raw %}
restore_dependency_cache:
parameters:
cacheType:
type: string
steps:
- restore_cache:
keys:
# Dependent steps will find this cache
- dd-trace-java-dep<< parameters.cacheType >>-v4-{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ .Revision }}
# New branch commits will find this cache
- dd-trace-java-dep<< parameters.cacheType >>-v4-{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-
# New branches fall back on main build caches
- dd-trace-java-dep<< parameters.cacheType >>-v4-master-{{ checksum "_circle_ci_cache_base_id" }}-
# Fallback to the previous cache during transition
- dd-trace-java-dep<< parameters.cacheType >>-v3-master-{{ checksum "_circle_ci_cache_base_id" }}-
save_dependency_cache:
parameters:
cacheType:
type: string
steps:
- save_cache:
key: dd-trace-java-dep<< parameters.cacheType >>-v4-{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ .Revision }}
paths:
# Cached dependencies and wrappers for gradle
- ~/.gradle/caches
- ~/.gradle/wrapper
# Cached dependencies for maven
- ~/.m2
# Cached launchers and compilers for sbt
- ~/.sbt
# Cached dependencies for sbt handled by ivy
- ~/.ivy2
# Cached dependencies for sbt handled by coursier
- ~/.cache/coursier
restore_build_cache:
parameters:
cacheType:
type: string
steps:
- restore_cache:
keys:
# Dependent steps will find this cache
- dd-trace-java-build<< parameters.cacheType >>-v4-{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ .Revision }}
save_build_cache:
parameters:
cacheType:
type: string
steps:
- save_cache:
key: dd-trace-java-build<< parameters.cacheType >>-v4-{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ .Revision }}
paths:
# Gradle version specific cache for incremental builds. Needs to match version in
# gradle/wrapper/gradle-wrapper.properties
- ~/.gradle/caches/8.3
# Workspace
- ~/dd-trace-java/.gradle
- ~/dd-trace-java/workspace
{% endraw %}
setup_system_tests:
parameters:
systemTestsCommit:
type: string
default: *default_system_tests_commit
steps:
- generate_cache_ids
- restore_build_cache:
cacheType: lib
- run:
name: Install python 3.9
command: |
sudo apt-get install python3.9-full python3.9-dev python3.9-venv
echo 'export PATH="$HOME/.local/bin:$PATH"' >>"$BASH_ENV"
- run:
name: Clone system-tests
command: |
git init system-tests
cd system-tests
git remote add origin https://github.com/DataDog/system-tests.git
git fetch origin << parameters.systemTestsCommit >>
git reset --hard FETCH_HEAD
jobs:
build:
<<: *defaults
resource_class: xlarge
parameters:
gradleTarget:
type: string
cacheType:
type: string
collectLibs:
type: boolean
default: false
steps:
- setup_code
- restore_dependency_cache:
cacheType: << parameters.cacheType >>
- run:
name: Build Project
command: >-
MAVEN_OPTS="-Xms64M -Xmx256M"
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2G -Xms2G -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
./gradlew clean
<< parameters.gradleTarget >>
-PskipTests
<< pipeline.parameters.gradle_flags >>
--max-workers=8
--rerun-tasks
- when:
condition:
equal: [ true, << parameters.collectLibs >> ]
steps:
- run:
name: Collect Libs
when: always
command: .circleci/collect_libs.sh
- store_artifacts:
path: ./libs
- run:
name: Collect reports
when: on_fail
command: .circleci/collect_reports.sh --destination ./check_reports --move
- run:
name: Delete reports
when: on_success
command: .circleci/collect_reports.sh --destination ./check_reports --delete
- store_artifacts:
path: ./check_reports
# Save a full dependency cache when building on master or a base project branch.
# We used to do this on the first build of each PR, but now it's skipped at the
# cost of downloading new dependencies a few more times.
- when:
condition:
matches:
pattern: "^(master|project/.+)$"
value: << pipeline.git.branch >>
steps:
- save_dependency_cache:
cacheType: << parameters.cacheType >>
# Save the small build cache
- save_build_cache:
cacheType: << parameters.cacheType >>
- display_memory_usage
spotless:
<<: *defaults
resource_class: medium+
steps:
- setup_code
- run:
name: Run spotless
command: >-
JAVA_HOME=$JAVA_11_HOME
./gradlew spotlessCheck
<< pipeline.parameters.gradle_flags >>
--max-workers=8
check:
<<: *defaults
parameters:
parallelism:
type: integer
default: 1
gradleTarget:
type: string
cacheType:
type: string
resource_class: medium+
parallelism: << parameters.parallelism >>
steps:
- setup_code
- restore_dependency_cache:
cacheType: << parameters.cacheType >>
- restore_build_cache:
cacheType: << parameters.cacheType >>
- run:
name: Check Project
command: >-
MAVEN_OPTS="-Xms64M -Xmx256M"
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2G -Xms2G -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
./gradlew
<< parameters.gradleTarget >>
-PskipTests
-PrunBuildSrcTests
-PtaskPartitionCount=${CIRCLE_NODE_TOTAL} -PtaskPartition=${CIRCLE_NODE_INDEX}
<< pipeline.parameters.gradle_flags >>
--max-workers=8
- run:
name: Collect reports
when: on_fail
command: .circleci/collect_reports.sh --destination ./check_reports --move
- run:
name: Delete reports
when: on_success
command: .circleci/collect_reports.sh --destination ./check_reports --delete
- store_artifacts:
path: ./check_reports
- run:
name: Cancel workflow
when: on_fail
command: .circleci/cancel_workflow.sh
build_clean_cache:
<<: *defaults
parameters:
gradleTarget:
type: string
cacheType:
type: string
collectLibs:
type: boolean
default: false
resource_class: xlarge
steps:
- setup_code
- run:
name: Build Project
command: >-
MAVEN_OPTS="-Xms64M -Xmx256M"
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2G -Xms2G -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
./gradlew clean
<< parameters.gradleTarget >>
-PskipTests
<< pipeline.parameters.gradle_flags >>
--max-workers=8
--rerun-tasks
- when:
condition:
not:
equal: [true, << parameters.collectLibs >>]
steps:
- run:
name: Collect Libs
when: always
command: .circleci/collect_libs.sh
- store_artifacts:
path: ./libs
- save_dependency_cache:
cacheType: << parameters.cacheType >>
- display_memory_usage
tests: &tests
<<: *defaults
# since tests use test containers, they will use a Linux VM / Remote Docker executor, so there is no medium+ size
resource_class: large
docker:
- image: << pipeline.parameters.docker_image >>:{{ docker_image_prefix }}<< parameters.testJvm >>
parameters:
testJvm:
type: string
default: ""
maxDaemonHeapSize:
type: string
default: "2G"
gradleParameters:
type: string
default: ""
gradleTarget:
type: string
triggeredBy:
type: string
default: ".*"
stage:
type: string
default: ""
parallelism:
type: integer
default: 1
maxWorkers:
type: integer
default: 2
profile:
type: boolean
default: false
continueOnFailure:
type: boolean
default: false
cacheType:
type: string
parallelism: << parameters.parallelism >>
steps:
- setup_code
- skip_unless_matching_files_changed:
pattern: << parameters.triggeredBy >>
- restore_dependency_cache:
cacheType: << parameters.cacheType >>
- restore_build_cache:
cacheType: << parameters.cacheType >>
- when:
condition:
or:
- equal: ["core", << parameters.stage >>]
- equal: ["instrumentation", << parameters.stage >>]
- equal: ["smoke", << parameters.stage >>]
steps:
- setup_testcontainers
- run:
name: Run tests
command: >-
if [[ << parameters.profile >> ]] && [[ << parameters.testJvm >> != "ibm8" ]] && [[ << parameters.testJvm >> != "oracle8" ]];
then
PROFILER_COMMAND="-XX:StartFlightRecording=settings=profile,filename=/tmp/<< parameters.stage >>-<< parameters.testJvm >>.jfr,dumponexit=true"
fi
MAVEN_OPTS="-Xms64M -Xmx512M"
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xms<< parameters.maxDaemonHeapSize >> -Xmx<< parameters.maxDaemonHeapSize >> $PROFILER_COMMAND -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp' -Ddatadog.forkedMaxHeapSize=768M -Ddatadog.forkedMinHeapSize=128M"
./gradlew
<< parameters.gradleTarget >>
<< parameters.gradleParameters >>
-PtaskPartitionCount=${CIRCLE_NODE_TOTAL} -PtaskPartition=${CIRCLE_NODE_INDEX}
<<# parameters.testJvm >>-PtestJvm=<< parameters.testJvm >><</ parameters.testJvm >>
<< pipeline.parameters.gradle_flags >>
--max-workers=<< parameters.maxWorkers >>
--continue
<<# parameters.continueOnFailure >> || true <</ parameters.continueOnFailure >>
- run:
name: Collect reports
when: on_fail
command: .circleci/collect_reports.sh
- store_artifacts:
path: ./reports.tar
- when:
condition:
equal: [true, << parameters.profile >>]
steps:
- run:
name: Collect profiles
when: always
command: .circleci/collect_profiles.sh
- store_artifacts:
path: ./profiles.tar
- run:
name: Collect test results
when: always
command: .circleci/collect_results.sh
- store_test_results:
path: ./results
- display_memory_usage
- early_return_for_forked_pull_requests
- run:
name: Upload test results to Datadog
when: always
command: .circleci/upload_ciapp.sh << parameters.stage >> << parameters.testJvm >> || true
- run:
name: Get APM Test Agent Trace Check Results
when: always
command: |
set +e # Disable exiting from testagent response failure
SUMMARY_RESPONSE=$(curl -s -w "\n%{http_code}" -o summary_response.txt http://localhost:8126/test/trace_check/summary)
set -e
SUMMARY_RESPONSE_CODE=$(echo "$SUMMARY_RESPONSE" | awk 'END {print $NF}')
if [[ SUMMARY_RESPONSE_CODE -eq 200 ]]; then
echo "APM Test Agent is running. (HTTP 200)"
else
echo "APM Test Agent is not running and was not used for testing. No checks failed."
exit 0
fi
RESPONSE=$(curl -s -w "\n%{http_code}" -o response.txt http://localhost:8126/test/trace_check/failures)
RESPONSE_CODE=$(echo "$RESPONSE" | awk 'END {print $NF}')
if [[ $RESPONSE_CODE -eq 200 ]]; then
echo "All APM Test Agent Check Traces returned successful! (HTTP 200)"
echo "APM Test Agent Check Traces Summary Results:"
cat summary_response.txt | jq '.'
elif [[ $RESPONSE_CODE -eq 404 ]]; then
echo "Real APM Agent running in place of TestAgent, no checks to validate!"
else
echo "APM Test Agent Check Traces failed with response code: $RESPONSE_CODE"
echo "Failures:"
cat response.txt
echo "APM Test Agent Check Traces Summary Results:"
cat summary_response.txt | jq '.'
exit 1
fi
xlarge_tests:
<<: *tests
docker:
- image: << pipeline.parameters.docker_image >>:{{ docker_image_prefix }}<< parameters.testJvm >>
environment:
- CI_USE_TEST_AGENT=true
- image: ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.11.0
environment:
- LOG_LEVEL=DEBUG
- TRACE_LANGUAGE=java
- DD_SUPPRESS_TRACE_PARSE_ERRORS=true
- DD_POOL_TRACE_CHECK_FAILURES=true
- DD_DISABLE_ERROR_RESPONSES=true
- ENABLED_CHECKS=trace_content_length,trace_stall,meta_tracer_version_header,trace_count_header,trace_peer_service,trace_dd_service
resource_class: xlarge
# The only way to do fan-in in CircleCI seems to have a proper job, so let's have one that
# doesn't consume so many resources. The execution time for this including spin up seems to
# be around 6 seconds.
fan_in:
resource_class: small
docker:
- image: alpine
parameters:
testJvm:
type: string
default: "all configured JVMs"
stage:
type: string
steps:
- run:
name: Completed stage << parameters.stage >> on << parameters.testJvm >> passed!
command: echo '<< parameters.stage >> completed!'
agent_integration_tests:
<<: *tests
resource_class: medium
docker:
- image: << pipeline.parameters.docker_image >>:{{ docker_image_prefix }}8
- image: datadog/agent:7.34.0
environment:
- DD_APM_ENABLED=true
- DD_BIND_HOST=0.0.0.0
- DD_API_KEY=invalid_key_but_this_is_fine
test_published_artifacts:
<<: *defaults
resource_class: medium
docker:
- image: << pipeline.parameters.docker_image >>:{{ docker_image_prefix }}7
steps:
- setup_code
- restore_dependency_cache:
cacheType: lib
- restore_build_cache:
cacheType: lib
- run:
name: Publish Artifacts Locally
command: |
mvn_local_repo=$(./mvnw help:evaluate -Dexpression=settings.localRepository -q -DforceStdout)
rm -rf "${mvn_local_repo}/com/datadoghq"
export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2G -Xms2G -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
./gradlew publishToMavenLocal << pipeline.parameters.gradle_flags >> --max-workers=3
- run:
name: Test Published Artifacts
command: |
cd test-published-dependencies
export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx512M -Xms512M -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
./gradlew check --info --max-workers=3
- run:
name: Collect Reports
when: on_fail
command: .circleci/collect_reports.sh
- store_artifacts:
path: ./reports
- display_memory_usage
muzzle-dep-report:
<<: *defaults
resource_class: medium
steps:
- setup_code
- skip_unless_matching_files_changed:
pattern: "dd-java-agent/instrumentation"
- restore_dependency_cache:
cacheType: inst
- restore_build_cache:
cacheType: inst
- run:
name: Generate muzzle dep report
command: >-
SKIP_BUILDSCAN="true"
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2G -Xms2G -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
./gradlew generateMuzzleReport muzzleInstrumentationReport
- run:
name: Collect Reports
command: .circleci/collect_muzzle_deps.sh
- store_artifacts:
path: ./reports
muzzle:
<<: *defaults
resource_class: medium
parallelism: 3
steps:
- setup_code
- skip_unless_matching_files_changed:
pattern: "dd-java-agent/instrumentation"
# We are not running with a separate cache of all muzzle artifacts here because it gets very big and
# ends up taking more time restoring/saving than the actual increase in time it takes just
# downloading the artifacts each time.
#
# Let's at least restore the build cache to have something to start from.
- restore_dependency_cache:
cacheType: inst
- restore_build_cache:
cacheType: inst
- run:
name: Gather muzzle tasks
command: >-
SKIP_BUILDSCAN="true"
./gradlew writeMuzzleTasksToFile
<< pipeline.parameters.gradle_flags >>
--max-workers=3
- run:
name: Verify Muzzle
command: >-
SKIP_BUILDSCAN="true"
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2G -Xms2G -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
./gradlew `circleci tests split --split-by=timings workspace/build/muzzleTasks | xargs`
<< pipeline.parameters.gradle_flags >>
--max-workers=4
- run:
name: Collect Reports
when: on_fail
command: .circleci/collect_reports.sh
- store_artifacts:
path: ./reports
- store_test_results:
path: workspace/build/muzzle-test-results
- display_memory_usage
system-tests:
machine:
# https://support.circleci.com/hc/en-us/articles/360007324514-How-can-I-use-Docker-volume-mounting-on-CircleCI-
image: ubuntu-2004:current
resource_class: medium
parameters:
weblog-variant:
type: string
steps:
- setup_system_tests
- run:
name: Copy jar file to system test binaries folder
command: |
ls -la ~/dd-trace-java/workspace/dd-java-agent/build/libs
cp ~/dd-trace-java/workspace/dd-java-agent/build/libs/*.jar system-tests/binaries/
- run:
name: Build
command: |
cd system-tests
./build.sh java --weblog-variant << parameters.weblog-variant >>
- run:
name: Run
command: |
cd system-tests
DD_API_KEY=$SYSTEM_TESTS_DD_API_KEY ./run.sh
- run:
name: Run APM E2E default tests
# Stop the job after 5m to avoid excessive overhead. Will need adjustment as more tests are added.
no_output_timeout: 5m
command: |
cd system-tests
DD_SITE=datadoghq.com DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY ./run.sh APM_TRACING_E2E
- run:
name: Run APM E2E Single Span tests
# Stop the job after 5m to avoid excessive overhead. Will need adjustment as more tests are added.
no_output_timeout: 5m
command: |
cd system-tests
DD_SITE=datadoghq.com DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY ./run.sh APM_TRACING_E2E_SINGLE_SPAN
- run:
name: Upload data to CI Visibility
command: |
cd system-tests
export DD_API_KEY=$SYSTEM_TESTS_CI_API_KEY
export DD_APP_KEY=$SYSTEM_TESTS_CI_APP_KEY
# Causes conflicts with DD_API_KEY and datadog-ci tool
unset DATADOG_API_KEY
echo "Uploading tests results to CI Visibility"
utils/scripts/upload_results_CI_visibility.sh dev java-tracer << pipeline.id >>-<< pipeline.number >>
if [[ $CIRCLE_BRANCH == "master" ]]; then
echo "Updating dashboard from dd-trace-java main branch"
utils/scripts/update_dashboard_CI_visibility.sh java-tracer << pipeline.id >>-<< pipeline.number >>
else
echo "Skipping CI Visibility dashboard update due to it is not a main branch"
fi
- run:
name: Collect artifacts
command: tar -cvzf logs_java_<< parameters.weblog-variant >>_dev.tar.gz -C system-tests logs logs_apm_tracing_e2e logs_apm_tracing_e2e_single_span
- store_artifacts:
path: logs_java_<< parameters.weblog-variant >>_dev.tar.gz
integrations-system-tests:
machine:
# https://support.circleci.com/hc/en-us/articles/360007324514-How-can-I-use-Docker-volume-mounting-on-CircleCI-
image: ubuntu-2004:current
resource_class: medium
steps:
- setup_system_tests
- run:
name: Copy jar file to system test binaries folder
command: |
ls -la ~/dd-trace-java/workspace/dd-java-agent/build/libs
cp ~/dd-trace-java/workspace/dd-java-agent/build/libs/*.jar system-tests/binaries/
- run:
name: Build
# Build the default framework, which is springboot
command: |
cd system-tests
./build.sh java
- run:
name: Run APM Integrations tests
# Stop the job after 5m to avoid excessive overhead. Will need adjustment as more tests are added.
no_output_timeout: 5m
command: |
cd system-tests
DD_SITE=datadoghq.com DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY ./run.sh INTEGRATIONS
- store_test_results:
path: system-tests/logs_integrations
- store_artifacts:
path: system-tests/logs_integrations
parametric-tests:
machine:
# https://support.circleci.com/hc/en-us/articles/360007324514-How-can-I-use-Docker-volume-mounting-on-CircleCI-
image: ubuntu-2004:current
resource_class: large
steps:
- setup_system_tests
- run:
name: Copy jar files to system test binaries folder
command: |
ls -la ~/dd-trace-java/workspace/dd-trace-api/build/libs
ls -la ~/dd-trace-java/workspace/dd-java-agent/build/libs
cp ~/dd-trace-java/workspace/dd-trace-api/build/libs/*.jar system-tests/binaries/
cp ~/dd-trace-java/workspace/dd-java-agent/build/libs/*.jar system-tests/binaries/
- run:
name: Install requirements
command: |
cd system-tests
pyenv local system
python3.9 --version
python3.9 -m pip install wheel
python3.9 -m pip install -r requirements.txt
sudo ln -sf /usr/bin/python3.9 /usr/bin/python
- run:
name: Run
command: |
set -e
cd system-tests
export TEST_LIBRARY=java
export PYTEST_WORKER_COUNT=8
./build.sh -i runner
./run.sh PARAMETRIC --log-cli-level=DEBUG --durations=30 -vv
- store_test_results:
path: system-tests/logs_parametric
- run:
name: Collect artifacts
command: tar -cvzf logs_java_parametric_dev.tar.gz -C system-tests logs_parametric
- store_artifacts:
path: logs_java_parametric_dev.tar.gz
build_test_jobs: &build_test_jobs
- build:
name: build_lib
gradleTarget: shadowJar
cacheType: lib
collectLibs: true
- build:
name: build_base
gradleTarget: :baseTest
cacheType: base
- build:
name: build_inst
gradleTarget: :instrumentationTest
cacheType: inst
- build:
name: build_latestdep
gradleTarget: :instrumentationLatestDepTest
cacheType: latestdep
- build:
name: build_smoke
gradleTarget: :smokeTest
cacheType: smoke
- build:
name: build_profiling
gradleTarget: :profilingTest
cacheType: profiling
- spotless
- fan_in:
requires:
- build_lib
- build_base
- build_inst
- build_smoke
- build_profiling
- spotless
name: ok_to_test
stage: ok_to_test
- check:
requires:
- ok_to_test
name: check_base
gradleTarget: ":baseCheck"
cacheType: base
- check:
requires:
- ok_to_test
name: check_inst
parallelism: 4