Skip to content

test(util): add unit tests for CreateValidMetricNameLabel - #3159

Merged
google-oss-prow[bot] merged 2 commits into
kubeflow:masterfrom
magic-peach:test/metrics-label-coverage
Sep 28, 2026
Merged

google-oss-prow[bot] merged 2 commits into
kubeflow:masterfrom
magic-peach:test/metrics-label-coverage

Conversation

@magic-peach

Copy link
Copy Markdown
Contributor

Purpose of this PR

pkg/util/metrics.go's CreateValidMetricNameLabel (dash-to-underscore metric label sanitizing) had no test file at all.

Proposed changes:

  • Add pkg/util/metrics_test.go covering dashes being replaced in both the prefix and the name, and the concatenation being returned unchanged when there are no dashes.

Change Category

  • Bugfix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that could affect existing functionality)
  • Documentation update

Rationale

None of the categories above quite fit: this is a test-only addition, no production code changed.

Checklist

  • I have conducted a self-review of my own code.
  • I have updated documentation accordingly.
  • I have added tests that prove my changes are effective or that my feature works.
  • Existing unit tests pass locally with my changes.

Additional Notes

Ran go test ./pkg/util/...: all specs pass. go vet ./pkg/util/... clean.

Copilot AI balanced review requested due to automatic review settings September 11, 2026 09:32

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

🎉 Welcome to the Kubeflow Spark Operator! 🎉

Thanks for opening your first PR! We're happy to have you as part of our community 🚀

Here's what happens next:

Join the community:

Feel free to ask questions in the comments if you need any help or clarification!
Thanks again for contributing to Kubeflow! 🙏

@tariq-hasan tariq-hasan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @magic-peach! Thanks for the PR. Overall lgtm. I have one suggestion to add some more cases.

Comment thread pkg/util/metrics_test.go
@tariq-hasan

Copy link
Copy Markdown
Member

/retitle test(util): add unit tests for CreateValidMetricNameLabel

@google-oss-prow google-oss-prow Bot changed the title Add unit tests for CreateValidMetricNameLabel test(util): add unit tests for CreateValidMetricNameLabel Sep 12, 2026
@tariq-hasan

Copy link
Copy Markdown
Member

/ok-to-test
/retest

Comment thread pkg/util/metrics_test.go
Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@magic-peach
magic-peach force-pushed the test/metrics-label-coverage branch from 5b5038b to c06c568 Compare September 19, 2026 04:22
@magic-peach

Copy link
Copy Markdown
Contributor Author

Expanded to a DescribeTable with the suggested cases, including the empty-prefix and consecutive-dash entries. Pushed.

@RobuRishabh

Copy link
Copy Markdown
Contributor

/lgtm
Thanks

@nabuskey nabuskey 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.

/approve

@google-oss-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nabuskey

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

@google-oss-prow
google-oss-prow Bot merged commit 7fda3ff into kubeflow:master Sep 28, 2026
19 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.

5 participants