Skip to content

feat: add tests_with_reruns count as suite attribute#12

Merged
silvi-t merged 1 commit into
mainfrom
test-suite-rerun-description
Apr 28, 2026
Merged

feat: add tests_with_reruns count as suite attribute#12
silvi-t merged 1 commit into
mainfrom
test-suite-rerun-description

Conversation

@silvi-t
Copy link
Copy Markdown
Contributor

@silvi-t silvi-t commented Apr 21, 2026

Summary

  • Adds a tests_with_reruns attribute to each test suite, reporting the number of test cases that had rerun attempts

Summary by CodeRabbit

  • Refactor
    • Improved ReportPortal integration: suite-level attributes now include accurate rerun counts and are computed earlier for more reliable start/finish reporting.
    • Test-case processing uses prefiltered results to streamline iteration and reduce repeated filtering, improving performance and consistency.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

📝 Walkthrough

Walkthrough

Suite-level attributes are precomputed before suite start, aggregating rerun counts and conditionally adding tests_with_reruns. Test case processing now receives pre-filtered case_result objects instead of filtering internally, and suite start/finish use the precomputed suite_attrs. (49 words)

Changes

Cohort / File(s) Summary
Suite Attribute Precomputation
src/reportportal/writer.py
Precomputes filtered case_result objects for all cases and totals reruns to compute rerun_test_count. Adds tests_with_reruns to suite_attrs when applicable; suite start and finish calls now use suite_attrs.
Test Case Processing Refactor
src/reportportal/writer.py
Test iteration zips case_data with its prefiltered case_result. _process_test_case signature updated to accept the prefiltered case_result and no longer performs internal property filtering.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through suites with a curious cheer,
Pre-filtered cases now whisper in my ear.
Reruns are counted, attributes gleam bright,
Upstream I tidy, and everything’s light.

🚥 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 accurately summarizes the main change: adding a tests_with_reruns count attribute to suite-level reporting, which directly aligns with the PR's primary objective and the code modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-suite-rerun-description

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/reportportal/writer.py`:
- Around line 222-224: The suite attribute "tests_with_reruns" is only added
when rerun_test_count > 0, but it must be emitted for every suite; update the
logic in writer.py where suite_attrs is built (the block referencing suite_attrs
and rerun_test_count) to always append {"key": "tests_with_reruns", "value":
str(rerun_test_count)} regardless of its value so zero counts are recorded as
"0".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 810920b3-c2df-4366-8f8c-b92535441cbf

📥 Commits

Reviewing files that changed from the base of the PR and between 5b45a98 and cb1d087.

📒 Files selected for processing (1)
  • src/reportportal/writer.py

Comment thread src/reportportal/writer.py
@silvi-t silvi-t requested a review from zkraus April 21, 2026 12:54
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.

Recommended to prefix a code block with a header comment. Otherwise LGTM.
Consider it pre-approved.

Comment thread src/reportportal/writer.py
Signed-off-by: Silvia Tarabova <starabov@redhat.com>
@silvi-t silvi-t force-pushed the test-suite-rerun-description branch from cb1d087 to eb6c4a4 Compare April 28, 2026 08:52
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 (2)
src/reportportal/writer.py (2)

299-307: Add an explicit type for case_result in the private method contract.

Typing this parameter as CasePropertyResult improves readability and static checking for this refactor.

🧩 Suggested typing improvement
-from .property_processor import PropertyFilter, LaunchPropertyBuilder
+from .property_processor import PropertyFilter, LaunchPropertyBuilder, CasePropertyResult
...
-    def _process_test_case(self, case_data: dict, case_result,
+    def _process_test_case(self, case_data: dict, case_result: CasePropertyResult,
                            suite_id: str, start_time: int) -> int:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/reportportal/writer.py` around lines 299 - 307, The private method
_process_test_case currently types case_result loosely; update its signature to
annotate case_result as CasePropertyResult (def _process_test_case(self,
case_data: dict, case_result: CasePropertyResult, suite_id: str, start_time:
int) -> int) and add or update the import for CasePropertyResult at the top of
the module if missing, then run and adjust any call sites to satisfy the new
type (or add typing.cast where necessary) to ensure static checkers recognize
the strong type.

236-239: Consider guarding against silent zip truncation.

zip(...) will silently drop trailing items if the lists diverge in a future edit. A small defensive length check here would make failures explicit.

🔧 Suggested defensive check
+        if len(case_results) != len(suite_data['test_cases']):
+            raise RuntimeError("Internal mismatch: case_results and test_cases lengths differ")
         for case_data, case_result in zip(suite_data['test_cases'], case_results):
             case_runtime = self._process_test_case(
                 case_data, case_result, suite_id, suite_timestamp + suite_runtime
             )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/reportportal/writer.py` around lines 236 - 239, The loop using
zip(suite_data['test_cases'], case_results) can silently drop items if the two
lists differ in length; before the for-loop that calls
self._process_test_case(case_data, case_result, suite_id, suite_timestamp +
suite_runtime) add a defensive check that compares len(suite_data['test_cases'])
to len(case_results) and, if they differ, emit a clear error (e.g., process/log
an error) and raise an exception (ValueError) so the mismatch is explicit rather
than silently truncating test cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/reportportal/writer.py`:
- Around line 299-307: The private method _process_test_case currently types
case_result loosely; update its signature to annotate case_result as
CasePropertyResult (def _process_test_case(self, case_data: dict, case_result:
CasePropertyResult, suite_id: str, start_time: int) -> int) and add or update
the import for CasePropertyResult at the top of the module if missing, then run
and adjust any call sites to satisfy the new type (or add typing.cast where
necessary) to ensure static checkers recognize the strong type.
- Around line 236-239: The loop using zip(suite_data['test_cases'],
case_results) can silently drop items if the two lists differ in length; before
the for-loop that calls self._process_test_case(case_data, case_result,
suite_id, suite_timestamp + suite_runtime) add a defensive check that compares
len(suite_data['test_cases']) to len(case_results) and, if they differ, emit a
clear error (e.g., process/log an error) and raise an exception (ValueError) so
the mismatch is explicit rather than silently truncating test cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1eea9141-10c5-49d8-897c-a75f671b8848

📥 Commits

Reviewing files that changed from the base of the PR and between cb1d087 and eb6c4a4.

📒 Files selected for processing (1)
  • src/reportportal/writer.py

@silvi-t silvi-t requested a review from zkraus April 28, 2026 08:55
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 77a3ee7 into main Apr 28, 2026
4 checks passed
@silvi-t silvi-t deleted the test-suite-rerun-description branch April 28, 2026 10:06
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.

2 participants