Skip to content

test: add test coverage for pkg/kubelet/status #132857

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

ylink-lfs
Copy link
Contributor

@ylink-lfs ylink-lfs commented Jul 10, 2025

What type of PR is this?

/kind cleanup
/sig node
/priority important-longterm

What this PR does / why we need it:

Test coverage increase for kubelet package

Which issue(s) this PR is related to:

Part of #109717

Special notes for your reviewer:

Before the commits were made, the coverage of pkg/kubelet/types module was 86.8%:

➜  kubernetes git:(master) make test WHAT=./pkg/kubelet/status/... KUBE_COVER=y
+++ [0710 09:21:06] Set GOMAXPROCS automatically to 8
+++ [0710 09:21:06] Normalizing Go targets
+++ [0710 09:21:06] Saving coverage output in '/tmp/k8s_coverage/20250710-092106'
+++ [0710 09:21:06] Running tests with code coverage and with -race
∅  pkg/kubelet/status/testing (36ms) (coverage: 0.0% of statements)
✓  pkg/kubelet/status (2.205s) (coverage: 86.8% of statements)

DONE 79 tests in 10.334s
+++ [0710 09:21:17] Combined coverage report: /tmp/k8s_coverage/20250710-092106/combined-coverage.html

This commit increased the coverage to 89.5%:

➜  kubernetes git:(test/kubelet_status_covrage) make test WHAT=./pkg/kubelet/status/... KUBE_COVER=y 
+++ [0710 09:20:13] Set GOMAXPROCS automatically to 8
+++ [0710 09:20:13] Normalizing Go targets
+++ [0710 09:20:14] Saving coverage output in '/tmp/k8s_coverage/20250710-092014'
+++ [0710 09:20:14] Running tests with code coverage and with -race
∅  pkg/kubelet/status/testing (59ms) (coverage: 0.0% of statements)
✓  pkg/kubelet/status (2.446s) (coverage: 89.5% of statements)

DONE 86 tests in 12.026s
+++ [0710 09:20:26] Combined coverage report: /tmp/k8s_coverage/20250710-092014/combined-coverage.html

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

None

@Copilot Copilot AI review requested due to automatic review settings July 10, 2025 01:21
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/node Categorizes an issue or PR as relevant to SIG Node. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels Jul 10, 2025
@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 10, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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
Copy link
Contributor

Hi @ylink-lfs. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 10, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR increases test coverage in the pkg/kubelet/status package by adding two new sets of unit tests:

  • A test ensuring pods in non-terminal phases with a deletion timestamp do not trigger deletion.
  • A table-driven test for the NeedToReconcilePodReadiness helper covering various readiness-gate scenarios.
Comments suppressed due to low confidence (1)

pkg/kubelet/status/status_manager_test.go:1507

  • [nitpick] The variable logger actually holds a context.Context; consider renaming it to ctx (e.g., ctx, _ := ktesting.NewTestContext(t)) to improve clarity.
	logger, _ := ktesting.NewTestContext(t)

@ylink-lfs ylink-lfs force-pushed the test/kubelet_status_covrage branch from 55188cb to 353e54d Compare July 10, 2025 01:32
@ylink-lfs
Copy link
Contributor Author

/assign mrunalp

@ffromani
Copy link
Contributor

/ok-to-test
/priority backlog

@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. priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 10, 2025
@ylink-lfs ylink-lfs force-pushed the test/kubelet_status_covrage branch from 353e54d to 5b06723 Compare July 10, 2025 12:03
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ylink-lfs
Once this PR has been reviewed and has the lgtm label, please ask for approval from mrunalp. 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

@ylink-lfs ylink-lfs force-pushed the test/kubelet_status_covrage branch from 5b06723 to fcab848 Compare July 10, 2025 12:07
@ylink-lfs ylink-lfs force-pushed the test/kubelet_status_covrage branch from fcab848 to 11d19c1 Compare July 10, 2025 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/backlog Higher priority than priority/awaiting-more-evidence. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Development

Successfully merging this pull request may close these issues.

4 participants