Skip to content

Conversation

@chethanv28
Copy link
Collaborator

@chethanv28 chethanv28 commented Nov 12, 2025

What this PR does / why we need it:
PR is adding Code coverage analysis for existing unit tests & then use the summary in make build.
As of today we have a very low overall code coverage. So, adding a check for overall code coverage does not make sense. But for the existing unit tests & any new tests that get added in the future we will have threshold of 75% coverage in amek build process itself.

The make build will execute the below steps:
✅ Compile the binaries
✅ Run unit tests with coverage
✅ Validate that tested functions have good coverage (≥75%) (For existing unit tests or any new unit tests that get added)
❌ Fail the build if code coverage drops below 75% For existing unit tests or any new unit tests that get added)

This is not a PR to increase the code coverage but intent is to introduce the code coverage analysis tool for every new check-in from now on.

We will continue to print the below summary until we reach overall coverage goal of 75~80%

Analyzing coverage quality (excluding 0% functions)...
Total functions: 1028
Functions with 0% coverage: 790 (76.8%)
Functions with >0% coverage: 238 (23.2%)
Overall coverage (including 0%): 17.7%
Quality coverage (excluding 0%): 76.6%
SUCCESS: Quality coverage 76.6% meets threshold 75.0%
NOTE: Consider adding tests for 790 untested functions to improve overall coverage.

Testing done:
$ make build

[Terminal output truncated: ~805KB dropped from beginning]
driver/v3/pkg/common/config/config.go:333:										isValidvCenterUsernameWithDomain				100.0%
sigs.k8s.io/vsphere-csi-driver/v3/pkg/common/config/config.go:343:										validateConfig							69.5%
sigs.k8s.io/vsphere-csi-driver/v3/pkg/common/config/config.go:513:										ReadConfig							0.0%
sigs.k8s.io/vsphere-csi-driver/v3/pkg/common/config/config.go:531:										GetCnsconfig							0.0%
sigs.k8s.io/vsphere-csi-driver/v3/pkg/common/config/config.go:567:										GetDefaultNetPermission						100.0%
sigs.k8s.io/vsphere-csi-driver/v3/pkg/common/config/config.go:579:										FromEnvToGC							0.0%
...
...
total:																		(statements)							17.1%
Analyzing coverage quality (excluding 0% functions)...
Total functions: 1028
Functions with 0% coverage: 793 (77.1%)
Functions with >0% coverage: 235 (22.9%)
Overall coverage (including 0%): 17.6%
Quality coverage (excluding 0%): 76.9%
SUCCESS: Quality coverage 76.9% meets threshold 75.0%
NOTE: Consider adding tests for 793 untested functions to improve overall coverage.

Special notes for your reviewer:

Release note:

Code coverage for unit tests

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 12, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chethanv28

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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 12, 2025
@chethanv28
Copy link
Collaborator Author

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Nov 12, 2025
@chethanv28 chethanv28 force-pushed the topic/chethanv28/add-code-coverage-summary branch from eff4de3 to bdecb15 Compare November 12, 2025 20:10
@chethanv28 chethanv28 requested review from deepakkinni and xing-yang and removed request for kolluria November 12, 2025 20:30
@chethanv28 chethanv28 changed the title Code coverage for unit tests Code coverage for existing unit tests Nov 12, 2025
@k8s-ci-robot k8s-ci-robot 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 13, 2025
@deepakkinni
Copy link
Collaborator

Triggering CSI-WCP Pre-checkin Pipeline for this PR... Job takes approximately an hour to complete
Jenkins Build #592

@deepakkinni
Copy link
Collaborator

SUCCESS --- Jenkins Build #592

@chethanv28
Copy link
Collaborator Author

/test pull-vsphere-csi-driver-verify-golangci-lint

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

3 participants