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

Project Plan: Enhance Karmada controller-manager and schedule testing coverage (LFX 2024 TERM 3) #5470

Open
anujagrawal699 opened this issue Sep 2, 2024 · 18 comments
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@anujagrawal699
Copy link
Contributor

anujagrawal699 commented Sep 2, 2024

Project Plan

Objective:
To improve the unit test coverage for the specified directories in the Karmada repository.

Plan:

  1. Project Understanding

    • Understand the functionality and interdependencies within the karmada-controller-manager and karmada-scheduler components.
    • Document the critical code paths that are essential for the core functionality of each module.
    • Analyze the current test coverage reports and existing test cases.
  2. Test Coverage Enhancement Strategy

    • Target Directories:

      • pkg/controllers (Currently 22.1%) (Estimated completion for the package 25 September)
      • pkg/detector (Currently 19.58%)
      • pkg/scheduler (Currently 52.36%)
      • pkg/descheduler (Currently 65.37%)
      • pkg/util (Currently 59.35%)
      • pkg/estimator (Currently 42.46%)
      • pkg/dependenciesdistributor (Currently 51.36%)
      • pkg/resourceinterpreter (Currently 46.22%)
    • Critical Logic Testing:

      • Focus on core business logic and test the functions needed without increasing the maintenance cost.
    • Testing Methodologies:

      • Unit Testing: For individual functions, methods, and classes focusing on isolated code units.
      • Table-Driven Tests: Implement table-driven tests where possible to efficiently test multiple scenarios using test cases.
  3. Test Implementation

    • Directory-by-Directory Implementation:

      • Begin with the most critical directories, i.e., pkg/controllers and the one with the least coverage, i.e., pkg/detector.
      • Move to the next directory in the suggested order after completing testing for each directory.
    • Continuous Improvement:

      • Regularly review new tests to ensure they are meaningful, efficient, and cover the intended scenarios.
      • Refactor old code and tests to remove redundancy and improve maintainability.
  4. Evaluation

    • Perform a mid-point review of the coverage reports to ensure that the UT coverage is on track to increase by more than 15%.
    • Optimize any tests that might be redundant or overly complex to maintain test efficiency.
  5. Expected Outcomes

    • Increased Coverage:

      • Achieve a significant increase in UT coverage, around 60% coverage overall.
    • Improved Code Quality:

      • Enhance the quality and maintainability of the Karmada codebase, reducing the likelihood of defects.

Mentors: @XiShanYongYe-Chang , @zhzhuang-zju
Mentee: @anujagrawal699

PR Tracking

Overall Coverage Improved by this issue till date: +12.52%

Legend:

  • ⏳ - Under Review
  • ✅ - Merged
  • ❌ - Closed
Status Date Directory Old Coverage New Coverage Overall Coverage Increase PR
Aug 6 pkg/controllers/context 42.3% 100% 0.07% #5310
Aug 9 pkg/util/eventfilter 26.7% 100% 0.05% #5338
Aug 13 pkg/descheduler 13.75% 85.5% 0.79% #5364
Aug 22 pkg/util/fedinformer 2% 83.84% 1.25% #5366
Aug 14 pkg/controllers/namespace 0% 41.7% 0.53% #5368
Aug 17 pkg/servicenameresolutiondetector 0% 80% 0.92% #5408
Aug 20 operator/pkg/controller/context 0% 48.38% 0.49% #5420
Aug 24 examples/customresourceinterpreter/webhook 0% 42.5% 0.24% #5433
Aug 27 cmd/descheduler 0% 34% 0.13% #5445
Sep 1 cmd/scheduler 0% 34% 0.58% #5459
Sep 5 pkg/controllers/cronfederatedhpa 0% 27.8% 0.21% #5481
Sep 7 pkg/controllers/deploymentreplicassyncer 0% 65.3% 0.11% #5493
Sep 11 pkg/controllers/federatedhpa 1.79% 49.62% 1.25% #5528
Sep 12 pkg/controllers/federatedresourcequota 0% 51.3% 0.17% #5535
Sep 13 pkg/controllers/gracefuleviction 35.90% 76.7% 0.13% #5543
Sep 14 pkg/controllers/hpascaletargetmarker 0% 79.8% 0.21% #5553
Sep 18 pkg/controllers/mcs 0% 44.4% 0.50% #5566
Sep 22 pkg/controllers/multiclusterservice 0% 38.2% 0.73% #5589
Sep 23 pkg/controllers/remediation 68.82% 86.5% 0.07% #5595
Sep 24 pkg/controllers/unifiedauth 25.30% 71.30% 0.14% #5600
Sep 27 pkg/controllers/workloadrebalancer 63.07% 75.40% 0.18% #5606
Oct 1 pkg/detector/detector.go 19.58% 50.00% 0.73% #5631
Oct 2 pkg/scheduler/cache 7.50% 100% 0.10% #5637
Oct 4 pkg/scheduler/event_handler.go 26.53% 58.50% 0.14% #5641
Oct 5 pkg/scheduler/framework/plugins 0% 100% 0.19% #5642
Oct 5 pkg/scheduler/framework & metrics 0% 100% 0.12% #5644
Oct 6 pkg/scheduler/core/common.go 0% 95.20% 0.05% #5646
Oct 7 pkg/descheduler/core 78.75% 85.20% 0.03% #5649
Oct 8 pkg/descheduler/descheduler.go 59.14% 80.80% 0.08% #5653
Oct 10 pkg/util/lifted/validatingfhpa.go 0.00% 100% 0.50% #5663
Oct 11 pkg/util/lifted/podtemplate.go 0.00% 100% 0.08% #5682
Oct 12 pkg/scheduler/scheduler.go - Part 1 29.71% 66.90% 0.24% #5680
Oct 12 pkg/scheduler/scheduler.go - Part 2 29.71% 66.90% 0.18% #5681
Oct 13 pkg/util/lifted/validateclustertaints.go 0.00% 100% 0.04% #5684
Oct 13 pkg/util/lifted/validatingmcs.go 0.00% 100% 0.05% #5684
Oct 14 pkg/util/lifted/corev1printers.go - Part 1 8.76% 52.70% 0.24% #5695
Oct 15 pkg/util/membercluster_client.go 57% 92.10% 0.08% #5698
Oct 16 pkg/util/lifted/corev1printers.go - Part 2 52.79% 95.30% 0.30% #5700
Oct 18 pkg/detector/detector.go - Part 1 1.60% 32.50% 0.44% #5711
Oct 23 pkg/util/context.go - rount_trippers.go - policy.go 0% 100% 0.08% #5733
Oct 24 pkg/util/helper/work.go 27.76% 87.5% 0.10% #5742
@anujagrawal699 anujagrawal699 added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 2, 2024
@XiShanYongYe-Chang
Copy link
Member

