Skip to content

Fix Polarion double-prefix by stripping OCP- from reportxml.ID arguments - #57

Merged
openshift-merge-bot[bot] merged 1 commit into
medik8s:mainfrom
ugreener:fix/reportxml-id-strip-ocp-prefix
Jul 26, 2026
Merged

Fix Polarion double-prefix by stripping OCP- from reportxml.ID arguments#57
openshift-merge-bot[bot] merged 1 commit into
medik8s:mainfrom
ugreener:fix/reportxml-id-strip-ocp-prefix

Conversation

@ugreener

@ugreener ugreener commented Jul 26, 2026

Copy link
Copy Markdown

Summary

reportxml.ID() automatically prepends OCP- to create Polarion test case IDs. Passing reportxml.ID("OCP-66026") produces OCP-OCP-66026 which Polarion rejects as "not found", causing test results to silently drop from CI reporting. The FAR weekly periodic job was reporting only 9/15 results to Polarion because the 6 destructive test IDs were rejected.

Changes

  • FAR (6 fixes): far_destructive.go (5), far_controller_lifecycle.go (1)
  • SNR (5 fixes): worker_remediation.go (3), master_remediation.go (2)
  • MDR (1 fix): mdr_remediation.go (1)

All 12 changes are identical: reportxml.ID("OCP-XXXXX") to reportxml.ID("XXXXX") (numeric only, matching the convention used by all post-deploy tests).

Verified: FAR periodic job OS-20260721-0545 confirms 9 post-deploy tests reported correctly while 6 destructive tests were rejected with "not found in Polarion" for IDs like OCP-OCP-70638.

reportxml.ID() automatically prepends OCP- to create Polarion test case
IDs. Passing reportxml.ID("OCP-66026") produces OCP-OCP-66026 which
Polarion rejects as "not found", causing test results to silently drop
from CI reporting.

Fix 12 instances across FAR (6), SNR (5), and MDR (1) destructive and
remediation test files.

Co-Authored-By: Claude <noreply@anthropic.com>
@openshift-ci
openshift-ci Bot requested review from abrugaro and eemcmullan July 26, 2026 07:39
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Report identifier normalization

