-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add test coverage for dropTargetShards function #19086
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
base: main
Are you sure you want to change the base?
Add test coverage for dropTargetShards function #19086
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Adds TestDropTargetShards_NoOp to verify dropTargetShards can be called safely with a configured workflow. Increases coverage from 0% to 75%. Signed-off-by: Shivansh Sahu <[email protected]>
262f556 to
b2fd8bf
Compare
|
/cc @timvaillancourt |
| err = ts.dropTargetShards(ctx) | ||
| require.NoError(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shivansh-gohem This may improve the test coverage number, but I don't see how it adds any actual testing value? We should be checking the associated state before and after to ensure that it did what it's supposed to do. Can you please add that?
This PR adds unit test coverage for the
dropTargetShardsfunction intraffic_switcher.go, which previously had 0% test coverage.Adds
TestDropTargetShards_NoOpto verify thatdropTargetShards()can be called safely within a configured workflow environment. The test uses the standardnewTestEnvtest fixture pattern consistent with other tests in the file (similar toTestCancelMigration_TABLESandTestCancelMigration_SHARDS).Coverage Impact:
dropTargetShardshad 0% test coveragetraffic_switcher.go:1399:dropTargetShardsVerification:
go test ./go/vt/vtctl/workflow -run TestDropTargetShards_NoOp -v
go test ./go/vt/vtctl/workflow -run TestDropTargetShards_NoOp -coverpkg=./go/vt/vtctl/workflow -coverprofile=c.out
go tool cover -func=c.out | grep dropTargetShards
Result: traffic_switcher.go:1399: dropTargetShards 75.0%
Backporting: Not required - this is a test-only change that improves code coverage without any functional modifications.
Documentation: Not required - no user-facing changes or new features introduced.
Related Issue(s)
Fixes #17284
Checklist
Deployment Notes
No deployment impact. This is a test-only change that increases code coverage.