#48407 Add test coverage module for lib389 repo
Closed: wontfix None Opened 5 years ago by spichugi.

We need some module that will show us how much lines of code is covered by tests. Also, we need to show this information somewhere.

Let's discuss it and implement after that.


There are two factors to consider in this.

We can cover lines in the python code very easily with something like coverage [0]

I think what's more important is to find a way to determine code coverage in the main body of ns-slapd C code. But this ticket I believe is more about lib389.

[0] https://pypi.python.org/pypi/pytest-cov

I've tested '''pytest-cov''' and it works perfectly.

All we need is to:
install '''python-pytest-cov''' package from Fedora or EPEL repos (for CI we should add "pytest-cov" line to requirements.txt);
create '''.coveragerc''' file at the root of the repo
{{{
[run]
omit = lib389/tests/
}}}
add "--cov-config .coveragerc --cov=lib389" to our py.test command

And then we will have coverage report printed in the end of the test run.

The issue that we should resolve is RHEL compatibility, because there is no package in default RHEL repos.

What do you think, team? Should we set up all these steps anyway, even there is no RHEL package with pytest-cov?

I have no issue with that because we would likely run this on our local machines or controlled dev systems.

This is just checking coverage of what we test internal to lib389. We can't easily add test coverage to the C code base.

Take a look at #48399 because we may be able to add the test-with-coverage or similar as a make target to help us in the team out too.

Can you add the .coveragerc as a patch?

Can you provide an example of the current output?

Thanks for your work on this!

This is how test coverage output looks like.

{{{
---------- coverage: platform linux2, python 2.7.10-final-0 ----------
Name Stmts Miss Cover
----------------------------------------------------------------------
lib389/init.py 1447 1048 28%
lib389/_constants.py 276 276 0%
lib389/_controls.py 60 27 55%
lib389/_entry.py 245 106 57%
lib389/_ldifconn.py 25 9 64%
lib389/_replication.py 132 132 0%
lib389/aci.py 13 0 100%
lib389/agreement.py 278 86 69%
lib389/backend.py 149 32 79%
lib389/brooker.py 62 46 26%
lib389/changelog.py 60 32 47%
lib389/clitools/init.py 37 37 0%
lib389/clitools/ds_list_instances.py 11 11 0%
lib389/clitools/ds_monitor_backend.py 19 19 0%
lib389/clitools/ds_monitor_server.py 16 16 0%
lib389/clitools/ds_schema_attributetype_list.py 15 15 0%
lib389/clitools/ds_schema_attributetype_query.py 24 24 0%
lib389/clitools/ds_start.py 14 14 0%
lib389/clitools/ds_stop.py 14 14 0%
lib389/clitools/krb_create_keytab.py 18 18 0%
lib389/clitools/krb_create_principal.py 17 17 0%
lib389/clitools/krb_create_realm.py 16 16 0%
lib389/clitools/krb_destroy_realm.py 16 16 0%
lib389/ds_instance.py 43 6 86%
lib389/index.py 54 34 37%
lib389/mappingTree.py 151 29 81%
lib389/mit_krb5.py 124 37 70%
lib389/monitor.py 45 34 24%
lib389/plugins.py 40 27 33%
lib389/properties.py 222 217 2%
lib389/replica.py 367 171 53%
lib389/schema.py 86 38 56%
lib389/suffix.py 35 8 77%
lib389/tasks.py 534 500 6%
lib389/tools.py 628 520 17%
lib389/utils.py 329 263 20%
----------------------------------------------------------------------
TOTAL 5622 3895 31%

==================== 60 passed in 2078.52 seconds ====================
}}}

I had a look on #48399. Viktor works on that now and he plans to provide some script that related to this issue soon.

P.S. I will continue to search some ways to cover our 389-ds the C code base.

I'm happy with this, ack.

So can we close this ticket?

To ssh://git.fedorahosted.org/git/389/lib389.git
82d2854..2c87c62 master -> master
commit 2c87c622d2ee50281b16d342d0cf4f0a543720a8
Author: Simon Pichugin spichugi@redhat.com
Date: Tue Feb 16 19:08:19 2016 +0100

Metadata Update from @firstyear:
- Issue set to the milestone: lib389 1.0.2

4 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/389ds/389-ds-base/issues/1738

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Metadata Update from @spichugi:
- Issue close_status updated to: wontfix (was: Fixed)

a year ago

Login to comment on this ticket.

Metadata