Skip to content

fix: add test_case_id to prevent RP history merging#14

Merged
silvi-t merged 1 commit into
Kuadrant:mainfrom
silvi-t:fix-test-uploading
May 7, 2026
Merged

fix: add test_case_id to prevent RP history merging#14
silvi-t merged 1 commit into
Kuadrant:mainfrom
silvi-t:fix-test-uploading

Conversation

@silvi-t
Copy link
Copy Markdown
Contributor

@silvi-t silvi-t commented May 6, 2026

Summary

  • Added test_case_id parameter to start_test_case() in the RP client wrapper
  • Writer now builds a suite-qualified test_case_id ({suite_name}: {test_path}) so ReportPortal tracks tests under different suites as distinct items in history
  • Fixes duplicate history entries when the same test runs in multiple suites within one launch (e.g. smoke, acceptance, fullsuite)

Closes #13

Summary by CodeRabbit

Release Notes

  • New Features

    • Added per-test-case identification support to ReportPortal integration, enabling improved history matching and test case tracking.
    • Introduced auto-analysis trigger functionality with dry-run capability for automatic test result analysis.
  • Refactor

    • Enhanced test case processing to propagate suite-level context and improve ReportPortal history linkage.
    • Improved failed attempt handling with proper test identification for accurate retry tracking.

Signed-off-by: Silvia Tarabova <starabov@redhat.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

📝 Walkthrough

Walkthrough

This PR adds per-test-case identification to ReportPortal integration by introducing a test_case_id parameter to the wrapper's test case start method, implementing an auto-analysis trigger class, and propagating suite context through the writer to create unique, suite-qualified test identifiers for RP history matching.

Changes

Test Case ID Propagation and Auto-Analysis Trigger

Layer / File(s) Summary
API Extension
src/reportportal/reportportal_client_wrapper.py
start_test_case method signature extended with optional test_case_id parameter; parameter forwarded to RPClient.start_test_item for RP history matching.
Auto-Analysis Trigger
src/reportportal/reportportal_client_wrapper.py
New AutoAnalysisTrigger class added with trigger_auto_analysis(launch_id) method; supports dry-run mode and HTTP POST to RP auto-analysis endpoint with logging and error handling.
Suite Context Propagation
src/reportportal/writer.py
_process_test_case signature updated to accept suite_name parameter; suite-qualified test_case_id generated by combining suite name with test name and passed to RP API calls.
Failed Attempt Linking
src/reportportal/writer.py
_create_failed_attempts signature updated to accept test_case_id parameter; uses ID when creating and linking retry attempts to ensure proper RP history linkage across multiple suites.
Test Expectations
tests/unit/test_reportportal_client_wrapper.py
Assertions updated to reflect new test_case_id=None parameter in RPClient.start_test_item calls.

Sequence Diagram

sequenceDiagram
    participant Writer as RPWriter
    participant WrapperAPI as RPClientWrapper
    participant AutoAnalysis as AutoAnalysisTrigger
    participant RPAPI as ReportPortal API

    Writer->>WrapperAPI: start_test_case(name, suite_name, test_case_id)
    WrapperAPI->>RPAPI: start_test_item(test_case_id=suite_qualified_id)
    RPAPI-->>WrapperAPI: item_id
    WrapperAPI-->>Writer: item_id

    Writer->>WrapperAPI: finish_test_case(item_id, result)
    WrapperAPI->>RPAPI: finish_test_item(item_id, result)
    RPAPI-->>WrapperAPI: ✓

    Writer->>AutoAnalysis: trigger_auto_analysis(launch_id)
    AutoAnalysis->>RPAPI: POST /auto-analysis (launch_id)
    RPAPI-->>AutoAnalysis: ✓
    AutoAnalysis-->>Writer: success
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • zkraus

Poem

🐰 A suite's context now flows through each test,
With IDs that guide the history quest—
Suite-qualified traces in ReportPortal's bright pages,
No more lost lineage through the test ages! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding test_case_id parameter to prevent ReportPortal history merging.
Linked Issues check ✅ Passed The PR implements the required solution: adds test_case_id parameter to start_test_case [#13], constructs suite-qualified test_case_id format in writer [#13], and propagates it through failed attempt handling [#13].
Out of Scope Changes check ✅ Passed All changes are directly scoped to resolving issue #13: test_case_id parameter addition, suite-qualified ID construction, and RP history linking without altering launch lifecycle.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/unit/test_reportportal_client_wrapper.py (1)

244-263: ⚡ Quick win

Add one explicit test for non-None test_case_id forwarding.

Right now the updated assertions only cover the default None path. A positive-path assertion with an actual suite-qualified ID would directly lock in the PR’s core behaviour.

💡 Minimal test tweak
         case_id = wrapper.start_test_case(
             name="Test Case",
             start_time="2024-01-01T12:00:00",
             parent_id="suite_456",
             attributes=[{"key": "color", "value": "green"}],
             description="Case description",
-            code_ref="path/to/test.py::test_name"
+            code_ref="path/to/test.py::test_name",
+            test_case_id="smoke: path/to/test.py::test_name"
         )
@@
             parent_item_id="suite_456",
             code_ref="path/to/test.py::test_name",
-            test_case_id=None,
+            test_case_id="smoke: path/to/test.py::test_name",
             retry=False,
             retry_of=None
         )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/test_reportportal_client_wrapper.py` around lines 244 - 263, Add a
focused positive-path unit test that verifies a non-None test_case_id is
forwarded to the ReportPortal client: call wrapper.start_test_case (from the
test file) with a concrete test_case_id like "suite_123::case_456" and assert
wrapper.client.start_test_item was called with test_case_id set to that exact
value (in addition to the existing args); reference wrapper.start_test_case and
wrapper.client.start_test_item to locate where to add the assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/unit/test_reportportal_client_wrapper.py`:
- Around line 244-263: Add a focused positive-path unit test that verifies a
non-None test_case_id is forwarded to the ReportPortal client: call
wrapper.start_test_case (from the test file) with a concrete test_case_id like
"suite_123::case_456" and assert wrapper.client.start_test_item was called with
test_case_id set to that exact value (in addition to the existing args);
reference wrapper.start_test_case and wrapper.client.start_test_item to locate
where to add the assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 02db9ba1-ff6a-4d21-9aaf-b9310d402cf7

📥 Commits

Reviewing files that changed from the base of the PR and between 77a3ee7 and b7d7bb2.

📒 Files selected for processing (3)
  • src/reportportal/reportportal_client_wrapper.py
  • src/reportportal/writer.py
  • tests/unit/test_reportportal_client_wrapper.py

@silvi-t silvi-t requested a review from zkraus May 6, 2026 16:25
Copy link
Copy Markdown
Contributor

@zkraus zkraus left a comment

Choose a reason for hiding this comment

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

LGTM

@silvi-t silvi-t merged commit 20e2e91 into Kuadrant:main May 7, 2026
4 checks passed
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.

Test results from different junit files lose their suite context when merged into a single launch

2 participants