karmada icon indicating copy to clipboard operation
karmada copied to clipboard

Added tests for controllers/deploymentreplicassyncer

Open anujagrawal699 opened this issue 1 year ago • 4 comments

Description: This PR introduces tests for deploymentreplicassyncer controller. The new addition tests significant logic of deploymentreplicassyncer controller.

Additions:

  1. TestPredicateFunc:

    • Added tests for various scenarios including label changes, replica changes, and different event types (Create, Update, Delete, Generic).
    • Ensures the predicate function correctly filters relevant events.
  2. TestSetupWithManager:

    • Verifies that the controller can be properly set up with a manager.
  3. TestReconcile:

    • Added test cases for different reconciliation scenarios:
      • Binding not found
      • Non-divided scheduling type
      • Replicas already synced
    • Checks for correct result, error handling, and replica updates.
  4. TestIsDeploymentStatusCollected:

    • Covers various scenarios:
      • Fully collected status
      • Mismatched replicas
      • Generation mismatches
      • Incomplete aggregated status
      • Invalid JSON in status
      • Zero replicas in status
      • Mismatched status replicas

Test Coverage: The test coverage of the deploymentreplicassyncer controller has been increased to 63.9% .

What type of PR is this? /kind failing-test /kind feature

Which issue(s) this PR fixes: Fixes a part of #5470

Does this PR introduce a user-facing change?:

NONE

anujagrawal699 avatar Sep 07 '24 18:09 anujagrawal699

The TestSetupWithManager is removed in the latest commit because it was causing CI failures and provided limited value in terms of testing the controller's core functionality.

anujagrawal699 avatar Sep 08 '24 05:09 anujagrawal699

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 45.00%. Comparing base (32c2ef7) to head (455cb39). Report is 378 commits behind head on master.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5493       +/-   ##
===========================================
+ Coverage   31.70%   45.00%   +13.29%     
===========================================
  Files         643      658       +15     
  Lines       44445    53917     +9472     
===========================================
+ Hits        14090    24263    +10173     
+ Misses      29325    28080     -1245     
- Partials     1030     1574      +544     
Flag Coverage Δ
unittests 45.00% <ø> (+13.29%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Sep 08 '24 06:09 codecov-commenter

@XiShanYongYe-Chang Please take a look.

anujagrawal699 avatar Sep 13 '24 07:09 anujagrawal699

/assign

zhzhuang-zju avatar Nov 11 '24 03:11 zhzhuang-zju

@zhzhuang-zju PTAL

anujagrawal699 avatar Nov 14 '24 08:11 anujagrawal699

/lgtm thanks cc @XiShanYongYe-Chang

zhzhuang-zju avatar Nov 14 '24 11:11 zhzhuang-zju

Thanks~ /assign

XiShanYongYe-Chang avatar Nov 14 '24 12:11 XiShanYongYe-Chang

/lgtm

zhzhuang-zju avatar Nov 15 '24 01:11 zhzhuang-zju

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: XiShanYongYe-Chang

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

The pull request process is described 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

karmada-bot avatar Nov 15 '24 06:11 karmada-bot