Layer / File(s) Summary
Numeric remediation report identifiers
tests/far-operator/tests/*, tests/mdr-operator/tests/mdr_remediation.go, tests/snr-operator/tests/*remediation.go
Replaces OCP-<number> report identifiers with numeric strings in FAR, MDR, and SNR remediation tests.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

Suggested labels: ok-to-test

Suggested reviewers: gamado

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: removing the OCP- prefix from reportxml.ID arguments to avoid double-prefixed Polarion IDs.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-2-for-medik8s

Copy link
Copy Markdown

PR Summary by Qodo

Fix Polarion test case IDs by removing redundant OCP- prefix in reportxml.ID calls

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Replace prefixed Polarion IDs ("OCP-#####") with numeric-only IDs in remediation/destructive
 tests.
• Prevent reportxml.ID() from generating double-prefixed IDs ("OCP-OCP-#####") rejected by Polarion.
• Restore complete CI-to-Polarion result reporting for FAR/SNR/MDR suites.
Diagram

graph TD
  T["Ginkgo operator tests"] --> N["Numeric case ID"] --> F(["reportxml.ID()"])
  F --> P["Polarion ID: OCP-<num>"] --> X{{"Polarion"}}
  subgraph Legend
    direction LR
    _file["Test/spec"] ~~~ _fn(["Helper function"]) ~~~ _ext{{"External system"}}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Normalize inside reportxml.ID() (strip optional "OCP-" prefix)
  • ➕ Prevents recurrence even if callers mistakenly pass prefixed IDs
  • ➕ Centralizes ID-format rules in one place
  • ➖ Potential behavior change for other callers relying on strict input
  • ➖ Requires validating all current usages to avoid surprises
2. Add a dedicated helper (e.g., reportxml.NumericID or reportxml.PolarionID) and deprecate current pattern
  • ➕ Makes the intended input format explicit at call sites
  • ➕ Allows a gradual migration without changing existing semantics
  • ➖ More API surface area and migration work
  • ➖ Still requires updating existing callers over time
3. Add a lint/test guard to reject prefixed inputs in test code
  • ➕ Catches mistakes early without changing runtime behavior
  • ➕ Keeps reportxml.ID() semantics unchanged
  • ➖ Does not fix existing breakage unless combined with code changes
  • ➖ Linting may not run in all contributor workflows

Recommendation: This PR’s approach (fixing the call sites to pass numeric-only IDs) is the lowest-risk, quickest way to restore Polarion reporting. Consider a follow-up to make reportxml.ID() tolerant of an accidental "OCP-" prefix (or add a guard) to prevent future regressions.

Files changed (5) +12 / -12

Tests (5) +12 / -12
far_controller_lifecycle.goFix Polarion case ID formatting for FAR controller lifecycle test +1/-1

Fix Polarion case ID formatting for FAR controller lifecycle test

• Updates the reportxml.ID() argument from a prefixed form ("OCP-70636") to numeric-only ("70636"). This prevents reportxml.ID() from generating a double-prefixed ID rejected by Polarion.

tests/far-operator/tests/far_controller_lifecycle.go

far_destructive.goFix Polarion case IDs for FAR destructive remediation scenarios +5/-5

Fix Polarion case IDs for FAR destructive remediation scenarios

• Replaces five reportxml.ID() usages from "OCP-#####" to "#####" across destructive/remediation specs. Ensures Polarion receives valid case IDs and does not drop these results.

tests/far-operator/tests/far_destructive.go

mdr_remediation.goFix Polarion case ID formatting for MDR remediation test +1/-1

Fix Polarion case ID formatting for MDR remediation test

• Changes reportxml.ID("OCP-66138") to reportxml.ID("66138") to avoid creating an invalid double-prefixed Polarion ID.

tests/mdr-operator/tests/mdr_remediation.go

master_remediation.goFix Polarion case IDs for SNR master remediation tests +2/-2

Fix Polarion case IDs for SNR master remediation tests

• Converts two reportxml.ID() calls from prefixed IDs to numeric-only IDs. Prevents Polarion lookup failures caused by "OCP-OCP-..." formatting.

tests/snr-operator/tests/master_remediation.go

worker_remediation.goFix Polarion case IDs for SNR worker remediation tests +3/-3

Fix Polarion case IDs for SNR worker remediation tests

• Updates three reportxml.ID() arguments to numeric-only values for worker remediation/eviction scenarios. Ensures reportxml.ID() prepends OCP- exactly once for Polarion reporting.

tests/snr-operator/tests/worker_remediation.go

@qodo-2-for-medik8s

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 13 rules

Grey Divider


Informational

1. ID prefix duplication risk 🐞 Bug ☼ Reliability
Description
reportxml.setTestID unconditionally concatenates the configured projectTag (e.g., "OCP-") with the
ID payload, so any future caller that accidentally passes a prefixed ID (e.g., "OCP-70636") will
still generate a double-prefixed testcase-id ("OCP-OCP-70636"). This PR fixes current call sites but
the report generator remains non-idempotent and easy to misuse again.
Code

tests/far-operator/tests/far_controller_lifecycle.go[44]

+			reportxml.ID("70636"),
Relevance

⭐ Low

Team previously rejected fixing vendor helper behavior; likely won’t change vendored reportxml for
idempotency.

PR-#8

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The suites pass a prefix into report generation, and setTestID concatenates that prefix with the ID
label payload. Therefore, if a caller supplies an ID that already begins with the same prefix, the
report value will include the prefix twice.

tests/far-operator/far_suite_test.go[47-50]
vendor/github.com/rh-ecosystem-edge/eco-goinfra/pkg/reportxml/reportxml.go[111-114]
vendor/github.com/rh-ecosystem-edge/eco-goinfra/pkg/reportxml/reportxml.go[153-160]
tests/far-operator/tests/far_controller_lifecycle.go[42-45]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`reportxml.setTestID(...)` always builds the testcase-id value as `projectTag + <id-from-label>`. If the label payload already starts with `projectTag`, the result becomes double-prefixed.

## Issue Context
- Test suites call `reportxml.Create(report, ..., Medik8sConfig.TCPrefix)`.
- `setTestID` concatenates `projectTag` with the ID payload extracted from labels.

## Fix Focus Areas
- vendor/github.com/rh-ecosystem-edge/eco-goinfra/pkg/reportxml/reportxml.go[153-160]

### Suggested implementation sketch
In `setTestID`, normalize the extracted ID before concatenation:
- Extract the payload safely (avoid assuming `strings.Split(...)[1]` exists).
- `id = strings.TrimPrefix(id, projectTag)`
- `Value: projectTag + id`

This keeps existing behavior for unprefixed IDs while preventing accidental double-prefixing.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@ugreener ugreener changed the title tests: strip OCP- prefix from reportxml.ID to fix Polarion double-prefix Fix Polarion double-prefix by stripping OCP- from reportxml.ID arguments Jul 26, 2026
@openshift-ci

openshift-ci Bot commented Jul 26, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: razo7, ugreener

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot
openshift-merge-bot Bot merged commit 9e39d54 into medik8s:main Jul 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants