Skip to content

Commit e9f42d8

Browse files
authored
chore(ci): add final_status property on junit XML [APMSP-2610] (#178)
### What does this PR do? Add a `<property name="dd_tags[test.final_status]" value="pass" />` on every test case reported through junit Also updated system-tests SHA, the used one was very old, and the support for `final_status` in system-tests has been introduced recently ### Motivation Some repositories intentionally use mechanisms that ignore test failures (there are valid reasons to still execute those tests behind the scenes). In these cases, the reported test status cannot be relied upon by Test Optimization to monitor repository health or trigger team notifications. To ensure a consistent and unified approach, we will instead use final_status — the property specifically designed and used by the Test Optimization integration for this purpose. # how to test it ? Now more `N/A` on the last commit on this [query](https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40git.repository.id_v2%3A%2A%2Fdd-trace-rs%20%40git.branch%3Acbeauchesne%2Ffinal_status%20%40git.commit.sha%3A01dfca97ce3335fb9f346225888329ef3b1f68d8&agg_m=%40test.full_name&agg_m_source=base&agg_q=%40test.final_status&agg_q_source=base&agg_t=cardinality&currentTab=overview&eventStack=&fromUser=false&index=citest&sort_m=count&sort_m_source=base&sort_t=count&top_n=10&top_o=top&viz=timeseries&x_missing=false&start=1772906562779&end=1773165762779&paused=false) # Additional Notes I'm using the not-that-ideal XSLT here as this change, because it must be done over [17+ repos](https://datadoghq.atlassian.net/browse/APMSP-2610), and it's a workaround until this gets integrated into a better place, such as datadog-ci or the backend. We're trying to work with the team on this, please have a look on this [RFC](https://docs.google.com/document/d/1OaX_h09fCXWmK_1ADrwvilt8Yt5h4WjC7UUAdS3Y3uw/edit?pli=1&tab=t.0#heading=h.tfy5viz7rz2) for more context.
1 parent f51cefc commit e9f42d8

2 files changed

Lines changed: 62 additions & 2 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3+
4+
<!-- Identity transform: copy everything as-is by default -->
5+
<xsl:template match="@*|node()">
6+
<xsl:copy>
7+
<xsl:apply-templates select="@*|node()"/>
8+
</xsl:copy>
9+
</xsl:template>
10+
11+
<!-- For testcase elements missing dd_tags[test.final_status] inside their properties block -->
12+
<xsl:template match="testcase[not(properties/property[@name='dd_tags[test.final_status]'])]">
13+
<xsl:copy>
14+
<xsl:apply-templates select="@*"/>
15+
<xsl:variable name="status">
16+
<xsl:choose>
17+
<xsl:when test="failure or error">fail</xsl:when>
18+
<xsl:when test="skipped">skip</xsl:when>
19+
<xsl:otherwise>pass</xsl:otherwise>
20+
</xsl:choose>
21+
</xsl:variable>
22+
<xsl:choose>
23+
<xsl:when test="properties">
24+
<!-- Inject into existing properties block, preserving child order -->
25+
<xsl:for-each select="node()">
26+
<xsl:choose>
27+
<xsl:when test="self::properties">
28+
<properties>
29+
<xsl:apply-templates select="@*|node()"/>
30+
<property name="dd_tags[test.final_status]" value="{$status}"/>
31+
</properties>
32+
</xsl:when>
33+
<xsl:otherwise>
34+
<xsl:apply-templates select="."/>
35+
</xsl:otherwise>
36+
</xsl:choose>
37+
</xsl:for-each>
38+
</xsl:when>
39+
<xsl:otherwise>
40+
<!-- No properties block: create one before other children -->
41+
<properties>
42+
<property name="dd_tags[test.final_status]" value="{$status}"/>
43+
</properties>
44+
<xsl:apply-templates select="node()"/>
45+
</xsl:otherwise>
46+
</xsl:choose>
47+
</xsl:copy>
48+
</xsl:template>
49+
50+
</xsl:stylesheet>

.github/workflows/test.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ jobs:
7575
report_paths: "target/nextest/ci/junit.xml"
7676
check_name: "[${{ matrix.platform }}:${{ matrix.rust_version }}] test report"
7777
include_passed: true
78+
- name: Add final_status property
79+
if: success() || failure()
80+
shell: bash
81+
run: |
82+
which xsltproc || sudo apt-get install -y xsltproc
83+
xml_file="target/nextest/ci/junit.xml"
84+
echo "Fixing $xml_file"
85+
tmp_file="$(mktemp)"
86+
xsltproc --output "$tmp_file" ".github/workflows/add_final_status.xsl" "$xml_file"
87+
mv "$tmp_file" "$xml_file"
7888
- name: Upload test results to Datadog
7989
if: success() || failure()
8090
shell: bash
@@ -165,13 +175,13 @@ jobs:
165175
parametric:
166176
needs:
167177
- build-artifacts
168-
uses: DataDog/system-tests/.github/workflows/run-parametric.yml@bafc8bc606d76170d98ce3cdb13c75a1ea9cf924 # main
178+
uses: DataDog/system-tests/.github/workflows/run-parametric.yml@93283b322c59ecf7267c28c06648d341be75eded # main
169179
secrets:
170180
TEST_OPTIMIZATION_API_KEY: ${{ secrets.DATADOG_API_KEY }}
171181
with:
172182
library: rust
173183
binaries_artifact: system_tests_binaries
174184
job_count: 2
175185
job_matrix: '[1,2]'
176-
ref: 8a65f66d74ca77f34e7e5a2f737e963ce9cec563 # main
186+
ref: 93283b322c59ecf7267c28c06648d341be75eded # main
177187
push_to_test_optimization: true

0 commit comments

Comments
 (0)