Skip to content

junit: switch time to zero instead of timestamp#278

Open
klaskosk wants to merge 1 commit into
openshift:mainfrom
klaskosk:junit-time-float
Open

junit: switch time to zero instead of timestamp#278
klaskosk wants to merge 1 commit into
openshift:mainfrom
klaskosk:junit-time-float

Conversation

@klaskosk

@klaskosk klaskosk commented Jun 1, 2026

Copy link
Copy Markdown

The JUnit format expects the time attribute to represent the duration of a test, not the timestamp. The JUnit output from kube-compare already correctly adds the timestamp attribute as a timestamp, but then sets time to be the same. For tools which are stricter about the JUnit schema, this causes errors parsing the kube-compare output.

This commit switches to always setting time="0" in the testsuites, testsuite, and testcase tags. Since the duration would not be relevant, "0" is chosen as a default. Alternatively, the attribute could be removed since it is optional, but since it is already present, setting it to zero works as well.

Assisted-by: Cursor

Summary by CodeRabbit

Bug Fixes

  • Test suite timestamps in JUnit XML reports now use RFC3339 standard formatting, with duration values consistently set to zero
  • Test case timing is now properly initialized with zero-duration values when empty, ensuring consistent duration handling across all test reports

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@klaskosk, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 55 minutes and 19 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3decf1b9-a81f-4334-9be9-5721462c8b4f

📥 Commits

Reviewing files that changed from the base of the PR and between 9fdbb71 and 5068536.

📒 Files selected for processing (2)
  • pkg/compare/testdata/JunitOutput/localout.golden
  • pkg/junit/junit.go

Walkthrough

This PR standardizes JUnit XML duration handling by introducing a zeroDuration constant and applying it consistently across test suite and test case initialization. The changes separate timestamp from duration in suite metadata, replacing prior timestamp-derived time values with zero duration.

Changes

JUnit XML Duration and Timing Standardization

Layer / File(s) Summary
Define zeroDuration constant
pkg/junit/junit.go
Introduces a zeroDuration constant to standardize duration values in generated JUnit XML.
Apply zeroDuration to suite constructors
pkg/junit/junit.go
Updates NewTestSuites to initialize Time with zeroDuration. Updates NewTestSuite to set Timestamp to the current RFC3339 time while setting Time to zeroDuration, separating duration from timestamp metadata.
Default testcase time in AddCase
pkg/junit/junit.go
Adds logic to TestSuite.AddCase to default tcase.Time to zeroDuration when the provided test case has an empty time field, ensuring consistency across all case initialization paths.

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: switching the JUnit time attribute from a timestamp value to zero, which is the primary objective of this PR.
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.
Stable And Deterministic Test Names ✅ Passed PR modifies only JUnit XML generation code (pkg/junit/junit.go) and contains no Ginkgo tests or test-related changes. Custom check for Ginkgo test name stability is not applicable.
Test Structure And Quality ✅ Passed PR modifies only production code (pkg/junit/junit.go). The check requires Ginkgo test code review, but the repository uses standard Go testing with testify, not Ginkgo. No test files are changed.
Microshift Test Compatibility ✅ Passed This PR does not add new Ginkgo e2e tests; it only modifies JUnit XML utility code (pkg/junit/junit.go). The custom check applies only when new tests are added.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR modifies only pkg/junit/junit.go (JUnit XML utility), not Ginkgo e2e tests. Custom check applies only to e2e test additions.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only pkg/junit/junit.go for JUnit output formatting. No deployment manifests, operators, controllers, or Kubernetes scheduling constraints introduced.
Ote Binary Stdout Contract ✅ Passed The junit package contains no stdout writes in process-level code. Write() accepts io.Writer, uses fmt only for errors, imports no klog, and has no init/global var violations.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR modifies only pkg/junit/junit.go, a JUnit XML utility library with no Ginkgo e2e tests. Custom check for IPv6/disconnected test compatibility does not apply.
No-Weak-Crypto ✅ Passed PR only modifies junit.go for XML formatting; contains no cryptographic operations, weak algorithms (MD5/SHA1/DES/RC4/3DES/Blowfish/ECB), custom crypto, or secret comparisons.
Container-Privileges ✅ Passed PR modifies only pkg/junit/junit.go for JUnit XML time formatting; no container/K8s manifests with privileged settings are involved.
No-Sensitive-Data-In-Logs ✅ Passed No logging that exposes passwords, tokens, API keys, PII, session IDs, internal hostnames, or customer data found in the modified code.

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

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

@openshift-ci openshift-ci Bot requested review from imiller0 and zzztx June 1, 2026 21:45
@openshift-ci

openshift-ci Bot commented Jun 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign nocturnalastro for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

The JUnit format expects the time attribute to represent the duration of
a test, not the timestamp. The JUnit output from kube-compare already
correctly adds the timestamp attribute as a timestamp, but then sets
time to be the same. For tools which are stricter about the JUnit
schema, this causes errors parsing the kube-compare output.

This commit switches to always setting `time="0"` in the `testsuites`,
`testsuite`, and `testcase` tags. Since the duration would not be
relevant, `"0"` is chosen as a default. Alternatively, the attribute
could be removed since it is optional, but since it is already present,
setting it to zero works as well.

Assisted-by: Cursor
Signed-off-by: Kirsten Laskoski <klaskosk@redhat.com>
@klaskosk klaskosk force-pushed the junit-time-float branch from 9fdbb71 to 5068536 Compare June 1, 2026 21:49
@openshift-ci

openshift-ci Bot commented Jun 1, 2026

Copy link
Copy Markdown

@klaskosk: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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.

1 participant