ref #5235

@XiShanYongYe-Chang
Copy link
Member

Thanks @anujagrawal699
/assinn @anujagrawal699

@anujagrawal699
Copy link
Contributor Author

Thanks @anujagrawal699 /assinn @anujagrawal699

Typo in assign. Thanks!

@XiShanYongYe-Chang
Copy link
Member

Hi @anujagrawal699 @mohamedawnallah can I invite you to review each other's prs? Although you two test different modules, the techniques used in the test are the same. I hope you can learn some advantages from each other by reviewing each other.

To be honest, I've learned some programming skills from your pr, thank you.

@RainbowMango
Copy link
Member

Hi all,

I want to thank you for your contributions to the project. Your effort to increase test coverage is greatly appreciated and has significantly improved our codebase's quality.

But I noticed that some of the unit tests become quite complex and in some cases, exceed the complexity of the code being tested. While achieving high test coverage is important, it's also worth balancing test complexity and code maintainability. Overly complex tests can make the codebase harder to understand and maintain, which can lead to issues in the long run.

@anujagrawal699
Copy link
Contributor Author

Hi all,

I want to thank you for your contributions to the project. Your effort to increase test coverage is greatly appreciated and has significantly improved our codebase's quality.

But I noticed that some of the unit tests become quite complex and in some cases, exceed the complexity of the code being tested. While achieving high test coverage is important, it's also worth balancing test complexity and code maintainability. Overly complex tests can make the codebase harder to understand and maintain, which can lead to issues in the long run.

Hi @RainbowMango , thanks for your appreciation. I agree to with you to balance test complexity and code maintainability. I'll keep the following thing in mind while further contributing and keep the code more maintainable and reliable.

@XiShanYongYe-Chang
Copy link
Member

Hi @anujagrawal699 the lfx activity is almost closed, and I've given you the final feedback. Thank you for your excellent contribution. Now, I'd like to see what files are left to add tests, so we can continue to add them, even if the campaign is over.

In view of your outstanding performance in the Karmada community, I'd like to invite you to join Karmada as a member. Would you like to do so?

@anujagrawal699
Copy link
Contributor Author

Hi @anujagrawal699 the lfx activity is almost closed, and I've given you the final feedback. Thank you for your excellent contribution. Now, I'd like to see what files are left to add tests, so we can continue to add them, even if the campaign is over.

In view of your outstanding performance in the Karmada community, I'd like to invite you to join Karmada as a member. Would you like to do so?

Thank you so much! The estimator and dependenciesdistributor package are remaining and I'll continue writing tests for it. I would be honored to join Karmada as a member and look forward to making more contributions to the community.
I'll always be in debt to you and @zhzhuang-zju for your guidance and the place of Guru you both have for me.

@zhzhuang-zju
Copy link
Contributor

@anujagrawal699 You have shown great enthusiasm and professional ability in this LFX. I have also gained a lot during the review process. I am very willing to vote on your Membership Issue.

@anujagrawal699
Copy link
Contributor Author

@anujagrawal699 You have shown great enthusiasm and professional ability in this LFX. I have also gained a lot during the review process. I am very willing to vote on your Membership Issue.

Thank you so much! @zhzhuang-zju

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
Status: No status
Development

No branches or pull requests

5 participants