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 cmd/descheduler #5445

Merged

Conversation

anujagrawal699
Copy link
Contributor

Description:
This PR introduces tests for cmd/descheduler/app/descheduler.go .

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

What this PR does / why we need it:
This PR adds comprehensive tests for testing core functionality of cmd/descheduler .

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

Does this PR introduce a user-facing change?:

NONE

@karmada-bot karmada-bot added 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. labels Aug 28, 2024
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 28, 2024
@anujagrawal699
Copy link
Contributor Author

Hey @XiShanYongYe-Chang is there a need to test cmd/descheduler/app/options/options.go?

@anujagrawal699 anujagrawal699 force-pushed the addedTests-cmd/descheduler branch from 3a7c3dc to 462a677 Compare August 28, 2024 17:12
@anujagrawal699
Copy link
Contributor Author

I refactored the pr and tried to avoid tests that are likely to break with minor, inconsequential changes.

@anujagrawal699
Copy link
Contributor Author

I FORGOT TO PULL THE LATEST COMMITS :) . @XiShanYongYe-Chang Please don't review i'll update the tests.

@XiShanYongYe-Chang
Copy link
Member

Hi @anujagrawal699 the lint ci is failed.
/assign

@karmada-bot karmada-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 29, 2024
@anujagrawal699 anujagrawal699 force-pushed the addedTests-cmd/descheduler branch from 394ecfc to 086599f Compare August 29, 2024 05:03
@karmada-bot karmada-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 29, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 29, 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 31.27%. Comparing base (2efe03f) to head (9d5e86e).
Report is 110 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    #5445      +/-   ##
==========================================
+ Coverage   31.14%   31.27%   +0.13%     
==========================================
  Files         640      640              
  Lines       44417    44417              
==========================================
+ Hits        13832    13890      +58     
+ Misses      29583    29519      -64     
- Partials     1002     1008       +6     
Flag Coverage Δ
unittests 31.27% <ø> (+0.13%) ⬆️

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
Copy link
Contributor Author

@XiShanYongYe-Chang Please take a look.

@XiShanYongYe-Chang
Copy link
Member

Thanks
/assign

healthAddress := "127.0.0.1:8082"
metricsAddress := "127.0.0.1:8083"

go serveHealthzAndMetrics(healthAddress, metricsAddress)
Copy link
Member

Choose a reason for hiding this comment

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

Too many arguments in call to 'serveHealthzAndMetrics'

Copy link
Contributor Author

@anujagrawal699 anujagrawal699 Aug 29, 2024

Choose a reason for hiding this comment

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

@XiShanYongYe-Chang I made the same error. Few days a ago a commit changed the 'serveHealthzAndMetrics' and the new implementation is

func serveHealthzAndMetrics(healthProbeBindAddress, metricsBindAddress string) {
	if healthProbeBindAddress == metricsBindAddress {
		if healthProbeBindAddress != "0" {
			go serveCombined(healthProbeBindAddress)
		}
	} else {
		if healthProbeBindAddress != "0" {
			go serveHealthz(healthProbeBindAddress)
		}
		if metricsBindAddress != "0" {
			go serveMetrics(metricsBindAddress)
		}
	}
}

Your local might be behind by some commits.

Copy link
Member

Choose a reason for hiding this comment

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

Can you rebase the latest master code and re-push it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay

@anujagrawal699 anujagrawal699 force-pushed the addedTests-cmd/descheduler branch from 086599f to a2fc7dd Compare August 29, 2024 07:39
@karmada-bot karmada-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 29, 2024
@anujagrawal699 anujagrawal699 force-pushed the addedTests-cmd/descheduler branch from a2fc7dd to 7a7b025 Compare August 29, 2024 07:43
@karmada-bot karmada-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 29, 2024
Signed-off-by: Anuj Agrawal <[email protected]>

Added tests for cmd/descheduler

Signed-off-by: Anuj Agrawal <[email protected]>
@anujagrawal699 anujagrawal699 force-pushed the addedTests-cmd/descheduler branch from 7a7b025 to 9d5e86e Compare August 29, 2024 07:58
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.

Good job!
/lgtm
/approve

assert.NotEmpty(t, cmd.Long)
}

func TestDeschedulerCommandFlagParsing(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

This test case feels good 👍

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 tried to keep it maintainable and not prone to break with minor changes.

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 29, 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 Aug 29, 2024
@karmada-bot karmada-bot merged commit 12f881b into karmada-io:master Aug 29, 2024
12 checks passed
@anujagrawal699
Copy link
Contributor Author

Hey @XiShanYongYe-Chang is there a need to test cmd/descheduler/app/options/options.go?

@XiShanYongYe-Chang
Copy link
Member

Hey @XiShanYongYe-Chang is there a need to test cmd/descheduler/app/options/options.go?

Is it possible to make a valid test? If so, please add it.

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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants