Skip to content

Separate test results from Jenkins job status - #7945

Open
sophia-guo wants to merge 67 commits into
adoptium:masterfrom
sophia-guo:separateResult
Open

sophia-guo wants to merge 67 commits into
adoptium:masterfrom
sophia-guo:separateResult

Conversation

@sophia-guo

@sophia-guo sophia-guo commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

env.testStatus is the test-only outcome. env.jobStatus is the Jenkins job outcome.

Close #7746

Copilot AI balanced review requested due to automatic review settings November 13, 2026 20:19
@sophia-guo
sophia-guo marked this pull request as draft November 13, 2026 20:19

Copilot AI left a comment

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.

🟡 Changes recommended

Critical status-handling defects can report unrun tests as successful, bypass infrastructure-error handling, and exclude failed test jobs from reruns.

6 open issues
What changed in this PR

This PR introduces separate test-outcome tracking in AQA’s Jenkins pipelines, aiming to distinguish test results from infrastructure-related job failures.

Changes:

  • Tracks test status separately through execution, child-job aggregation, and rerun decisions.
  • Adds separate test and job badges to build descriptions.
  • Adds infrastructure-failure annotations and early-failure status reporting.
File Description
buildenv/​jenkins/​openjdk_tests Initializes test status and updates exception reporting and rerun orchestration.
buildenv/​jenkins/​JenkinsfileBase Adds test-status tracking, aggregation, rerun handling, and status-display helpers.
buildenv/​jenkins/​aqaTestPipeline.groovy Displays downstream test-status badges alongside Jenkins job badges.

Review effort: Balanced

Comment thread buildenv/jenkins/JenkinsfileBase Resolved
Comment thread buildenv/jenkins/JenkinsfileBase Resolved
Comment thread buildenv/jenkins/JenkinsfileBase Resolved
Comment thread buildenv/jenkins/openjdk_tests Resolved
Comment thread buildenv/jenkins/JenkinsfileBase Resolved
Comment thread buildenv/jenkins/aqaTestPipeline.groovy Resolved
… failures

- Add env.testStatus to track pure test outcome independently of env.jobStatus
  (env.jobStatus = worst(env.testStatus, any infra failure))
- Set env.testStatus at all test-outcome sites: makeTest() catch,
  checkTestResults(), runTest() no-result check
- archiveChildJobTap(): read child testStatus via getBuildVariables()["testStatus"]
  (fallback to getCurrentResult()) so parent aggregates test outcomes separately
  from Jenkins build results; return testStatus in result map
- openjdk_tests catch block: stop hardcoding FAILURE; degrade env.jobStatus to
  FAILURE only if not already worse, set currentBuild.result = env.jobStatus so
  a post-test cleanWs failure cannot promote SUCCESS tests to FAILURE result
- All currentBuild.result assignment sites now call annotateInfraFailure() which
  adds a visible badge when jobStatus > testStatus so the cause is clear on the
  build page; badge fires at every terminal path (normal, rerun, parallel, catch)
- Rerun trigger and parallel guard in openjdk_tests use env.testStatus so infra
  failures do not incorrectly suppress or trigger reruns
- addFailedTestsGrinderLink() uses env.testStatus so rerun links are only shown
  for actual test failures
Previously FlowInterruptedException was handled in a separate branch that
exited before calling annotateInfraFailure, so no badge was written when
a manual abort (or timeout) hit during the post stage after tests passed.

Fix: merge both branches — all exceptions go through the same logic:
- ITER_COUNT == 0 guard: if no test results were collected, testStatus is
  the initialisation default 'SUCCESS' which is not meaningful; null it so
  annotateInfraFailure does not falsely claim tests passed
- infraStatus = ABORTED (FlowInterruptedException) or FAILURE (others)
- env.jobStatus degraded only if infraStatus is worse (isWorseThan semantics)
- currentBuild.result = env.jobStatus
- annotateInfraFailure(testStatus, jobStatus) — fires badge only when
  jobStatus is worse than testStatus (already enforced inside the function)
Always append TEST STATUS to the test results summary badge so the
pure test outcome is visible on every build regardless of job status.
Prepend TEST STATUS to currentBuild.description at the start of post()
so it appears first in the build description panel, above the existing
TARGET: / LABEL: / node lines.

Removed TEST STATUS from writeSummary() badge (added in previous commit)
to avoid duplication — the description panel is the more prominent location.
Replace plain-text TEST STATUS with a coloured badge image rendered via
the embeddable-build-status-plugin endpoint on this Jenkins instance:
  passing   (brightgreen) — testStatus SUCCESS
  unstable  (yellow)      — testStatus UNSTABLE
  failing   (red)         — testStatus FAILURE
  aborted   (lightgrey)   — testStatus ABORTED

Add getResultBadgeUrl() helper to JenkinsfileBase (mirrors the same
helper already present in aqaTestPipeline.groovy).
The previous badge showed 'build | unstable' with a grey left section.
Replaced with a value-only SVG pill that shows just the coloured status
word (passing / unstable / failing / aborted) with no label part.
Changed from prepend (top of description) to append-at-post-start so
the order is: TARGET → LABEL → node → TEST STATUS → artifact/rerun links
…ption

1. archiveChildJobTap(): add 'Test Status' column to the child job table
   showing getTestStatusBadge(childTestResult) for each child — separate
   from the Jenkins job status badge in the Status column

2. post() and archiveChildJobTap(): render TEST STATUS with bold + slightly
   larger font so it stands out above TARGET/LABEL/node in the description

3. archiveChildJobTap(): prepend TEST STATUS header to parent job description
   (previously only post() did this, so parent parallel jobs never showed it)
…hiveChildJobTap

- Remove style='font-size:1.1em' — Jenkins XSS filter strips style attributes
  from currentBuild.description; use plain <b> instead
- archiveChildJobTap: move description write to after currentTestStatus is
  finalised (after clamping to originalStatus and env.testStatus assignment)
  so the badge always reflects the correct aggregated test status
Jenkins XSS sanitizer strips data: URIs from currentBuild.description,
causing the <img> tag to silently vanish and breaking the surrounding
HTML — which made the child job table disappear entirely.

Replace getTestStatusBadge() (SVG/base64) with getTestStatusLabel()
which returns <font color='...'><b>STATUS</b></font> — safe HTML that
Jenkins allows in build descriptions.

Colors: green=SUCCESS, dark-gold=UNSTABLE, red=FAILURE, grey=ABORTED
…d table

1. getTestStatusLabel(): add icon prefix (✔/⚠/✘/⊘) and <big> for larger
   font — TEST STATUS line is now more prominent in the description

2. Child job table Test Status cell: append grey small-text note
   '⚠ job degraded to ABORTED' when child jobStatus > testStatus,
   so infra failures on children are visible per-row

3. annotateInfraFailure() summary badge: use getTestStatusLabel() for
   coloured status text and bold jobStatus in the warning message
Replace plain text test status with a proper pill badge using the same
embeddable-build-status-plugin endpoint, using subject=tests so it renders
as 'tests|passing' in the same style as 'build|passing'.

Each job line now shows: tests|<status>  build|<status>
Previously the fallback was downstreamJobResult, meaning an infra failure
(ABORTED job, tests passed) would show tests|aborted instead of the real
test outcome. Fall back to NOT_BUILT instead so the badge is explicit
when testStatus was not set by JenkinsfileBase.
…stPipeline style

- Add getTestStatusBadgeUrl() to JenkinsfileBase (mirrors aqaTestPipeline version)
  renders 'tests|passing' pill via embeddable-build-status-plugin endpoint
- Move Test Status column before Status column
- Replace colored text label with pill badge image in Test Status cell
- Keep infra degradation note below the badge when job status > test status
…failure

- Initialize env.testStatus = 'NOT_BUILT' at the top of runTest() in
  openjdk_tests, before the git clone / checkout. Jobs that fail before
  setupEnv() now export a defined testStatus via build variables instead
  of null, so getTestStatusBadgeUrl() shows 'tests|not_run' rather than
  'tests|unknown'.

- Add 'NOT_BUILT' entry to getTestStatusLabel() styleMap (grey, em-dash
  icon) so the label renders cleanly instead of falling through to '?'.

- In archiveChildJobTap(), guard cjob.getCurrentResult() and the
  getBuildVariables()["testStatus"] fallback with ?: 'NOT_BUILT' so
  very-early-aborted child jobs never produce null in either variable.

- In the openjdk_tests catch block, prepend 'TEST STATUS: ...' to
  currentBuild.description when post() was never reached (i.e. the
  exception was thrown before testExecution() ran). Uses
  jenkinsfile.getTestStatusLabel() when the library is loaded, or an
  inline plain-font fallback when jenkinsfile is still null. A
  contains('TEST STATUS:') guard prevents double-writing when cleanWs
  throws after post() already ran.
Jenkins env variables are always strings. Assigning null to env.testStatus
produces the literal string "null", which is truthy in Groovy's Elvis
operator and boolean context, causing:
  - post() / catch block to call getTestStatusLabel("null") -> '? null'
  - aqaTestPipeline / archiveChildJobTap to call getTestStatusBadgeUrl("null")
    -> 'tests|unknown'

Fix:
- openjdk_tests catch block: replace env.testStatus = null with
  env.testStatus = 'NOT_BUILT' so setupEnv()-ran-but-no-tests case is
  represented by a valid status value, not the string "null".
- aqaTestPipeline.groovy: add explicit rawTestStatus != 'null' guard
  when reading getBuildVariables()["testStatus"] so legacy builds that
  exported the string "null" still fall back to 'NOT_BUILT'.
- JenkinsfileBase archiveChildJobTap: same "null" string guard for
  child job testStatus reads.
The local copy of getTestStatusBadgeUrl in aqaTestPipeline.groovy was
missing the 'NOT_BUILT' entry, causing jobs that failed before setupEnv()
(which now export testStatus='NOT_BUILT') to still render as
'tests|unknown' in the aqaTestPipeline view.

Add 'NOT_BUILT': [text: 'not_run', color: 'lightgrey'] to match the
identical entry already present in JenkinsfileBase.
Align the leaf job description with the aqaTestPipeline badge text.
getTestStatusBadgeUrl already rendered NOT_BUILT as 'not_run'; the
description label was showing the raw 'NOT_BUILT' string instead.

Add a 'label' field to the styleMap so NOT_BUILT renders as
'— not_run' in TEST STATUS descriptions, matching the badge pill.
Other statuses are unaffected (their label equals their status key).
Add getTestStatusDescription() which combines the pill badge image
(<img src='tests|passing'>) with the coloured bold text label, giving
the leaf job description the same visual style as the aqaTestPipeline
view.

Switch post(), archiveChildJobTap() parent header, and the openjdk_tests
catch block from getTestStatusLabel() to getTestStatusDescription() for
currentBuild.description writes. annotateInfraFailure() summary badge
keeps getTestStatusLabel() (plain text is more appropriate there).
The badge already shows 'tests|unstable' etc. — the additional
coloured text label is redundant. Keep only the <img> pill badge
in getTestStatusDescription().
…ing inline

Three changes:
1. Rename 'TEST STATUS' -> 'TEST EXECUTE STATUS' in all description
   writes, guards, summary badges, and echo/log messages.
2. Rename child job table headers: 'Test Status' -> 'Test Execute Status',
   'Status' -> 'Jenkins Job Status'.
3. getTestStatusDescription() now accepts an optional jobStatus param;
   when jobStatus is worse than testStatus it appends
   '⚠ job degraded to X' inline after the pill badge — so the warning
   appears directly in the TEST EXECUTE STATUS line rather than only
   in the separate annotateInfraFailure summary badge.
Add echo/println after every currentBuild.description write that sets
the TEST EXECUTE STATUS header, so the status is visible in the
console log:
- post() in JenkinsfileBase (leaf job normal path)
- archiveChildJobTap() in JenkinsfileBase (parent/parallel job)
- catch block in openjdk_tests (early failure path)

annotateInfraFailure() already had an echo; no change needed there.
Use &nbsp; entities to add horizontal spacing after each column header
so 'Test Execute Status' and 'Jenkins Job Status' are not cramped.
Also bold all headers for consistency. Avoids style= attributes which
Jenkins XSS sanitizer strips from currentBuild.description.
…ob->Job Status; fix leaf job infra warning

1. Table column headers only: 'Test Execute Status'->'Test Status',
   'Jenkins Job Status'->'Job Status'. All 'TEST EXECUTE STATUS' strings
   in descriptions, echo, summary badges remain unchanged.

2. Fix leaf job description missing infra warning:
   post() runs in testExecution()'s finally before openjdk_tests' catch
   block degrades env.jobStatus, so the warning could not be added at
   post() time. annotateInfraFailure() now also patches the existing
   TEST EXECUTE STATUS line in currentBuild.description by replacing
   the plain badge HTML with badge + warning HTML, making the inline
   warning appear on both leaf and parent job descriptions.

Copilot AI left a comment

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.

🔵 Needs a closer look

Infrastructure failures and aborts still overwrite test-only outcomes, producing misleading test badges instead of remaining isolated in jobStatus.

