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

Increase scenario coverage for each package that has less than 80% #812

Open
denis-tingaikin opened this issue Apr 9, 2021 · 5 comments
Labels
enhancement New feature or request investigation Something that should be investigated.

Comments

@denis-tingaikin
Copy link
Member

denis-tingaikin commented Apr 9, 2021

Our current coverage for 0d2dc28 is:

?       github.com/networkservicemesh/sdk/pkg/networkservice/chains/client      [no test files]
?       github.com/networkservicemesh/sdk/pkg/networkservice/chains/endpoint    [no test files]
ok      github.com/networkservicemesh/sdk/pkg/networkservice/chains/nsmgr       12.069s coverage: 92.1% of statements
?       github.com/networkservicemesh/sdk/pkg/networkservice/chains/nsmgr/peertracker   [no test files]
ok      github.com/networkservicemesh/sdk/pkg/networkservice/chains/nsmgrproxy  1.931s  coverage: 73.3% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/authorize   1.320s  coverage: 42.2% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/clientinfo  0.823s  coverage: 85.7% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/clienturl   0.577s  coverage: 100.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/connect     1.186s  coverage: 80.8% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/discover    2.374s  coverage: 79.7% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/excludedprefixes    2.404s  coverage: 87.2% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/externalips 1.491s  coverage: 71.1% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/filtermechanisms    1.326s  coverage: 93.3% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/heal        0.629s  coverage: 64.4% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/interdomainurl      0.771s  coverage: 58.3% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/interpose   0.531s  coverage: 72.5% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/journal     1.172s  coverage: 62.5% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms  0.561s  coverage: 98.0% of statements
?       github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/checkmechanism   [no test files]
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/kernel   0.307s  coverage: 69.2% of statements
?       github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/recvfd   [no test files]
?       github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd   [no test files]
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/supported        0.534s  coverage: 100.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanismtranslation        0.653s  coverage: 73.5% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/monitor     1.093s  coverage: 90.7% of statements
?       github.com/networkservicemesh/sdk/pkg/networkservice/common/null        [no test files]
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/refresh     2.802s  coverage: 85.7% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/roundrobin  0.612s  coverage: 29.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/serialize   0.608s  coverage: 50.0% of statements
?       github.com/networkservicemesh/sdk/pkg/networkservice/common/setextracontext     [no test files]
?       github.com/networkservicemesh/sdk/pkg/networkservice/common/setlogoption        [no test files]
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/swapip      1.118s  coverage: 76.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/timeout     2.321s  coverage: 78.2% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/updatepath  0.650s  coverage: 75.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/updatetoken 0.683s  coverage: 70.4% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext       1.159s  coverage: 86.9% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/core/adapters      0.917s  coverage: 37.0% of statements
?       github.com/networkservicemesh/sdk/pkg/networkservice/core/chain [no test files]
ok      github.com/networkservicemesh/sdk/pkg/networkservice/core/eventchannel  1.581s  coverage: 99.0% of statements
?       github.com/networkservicemesh/sdk/pkg/networkservice/core/next  [no test files]
ok      github.com/networkservicemesh/sdk/pkg/networkservice/core/next/tests    0.530s  coverage: 95.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/core/trace 0.308s  coverage: 70.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/ipam/point2pointipam       0.314s  coverage: 93.2% of statements
?       github.com/networkservicemesh/sdk/pkg/networkservice/utils/checks/checkconnection       [no test files]
?       github.com/networkservicemesh/sdk/pkg/networkservice/utils/checks/checkcontext  [no test files]
?       github.com/networkservicemesh/sdk/pkg/networkservice/utils/checks/checkcontextonreturn  [no test files]
ok      github.com/networkservicemesh/sdk/pkg/networkservice/utils/checks/checkerror    0.644s  coverage: 95.2% of statements
?       github.com/networkservicemesh/sdk/pkg/networkservice/utils/checks/checkopts     [no test files]
?       github.com/networkservicemesh/sdk/pkg/networkservice/utils/checks/checkrequest  [no test files]
?       github.com/networkservicemesh/sdk/pkg/networkservice/utils/inject/injecterror   [no test files]
?       github.com/networkservicemesh/sdk/pkg/networkservice/utils/inject/injectopts    [no test files]
ok      github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata     0.438s  coverage: 74.5% of statements
?       github.com/networkservicemesh/sdk/pkg/registry  [no test files]
?       github.com/networkservicemesh/sdk/pkg/registry/chains/client    [no test files]
?       github.com/networkservicemesh/sdk/pkg/registry/chains/memory    [no test files]
?       github.com/networkservicemesh/sdk/pkg/registry/chains/proxydns  [no test files]
ok      github.com/networkservicemesh/sdk/pkg/registry/common/clienturl 0.760s  coverage: 51.4% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/connect   1.702s  coverage: 77.8% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/dnsresolve        1.026s  coverage: 79.8% of statements
?       github.com/networkservicemesh/sdk/pkg/registry/common/endpointurls      [no test files]
ok      github.com/networkservicemesh/sdk/pkg/registry/common/expire    5.052s  coverage: 71.1% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/interpose 0.780s  coverage: 63.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/localbypass       0.944s  coverage: 85.7% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/memory    1.889s  coverage: 68.7% of statements
?       github.com/networkservicemesh/sdk/pkg/registry/common/null      [no test files]
ok      github.com/networkservicemesh/sdk/pkg/registry/common/proxy     3.133s  coverage: 80.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/querycache        0.781s  coverage: 83.8% of statements
?       github.com/networkservicemesh/sdk/pkg/registry/common/recvfd    [no test files]
ok      github.com/networkservicemesh/sdk/pkg/registry/common/refresh   1.282s  coverage: 72.6% of statements
?       github.com/networkservicemesh/sdk/pkg/registry/common/sendfd    [no test files]
ok      github.com/networkservicemesh/sdk/pkg/registry/common/serialize 0.518s  coverage: 22.2% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/setid     0.725s  coverage: 58.1% of statements
?       github.com/networkservicemesh/sdk/pkg/registry/common/setlogoption      [no test files]
ok      github.com/networkservicemesh/sdk/pkg/registry/common/swap      0.276s  coverage: 57.9% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/core/adapters    0.313s  coverage: 81.4% of statements
?       github.com/networkservicemesh/sdk/pkg/registry/core/chain       [no test files]
ok      github.com/networkservicemesh/sdk/pkg/registry/core/interdomain 1.294s  coverage: [no statements]
ok      github.com/networkservicemesh/sdk/pkg/registry/core/next        0.935s  coverage: 96.3% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/core/nextwrap    0.591s  coverage: 60.0% of statements
?       github.com/networkservicemesh/sdk/pkg/registry/core/streamchannel       [no test files]
?       github.com/networkservicemesh/sdk/pkg/registry/core/streamcontext       [no test files]
?       github.com/networkservicemesh/sdk/pkg/registry/core/trace       [no test files]
?       github.com/networkservicemesh/sdk/pkg/registry/utils/checks/checkcontext        [no test files]
?       github.com/networkservicemesh/sdk/pkg/registry/utils/checks/checknse    [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/addressof   [no test files]
ok      github.com/networkservicemesh/sdk/pkg/tools/cidr        0.267s  coverage: 100.0% of statements
?       github.com/networkservicemesh/sdk/pkg/tools/clientinfo  [no test files]
ok      github.com/networkservicemesh/sdk/pkg/tools/clientmap   1.050s  coverage: 5.9% of statements [no tests to run]
?       github.com/networkservicemesh/sdk/pkg/tools/clienturlctx        [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/clock       [no test files]
ok      github.com/networkservicemesh/sdk/pkg/tools/clockmock   2.068s  coverage: 80.4% of statements
?       github.com/networkservicemesh/sdk/pkg/tools/debug       [no test files]
ok      github.com/networkservicemesh/sdk/pkg/tools/dnscontext  0.951s  coverage: 96.6% of statements
?       github.com/networkservicemesh/sdk/pkg/tools/extend      [no test files]
ok      github.com/networkservicemesh/sdk/pkg/tools/fs  0.880s  coverage: 53.7% of statements
ok      github.com/networkservicemesh/sdk/pkg/tools/grpcutils   0.675s  coverage: 35.2% of statements
?       github.com/networkservicemesh/sdk/pkg/tools/interdomain [no test files]
ok      github.com/networkservicemesh/sdk/pkg/tools/ippool      0.602s  coverage: 74.0% of statements
?       github.com/networkservicemesh/sdk/pkg/tools/jaeger      [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/log [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger    [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/log/spanlogger      [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/matchutils  [no test files]
ok      github.com/networkservicemesh/sdk/pkg/tools/multiexecutor       0.821s  coverage: 100.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/tools/nsurl       0.668s  coverage: 100.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/tools/opa 0.780s  coverage: 79.4% of statements
?       github.com/networkservicemesh/sdk/pkg/tools/opentracing [no test files]
ok      github.com/networkservicemesh/sdk/pkg/tools/prefixpool  0.590s  coverage: 88.6% of statements
?       github.com/networkservicemesh/sdk/pkg/tools/sandbox     [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/serializectx        [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/signalctx   [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/spiffejwt   [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/spire       [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/stringurl   [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/token       [no test files]
?       github.com/networkservicemesh/sdk/pkg/tools/typeutils   [no test files]
@denis-tingaikin
Copy link
Member Author

denis-tingaikin commented Apr 9, 2021

@fkautz , @edwarnicke Is 80% enough coverage?

@denis-tingaikin denis-tingaikin added enhancement New feature or request investigation Something that should be investigated. labels Apr 9, 2021
@edwarnicke
Copy link
Member

@denis-tingaikin 80% is probably the right amount. Code coverage itself is basically meaningless. I can get 100% code coverage over code without necessarily exercising all possible cases. It's also important to understand that unit tests don't necessarily test code correctness (though that's always the goal), they test that code behavior does not change. Finally some error cases are almost impossible to 'force' without doing deeply unnatural things to your code to allow exercising them.

None of which means code coverage isn't a good idea... it just means obsessing about it isn't a good idea :)

80% is a pretty good middle ground goal. It prevents the unproductive obsessive drive to 100% when that is unreasonable or undesirable... but it encourages good levels of coverage.

All of that said... we are likely to find cases (like recvfd/sendfd) where unit tests will be extremely hard to reasonable execute, so intelligent discretion should be employed.

@denis-tingaikin denis-tingaikin changed the title Increase code coverage for each package that has less than 80% Increase scenario coverage for each package that has less than 80% Apr 20, 2021
@denis-tingaikin
Copy link
Member Author

denis-tingaikin commented Apr 20, 2021

After manual filtering (by criteria 80% and what will not be reworked in the next days) we have this:

ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/heal        0.629s  coverage: 64.4% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/interpose   0.531s  coverage: 72.5% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/journal     1.172s  coverage: 62.5% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/kernel   0.307s  coverage: 69.2% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanismtranslation        0.653s  coverage: 73.5% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/roundrobin  0.612s  coverage: 29.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/serialize   0.608s  coverage: 50.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/timeout     2.321s  coverage: 78.2% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/updatepath  0.650s  coverage: 75.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/common/updatetoken 0.683s  coverage: 70.4% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext       1.159s  coverage: 86.9% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/core/adapters      0.917s  coverage: 37.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/core/trace 0.308s  coverage: 70.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata     0.438s  coverage: 74.5% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/clienturl 0.760s  coverage: 51.4% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/connect   1.702s  coverage: 77.8% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/expire    5.052s  coverage: 71.1% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/interpose 0.780s  coverage: 63.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/memory    1.889s  coverage: 68.7% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/refresh   1.282s  coverage: 72.6% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/serialize 0.518s  coverage: 22.2% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/common/setid     0.725s  coverage: 58.1% of statements
ok      github.com/networkservicemesh/sdk/pkg/registry/core/nextwrap    0.591s  coverage: 60.0% of statements
ok      github.com/networkservicemesh/sdk/pkg/tools/fs  0.880s  coverage: 53.7% of statements
ok      github.com/networkservicemesh/sdk/pkg/tools/grpcutils   0.675s  coverage: 35.2% of statements
ok      github.com/networkservicemesh/sdk/pkg/tools/ippool      0.602s  coverage: 74.0% of statements

@denis-tingaikin
Copy link
Member Author

Finally, I think we should add new unit tests during fixing issues, then we'll increase code coverage naturally.

@edwarnicke
Copy link
Member

@denis-tingaikin There's a good balance there as well... testing is a good way to make sure things stay the way you expect them to be. If you put in too much testing to early, it becomes an impediment to fixing bugs (because to much testing can bake in design bugs)... if you have to little, you lack the confidence to make changes.

I definitely agree that when we find issues downstream we need to fix its a good thing to add unit tests earlier to make sure they don't recur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request investigation Something that should be investigated.
Projects
None yet
Development

No branches or pull requests

3 participants