Skip to content

Add unit tests for pod create/update handler #2101

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

GautamBytes
Copy link
Contributor

Ⅰ. Describe what this PR does
This pull request introduces a unit test suite for the pod validating webhook handler located in pkg/webhook/pod/validating/pod_create_update_handler.go.

The primary goal is to increase test coverage and ensure the reliability of the webhook's core dispatch logic. The tests use a mock handler to verify that admission requests are correctly routed to either the WorkloadSpread or PodUnavailableBudget validation functions based on the operation type (CREATE, UPDATE, DELETE) and the state of their respective feature gates.

Ⅱ. Does this pull request fix one issue?
in support of #2074

Ⅲ. Describe how to verify it
You can verify this PR by running the tests for the specific package and ensuring they pass:
go test ./pkg/webhook/pod/validating -v
All newly added tests for pod_create_update_handler should pass successfully.

@kruise-bot kruise-bot requested review from Fei-Guo and zmberg July 9, 2025 09:20
@kruise-bot
Copy link

[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 furykerry for approval by writing /assign @furykerry in a comment. For more information see:The Kubernetes 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

@kruise-bot kruise-bot added the size/L size/L: 100-499 label Jul 9, 2025
Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.02%. Comparing base (f69813c) to head (4354720).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2101      +/-   ##
==========================================
+ Coverage   43.99%   44.02%   +0.02%     
==========================================
  Files         316      316              
  Lines       31844    31844              
==========================================
+ Hits        14009    14018       +9     
+ Misses      16425    16418       -7     
+ Partials     1410     1408       -2     
Flag Coverage Δ
unittests 44.02% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L size/L: 100-499
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants