-
Notifications
You must be signed in to change notification settings - Fork 367
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
Improve unit test of flowexporter package #4182
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4182 +/- ##
==========================================
+ Coverage 57.25% 60.65% +3.39%
==========================================
Files 380 384 +4
Lines 53791 54375 +584
==========================================
+ Hits 30799 32981 +2182
+ Misses 20655 18961 -1694
- Partials 2337 2433 +96
|
Hi @tnqn , I found the coverage of pkg/agent/flowexporter is already over 78%. I looked into the individual files, didn't find much I can add. Many of the uncovered lines are just error logging. So I only fixed a small error in one of the test, and added one single test case. Do you think it will be ok for now? |
@heanlan I listed the package because unit test report show around 50% coverage for several sub-packages of it and I took a quick look at the source code and thought some of them may be error prone without an unit test, e.g. antrea/pkg/agent/flowexporter/priorityqueue/priorityqueue.go Lines 113 to 127 in 7a3f6e2
As explained in #4142 (comment), I guess the reason why its overall coverage looks fine is because the major code of this package will be executed when the program runs e2e to e2e, but does it mean the code work as expected in various situation? For example, if I remove L107 from the following code, would any test fail? If not, it would be a memory leak but the coverage still looks good. antrea/pkg/agent/flowexporter/priorityqueue/priorityqueue.go Lines 100 to 109 in 7a3f6e2
For a tool like |
Thanks @tnqn , I think I got your point. I previously didn't realize the coverage report does not only include UT coverage. I will re-evaluate the coverage in your suggested way.
Could you show me where to find the coverage report for exact unit test? In https://app.codecov.io/gh/antrea-io/antrea/tree/main/pkg/agent/flowexporter, I only see the coverage for file
For |
You could run
|
c87a2f6
to
aefef72
Compare
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.
LGTM
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.
LGTM
Add more test cases for pkg/agent/flowexporter package and its subpackages: connections, exporter, priorityqueue. For antrea-io#4142 Signed-off-by: heanlan <hanlan@vmware.com>
e224a73
to
7ab0f23
Compare
squashed the commits |
Hi @tnqn , would you like to take a look at the PR? Thanks |
Found I missed to git add a new test file... It includes the unit tests of |
Signed-off-by: heanlan <hanlan@vmware.com>
d1a2ec1
to
7b03299
Compare
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.
LGTM, thanks
/skip-all |
Add more test cases for pkg/agent/flowexporter package and its subpackages: connections, exporter, priorityqueue. For antrea-io#4142 Signed-off-by: heanlan <hanlan@vmware.com>
Add more test cases for pkg/agent/flowexporter package and
its subpackages: connections, exporter, priorityqueue.
For #4142
Signed-off-by: heanlan hanlan@vmware.com