3 open issues
5 previously missed issues

In code that hasn't changed since last review

Medium severity Keep setup failures separate from test results

buildenv/​jenkins/​JenkinsfileBase:63

This catch also handles failures from the initial testEnvTeardown command and credential setup, before makeTestCmd runs. Marking those exceptions UNSTABLE records a test failure without any test result, and a later passing iteration cannot clear it. Set testStatus from collected test results and retain incomplete-run states when results are missing; record setup/command failures separately in jobStatus.

Medium severity Restore jobStatus with the original build result

buildenv/​jenkins/​JenkinsfileBase:1839

archiveChildJobTap has already overwritten env.jobStatus with the rerun result. For OpenJ9/IBM, this branch restores only currentBuild.result to originalJobStatus, leaving the exported jobStatus inconsistent with Jenkins (for example SUCCESS after a successful rerun while the job remains UNSTABLE). Restore env.jobStatus alongside the Jenkins result so consumers receive the actual job outcome.

Medium severity Do not infer test failures from child job results

buildenv/​jenkins/​JenkinsfileBase:1912

Converting NOT_RUN/NOT_FINISHED into FAILURE or ABORTED makes an infrastructure-only child failure contaminate the parent's testStatus again. It also labels an older successful child that does not export testStatus as a test failure, because the fallback above is NOT_RUN. Preserve unavailable/incomplete test outcomes separately and aggregate them explicitly rather than deriving a test failure from the Jenkins result.

Medium severity Preserve exported test status on infrastructure failures

buildenv/​jenkins/​aqaTestPipeline.groovy:361

A downstream checkout failure can legitimately export NOT_RUN, and an interrupted test run can export NOT_FINISHED. Replacing those values with the Jenkins FAILURE/ABORTED result makes the tests badge report an infrastructure failure as a test failure, contrary to the new test-only contract. Pass the exported test status through unchanged; the adjacent job badge already displays the infrastructure outcome.

Medium severity Export queue and node acquisition failures to jobStatus

buildenv/​jenkins/​openjdk_tests:339

A queue timeout or abort still exports jobStatus=SUCCESS. Node acquisition and the active-node timeout occur outside runTest(), so their exceptions never reach the catch block that updates jobStatus; initializing these variables does not cover that boundary. Wrap the queue/node-acquisition path in exception/finalization handling that exports FAILURE or ABORTED while preserving testStatus=NOT_RUN, including when JenkinsfileBase has not been loaded.

4 resolved since last review

Review effort: Balanced

Copilot AI left a comment

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.

🔵 Needs a closer look

Human assessment is needed because intertwined status aggregation and rerun behavior can misclassify or hide infrastructure failures and export inconsistent job outcomes.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@sophia-guo
sophia-guo marked this pull request as ready for review November 25, 2026 20:14
@sophia-guo

Copy link
Copy Markdown
Contributor Author

Some tests see #7746

Copilot AI left a comment

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.

🟡 Changes recommended

Status-handling defects can leave Jenkins reporting success despite missing iteration summaries, mask infrastructure failures during reruns, and incorrectly select children with passing tests for reruns.

6 open issues

Review effort: Balanced

Comment thread buildenv/jenkins/JenkinsfileBase Resolved
Comment thread buildenv/jenkins/JenkinsfileBase Resolved
Comment thread buildenv/jenkins/JenkinsfileBase Resolved
Comment thread buildenv/jenkins/JenkinsfileBase Resolved
Comment thread buildenv/jenkins/JenkinsfileBase Resolved
Comment thread buildenv/jenkins/openjdk_tests Resolved

Copilot AI left a comment

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.

Comment thread buildenv/jenkins/JenkinsfileBase Resolved
Comment thread buildenv/jenkins/aqaTestPipeline.groovy Resolved
Comment thread buildenv/jenkins/openjdk_tests Resolved

Copilot AI left a comment

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.

🔵 Needs a closer look

Infrastructure failures are still misclassified as test failures, causing misleading badges and unnecessary reruns, while rerun handling can export a job status inconsistent with the retained Jenkins result.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@sophia-guo
sophia-guo marked this pull request as draft November 30, 2026 19:28
@sophia-guo
sophia-guo marked this pull request as ready for review November 30, 2026 22:26

@smlambert smlambert left a comment

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.

Thank you @sophia-guo ! Let's see how this performs in our Dec dry-run!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Separate test status from job status to avoid infra failures tainting test results

3 participants