Skip to content

Conversation

@GautamBytes
Copy link
Contributor

What this PR does / Why we need it
The MutatingWebhookEventHandler in pkg/controller/deployment/deployment_event_handler.go contains critical logic for queueing Deployments but previously lacked unit test coverage. This made it difficult to refactor or protect against regressions.

This PR adds a comprehensive and robust test suite to validate the handler's functionality, ensuring stability and correctness.

Key Improvements & Scenarios Covered
Complete Handler Coverage: Tests have been added for all event handler methods (Create, Update, Delete, and Generic).

Content Verification: Tests now verify the content of the enqueued reconcile.Request (i.e., the correct deployment name and namespace), not just that the queue length has changed.

Bulk Enqueue Testing: A scenario with multiple matching deployments is tested to ensure the handler's loop logic is correct.

Error Handling: A new test, TestEnqueueErrorHandling, was added to simulate an API client error and confirm that the handler fails gracefully without adding items to the queue.

@kruise-bot kruise-bot requested review from furykerry and veophi July 14, 2025 15:49
@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

@GautamBytes GautamBytes force-pushed the add-deployment-event-handler-tests branch from 742921a to d0dd578 Compare August 13, 2025 18:12
Signed-off-by: GautamBytes <[email protected]>
@codecov
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.83%. Comparing base (00aae12) to head (8fcd407).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #292      +/-   ##
==========================================
+ Coverage   47.52%   47.83%   +0.30%     
==========================================
  Files          63       63              
  Lines        9799     9799              
==========================================
+ Hits         4657     4687      +30     
+ Misses       4585     4553      -32     
- Partials      557      559       +2     
Flag Coverage Δ
unittests 47.83% <ø> (+0.30%) ⬆️

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.

@GautamBytes
Copy link
Contributor Author

@furykerry @veophi PTAL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants