Skip to content
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

Added tests for controllers/deploymentreplicassyncer #5493

Conversation

anujagrawal699
Copy link
Contributor

@anujagrawal699 anujagrawal699 commented Sep 7, 2024

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:
      • Successful replicas sync
      • 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 80.60% .

What type of PR is this?
/kind feature

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

Does this PR introduce a user-facing change?:

NONE

@karmada-bot karmada-bot added the kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. label Sep 7, 2024
@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 7, 2024
@karmada-bot karmada-bot requested a review from Poor12 September 7, 2024 18:15
@karmada-bot karmada-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 7, 2024
@anujagrawal699 anujagrawal699 force-pushed the addedTests-pkg/controllers/deploymentreplicassyncer branch from 8c04229 to 1a16c6b Compare September 8, 2024 05:52
@karmada-bot karmada-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 8, 2024
@anujagrawal699
Copy link
Contributor Author

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.

@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2024

⚠️ 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 ✅

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

❗ 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%) ⬆️

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.

@anujagrawal699 anujagrawal699 force-pushed the addedTests-pkg/controllers/deploymentreplicassyncer branch from 1a16c6b to 9f02242 Compare September 9, 2024 10:44
@anujagrawal699
Copy link
Contributor Author

@XiShanYongYe-Chang Please take a look.

@zhzhuang-zju
Copy link
Contributor

/assign

@anujagrawal699 anujagrawal699 force-pushed the addedTests-pkg/controllers/deploymentreplicassyncer branch from 9f02242 to 54813b1 Compare November 12, 2024 12:17
@karmada-bot karmada-bot 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 Nov 12, 2024
@anujagrawal699
Copy link
Contributor Author

@zhzhuang-zju PTAL

@zhzhuang-zju
Copy link
Contributor

/lgtm
thanks cc @XiShanYongYe-Chang

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 14, 2024
@XiShanYongYe-Chang
Copy link
Member

Thanks~
/assign

@anujagrawal699 anujagrawal699 force-pushed the addedTests-pkg/controllers/deploymentreplicassyncer branch from 54813b1 to b765067 Compare November 14, 2024 15:10
@karmada-bot karmada-bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 14, 2024
@zhzhuang-zju
Copy link
Contributor

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 15, 2024
Comment on lines 136 to 140
case tc.name == "create event":
result = predicateFunc.Create(event.CreateEvent{Object: tc.newObj})
case tc.name == "delete event":
result = predicateFunc.Delete(event.DeleteEvent{Object: tc.oldObj})
case tc.name == "generic event":
Copy link
Member

Choose a reason for hiding this comment

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

Generally, the name is read-only and may be changed frequently in the future. If the switch case statement is used, it is recommended that a type field be added to indicate the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add an event type structure.

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Other parts lgtm, thanks~

Signed-off-by: Anuj Agrawal <[email protected]>

Added tests for controllers/deploymentreplicassyncer

Signed-off-by: Anuj Agrawal <[email protected]>

Added tests for controllers/deploymentreplicassyncer

Signed-off-by: Anuj Agrawal <[email protected]>

Added tests for controllers/deploymentreplicassyncer

Signed-off-by: Anuj Agrawal <[email protected]>

Added tests for controllers/deploymentreplicassyncer

Signed-off-by: Anuj Agrawal <[email protected]>

Added tests for controllers/deploymentreplicassyncer

Signed-off-by: Anuj Agrawal <[email protected]>
@anujagrawal699 anujagrawal699 force-pushed the addedTests-pkg/controllers/deploymentreplicassyncer branch from b765067 to 455cb39 Compare November 15, 2024 05:35
@karmada-bot karmada-bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 15, 2024
Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 15, 2024
@karmada-bot
Copy link
Collaborator

[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 karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 15, 2024
@karmada-bot karmada-bot merged commit e7fd4eb into karmada-io:master Nov 15, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants