Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ variables:
GRADLE_PLUGIN_PROXY: "https://depot-read-api-java.us1.ddbuild.io/magicmirror/magicmirror/@current/"
BUILDER_IMAGE_REPO: "registry.ddbuild.io/images/mirror/dd-trace-java-docker-build" # images are pinned in images/mirror.lock.yaml in the DataDog/images repo
BUILDER_IMAGE_VERSION_PREFIX: "ci-" # use either an empty string (e.g. "") for latest images or a version followed by a hyphen (e.g. "ci-" or "123_merge-")
TEST_COUNTS_S3_BUCKET: "dd-trace-java-ci-test-reports"
REPO_NOTIFICATION_CHANNEL: "#apm-java-escalations"
DEFAULT_TEST_JVMS: /^(8|11|17|21|25|tip)$/ # the latest "tip" version is 26
PROFILE_TESTS:
Expand Down Expand Up @@ -686,6 +687,11 @@ muzzle-dep-report:
- .gitlab/upload_ciapp.sh $CACHE_TYPE $testJvm
- gitlab_section_end "collect-reports"
- .gitlab/count_tests.sh "$GRADLE_TARGET" "$testJvm" "./results" "./test_counts_${CI_JOB_ID}.json"
- export TEST_COUNTS_S3_PREFIX="test-counts/${CI_PIPELINE_ID}"
- export TEST_COUNTS_FILE="./test_counts_${CI_JOB_ID}.json"
- export TEST_COUNTS_S3_URI="s3://${TEST_COUNTS_S3_BUCKET}/${TEST_COUNTS_S3_PREFIX}/test_counts_${CI_JOB_ID}.json"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Deduplicate retried test jobs before aggregating

When a test job is retried manually or by the template's retry: max: 2, the retry stays in the same CI_PIPELINE_ID but gets a new CI_JOB_ID, so this key leaves the first attempt's test_counts_<old job id>.json in the same S3 prefix while the retry uploads another file. The aggregate job then downloads every test_counts_*.json from that prefix, which double-counts tests and can preserve stale failed/zero-test attempts in the summary; use a stable per-job key that is overwritten by retries or filter to the latest attempt before aggregation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice finding... BTW
@bric3 WDYT? maybe we should use pipelineId + test name?
like: 1223456789_test_base: [17, 1/4] ?

Copy link
Copy Markdown
Contributor Author

@bric3 bric3 Jun 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YUp I saw that, I made a follow-up PR: #11580

- echo "Uploading ${TEST_COUNTS_FILE} to ${TEST_COUNTS_S3_URI}"
- aws s3 cp "$TEST_COUNTS_FILE" "$TEST_COUNTS_S3_URI" --only-show-errors
- URL_ENCODED_JOB_NAME=$(jq -rn --arg x "$CI_JOB_NAME" '$x|@uri')
- echo -e "${TEXT_BOLD}${TEXT_YELLOW}See test results in Datadog:${TEXT_CLEAR} https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40test.service%3Add-trace-java%20%40ci.pipeline.id%3A${CI_PIPELINE_ID}%20%40ci.job.name%3A%22${URL_ENCODED_JOB_NAME}%22"
artifacts:
Expand Down Expand Up @@ -918,9 +924,8 @@ test_smoke_semeru8_debugger:
aggregate_test_counts:
image: ${BUILDER_IMAGE_REPO}:${BUILDER_IMAGE_VERSION_PREFIX}base
stage: test-summary
# Note: No explicit 'needs' or 'dependencies' required
# By default, GitLab CI automatically downloads artifacts from ALL jobs in previous stages
# This job collects test_counts_*.json files from all test/check jobs via stage ordering
# Keep stage ordering, but prevent GitLab from downloading all previous-stage artifacts.
dependencies: []
rules:
- if: '$POPULATE_CACHE'
when: never
Expand All @@ -930,12 +935,20 @@ aggregate_test_counts:
when: on_success
- if: '$CI_COMMIT_BRANCH =~ /^gh-readonly-queue/'
when: on_success
- if: '$CI_COMMIT_BRANCH'
when: on_success
script:
- *set_datadog_api_keys
- .gitlab/aggregate_test_counts.sh
- export TEST_COUNTS_S3_PREFIX="test-counts/${CI_PIPELINE_ID}"
- mkdir -p ./test_counts_aggregate
- echo "Downloading test count files from s3://${TEST_COUNTS_S3_BUCKET}/${TEST_COUNTS_S3_PREFIX}/"
- aws s3 cp "s3://${TEST_COUNTS_S3_BUCKET}/${TEST_COUNTS_S3_PREFIX}/" ./test_counts_aggregate/ --recursive --exclude "*" --include "test_counts_*.json" --only-show-errors
- find ./test_counts_aggregate -name 'test_counts_*.json' -type f -print | sort
- .gitlab/aggregate_test_counts.sh ./test_counts_aggregate
artifacts:
when: always
paths:
- test_counts_aggregate/test_counts_*.json
- test_counts_summary.json
- test_counts_report.md

Expand Down
2 changes: 1 addition & 1 deletion .gitlab/aggregate_test_counts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ done <<-EOF # <<- strips leading tabs
EOF

# Find and validate test count files
mapfile -t VALID_FILES < <(find_and_validate_test_files "." "$OUTPUT_FILE")
mapfile -t VALID_FILES < <(find_and_validate_test_files "$AGGREGATE_DIR" "$OUTPUT_FILE")
if [ ${#VALID_FILES[@]} -eq 0 ]; then
exit 0
fi
Expand Down
Loading