Skip to content

test: add unit tests for core/utils and improve nil-safety in helpers #8406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kincoy
Copy link
Contributor

@kincoy kincoy commented Aug 5, 2025

What type of PR is this?

/kind cleanup


What this PR does / why we need it:

This PR improves unit test coverage for several utility functions in core/utils, helping ensure correctness and robustness of logic that supports autoscaling decisions.

Specifically:

  • Adds unit tests for:
    • FilterOutNodesFromNotAutoscaledGroups
    • GetOldestCreateTimeWithGpu
    • hasHardInterPodAffinity
    • isVirtualNode
  • Fixes potential panic in isVirtualNode when passed a nil node
  • Brings test coverage in core/utils/utils.go from 47.4% to 84.6%

before:
image

after:
image


Which issue(s) this PR fixes:

N/A — test coverage improvement


Special notes for your reviewer:

  • Safe refactor: no production logic changed, only a nil check added in isVirtualNode
  • Tests are table-driven and use testify assertions

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot
Copy link
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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.

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area labels Aug 5, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 5, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @kincoy. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 5, 2025
@kincoy
Copy link
Contributor Author

kincoy commented Aug 13, 2025

@feiskyer @vadasambar Hi, could you please re-run the failed workflows? They appear to be unrelated to this PR. Thanks🙏!

@vadasambar
Copy link
Member

vadasambar commented Aug 13, 2025

@kincoy sorry I don't have permissions to restart the failed workflow. Can you try creating an empty commit like this to trigger the build (another option is to create a small harmless change like adding new line and removing it later):

git commit --allow-empty -m "Trigger Build"

@kincoy kincoy force-pushed the test/core-utils-cover branch 2 times, most recently from 210db02 to b585c82 Compare August 13, 2025 13:31
@kincoy
Copy link
Contributor Author

kincoy commented Aug 13, 2025

@kincoy sorry I don't have permissions to restart the failed workflow. Can you try creating an empty commit like this to trigger the build (another option is to create a small harmless change like adding new line and removing it later):

git commit --allow-empty -m "Trigger Build"

Thanks for your feedback. I found a minor issue in my changes, which has now been fixed. I’ve pushed the update and all tests have passed. Please help review the latest commit to see if it looks good. Thanks again!🙏。

@kincoy kincoy force-pushed the test/core-utils-cover branch from b585c82 to a21eb0e Compare August 13, 2025 14:40
@jackfrancis
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants