Skip to content

test: code coverage increase for kubelet/prober #132534

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 Jun 25, 2025

What type of PR is this?

/kind cleanup
/sig node

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/prober module was 80.5%:

➜  kubernetes git:(master) make test WHAT=./pkg/kubelet/prober KUBE_COVER=y                                        
+++ [0626 00:27:18] Set GOMAXPROCS automatically to 8
+++ [0626 00:27:18] Normalizing Go targets
+++ [0626 00:27:18] Saving coverage output in '/tmp/k8s_coverage/20250626-002718'
+++ [0626 00:27:18] Running tests with code coverage and with -race
✓  pkg/kubelet/prober (13.253s) (coverage: 80.5% of statements)

=== Skipped
=== SKIP: pkg/kubelet/prober TestTCPPortExhaustion (0.00s)
    scale_test.go:68: skipping TCP port exhaustion tests

DONE 33 tests, 1 skipped in 20.873s
+++ [0626 00:27:40] Combined coverage report: /tmp/k8s_coverage/20250626-002718/combined-coverage.html

This commit increased the coverage to 94.1%:

➜  kubernetes git:(test/kubelet_prober_test) make test WHAT=./pkg/kubelet/prober KUBE_COVER=y                      
+++ [0626 00:26:00] Set GOMAXPROCS automatically to 8
+++ [0626 00:26:00] Normalizing Go targets
+++ [0626 00:26:00] Saving coverage output in '/tmp/k8s_coverage/20250626-002600'
+++ [0626 00:26:00] Running tests with code coverage and with -race
✓  pkg/kubelet/prober (13.421s) (coverage: 94.1% of statements)

=== Skipped
=== SKIP: pkg/kubelet/prober TestTCPPortExhaustion (0.00s)
    scale_test.go:68: skipping TCP port exhaustion tests

DONE 37 tests, 1 skipped in 21.154s
+++ [0626 00:26:22] Combined coverage report: /tmp/k8s_coverage/20250626-002600/combined-coverage.html
  • Note that the coverage of prober.go file increased from 62.6% to 94.5% because tests for probe method other than Exec-Probe were added. prober_manager.go file increased from 81.8% to 94.2% because tests for StopLivenessAndStartup and duplicate probe addition in AddPod are added.

  • Also, this commit moved test functions TestGetURLParts and TestGetTCPAddrParts to pkg/probe/util_test.go because those two test functions mainly test ResolveContainerPort, which is not provided by pkg/kubelet/probe.

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 June 25, 2025 16:40
@k8s-ci-robot k8s-ci-robot added 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. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. sig/node Categorizes an issue or PR as relevant to SIG Node. labels Jun 25, 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 Jun 25, 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 k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 25, 2025
@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
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 assign sergeykanzhelev 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

Copilot

This comment was marked as outdated.

@ylink-lfs
Copy link
Contributor Author

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 26, 2025
@ylink-lfs ylink-lfs changed the title test: code coverage increase for kubelet/prober/prober.go test: code coverage increase for kubelet/prober Jun 26, 2025
@ylink-lfs ylink-lfs force-pushed the test/kubelet_prober_test branch from 9f8e697 to be8f775 Compare June 26, 2025 17:58
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 26, 2025
@ylink-lfs ylink-lfs requested a review from Copilot June 26, 2025 18:01
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 for the kubelet/prober package by adding new tests and moving some test functions to a more appropriate location. Key changes include:

  • Adding new unit tests in pkg/probe/util_test.go for URL and TCP parts parsing.
  • Extending the prober tests in pkg/kubelet/prober/prober_test.go with multiple fake prober implementations and additional test cases for various probe schemes.
  • Enhancing the prober manager tests in pkg/kubelet/prober/prober_manager_test.go to validate duplicate probe worker handling and proper stopping of liveness/startup probes.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pkg/probe/util_test.go Added tests for GetURLParts and GetTCPAddrParts to verify port and URL parsing.
pkg/kubelet/prober/prober_test.go Introduced fake prober types and extended probe tests for exec, HTTP, TCP, and GRPC probes.
pkg/kubelet/prober/prober_manager_test.go Added tests for duplicate probe worker creation and StopLivenessAndStartup functionality.

@ylink-lfs ylink-lfs force-pushed the test/kubelet_prober_test branch from be8f775 to e0a2bb3 Compare June 26, 2025 18:03
@ylink-lfs
Copy link
Contributor Author

@bart0sh Would you be willing to review?

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-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Development

Successfully merging this pull request may close these issues.

2 participants