You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/05/22 09:56:18 UTC

[GitHub] chetanmeh opened a new pull request #3685: Enable test code coverage collection for containers

chetanmeh opened a new pull request #3685: Enable test code coverage collection for containers
URL: https://github.com/apache/incubator-openwhisk/pull/3685
 
 
   Enables collection of test code coverage for code running within containers like Controller and Invoker
   
   ## Description
   
   So far with #3249 we have been collecting test code coverage data from unit and system test for code which need not be running within container. However some of the code paths can only be exercised within a running container. This PR enables collecting test code coverage stats for such code paths.
   
   As explained in #3243 scoverage creates `build/scoverage/scoverage.measurements.xxx` files (xxx maps to threadId) at runtime to record any code path being hit. Instrumented code has compile time configured paths for the data directory. So for code compiled for coverage data collection on travis the instrumented code would try to write the measurement file under _/home/travis/build/apache/incubator-openwhisk/core/controller/build/scoverage_
   
   For normal scenario when code is running outside of container such files are written within `build/scoverage` directory and is accessible when generating reports. However when code runs within container its not possible to access such generated files. To enable that following approach has been taken
   
   ### Preparing Instrumented Containers
   
   Docker build now supports a `distDockerCoverage` task which generate a new image for controller and invoker containing instrumented code based on `Dockerfile.cov` file. 
   
   The instrumented container 
   
   * Is tagged with `cov` tag e.g. `whisk/controller:cov`
   * Adds scoverage runtime jars and replaces existing openwhisk-common etc jars with those generated by scoverage task
   * Adds symlinks in container for data directory path
   
   ### Running Instrumented Containers
   
   Further ansible playbooks are modified to look for `GRADLE_COVERAGE` environment variable to enable some specific tasks. Once enabled the new tasks would
   
   1. Create specific directory for controller and invoker like `/tmp/wskcov/controller`
   2. Expose these directory as shared volume with path `/coverage`
   
   Once running a path like  _/home/travis/build/apache/incubator-openwhisk/core/controller/build/scoverage_ would be symlinked to `/coverage/controller` which inturn is pointing to `/tmp/wskcov/controller/controller`
   
   ### Report Generation
   
   In test module the report generation task would copy all such measurement files from directories under `/tmp/wskcov` to respective modules. The file names would be changed to ensure that they are unique. Post this report would include stats from code running within containers.
   
   ## Related issue and scope
   <!--- Please include a link to a related issue if there is one. -->
   - [ ] I opened an issue to propose and discuss this change (#3243)
   
   ## My changes affect the following components
   <!--- Select below all system components are affected by your change. -->
   <!--- Enter an `x` in all applicable boxes. -->
   - [ ] API
   - [ ] Controller
   - [ ] Message Bus (e.g., Kafka)
   - [ ] Loadbalancer
   - [ ] Invoker
   - [ ] Intrinsic actions (e.g., sequences, conductors)
   - [ ] Data stores (e.g., CouchDB)
   - [x] Tests
   - [ ] Deployment
   - [ ] CLI
   - [ ] General tooling
   - [ ] Documentation
   
   ## Types of changes
   <!--- What types of changes does your code introduce? Use `x` in all the boxes that apply: -->
   - [ ] Bug fix (generally a non-breaking change which closes an issue).
   - [x] Enhancement or new feature (adds new functionality).
   - [ ] Breaking change (a bug fix or enhancement which changes existing behavior).
   
   ## Checklist:
   <!--- Please review the points below which help you make sure you've covered all aspects of the change you're making. -->
   
   - [x] I signed an [Apache CLA](https://github.com/apache/incubator-openwhisk/blob/master/CONTRIBUTING.md).
   - [x] I reviewed the [style guides](https://github.com/apache/incubator-openwhisk/wiki/Contributing:-Git-guidelines#code-readiness) and followed the recommendations (Travis CI will check :).
   - [ ] I added tests to cover my changes.
   - [ ] My changes require further changes to the documentation.
   - [ ] I updated the documentation where necessary.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services