-
Notifications
You must be signed in to change notification settings - Fork 127
Generate a cobertura report for processors in pipeline tests #704
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
Conversation
This improves the coverage reporting (--test-coverage flag) to include detailed coverage for ingest pipelines in the pipeline test.
|
|
||
| if testCoverage && len(dataStreams) > 0 { | ||
| return cobraext.FlagParsingError(errors.New("test coverage can be calculated only if all data streams are selected"), cobraext.DataStreamsFlagName) | ||
| } |
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.
This restriction has been removed for convenience, as coverage reports are useful during development and we may want to test as quick as possible and only the data stream being developed.
|
Pinging @elastic/integrations (Team:Integrations) |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
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.
Could you please describe how will the coverage calculation change once this PR is merged?
Consider the following cases:
- Run
test- cover all data streams of a package - Run
test --data-stream foo- cover only thefoodata stream - Run
test pipeline- cover all data streams, but only pipeline tests - Run
test- but no tests present
Sorry for adding more tasks to do, but I'd like to double-check if there are any risky side effects.
Also, what kind of changes do we need on the CI side?
|
|
||
| type coberturaCoverage struct { | ||
| // CoberturaCoverage is the root element for a Cobertura XML report. | ||
| type CoberturaCoverage struct { |
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.
Is there any reason why these properties are exposed? Is it for the consistency with CoberturaCoverage?
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.
I think I got mixed here a little bit. The original idea was for the test runners to have the option to generate their own coverage in Cobertura format (via the new TestResult.Coverage), that's why these types are exposed.
To align with this idea, I think it makes more sense to put GetPipelineCoverage into the pipeline runner instead of the global testrunner package as is now.
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.
To align with this idea, I think it makes more sense to put GetPipelineCoverage into the pipeline runner instead of the global testrunner package as is now.
Yes, I have a similar feeling about this :)
| API: esClient.API, | ||
| DeferCleanup: deferCleanup, | ||
| ServiceVariant: variantFlag, | ||
| WithCoverage: testCoverage, |
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.
Does this property apply to all test runners (system tests, static tests, etc.)? Maybe we should add a WARN informing if we can't calculate the coverage properly.
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.
The way I see it we have the old default coverage, which only tells whether we have a particular kind of test for the package, and the opt-in detailed coverage added by this PR. Each individual test runner can err if they wanted to calculate detailed coverage but failed, as the pipeline tests will do after this PR.
|
@adriansr Please re-request the review when this PR is ready for another round. It would be great to research these cases. |
Before this PR, it generates a reduced coverage report for each kind of test (system, static, asset, pipeline...). Each of these tests contains a single package (name of integration package), then one class per data_stream (class name: test type, class filename: package/datastream). After this PR, the output is the same, except for the pipeline coverage report, which contains processor coverage of the ingest pipelines:
Before: It's not possible to run a coverage report for a single data-stream.
Before: You get the reduced coverage report (OK / Missing).
Only the reduced coverage reports are present.
It needs some investigation, but basically make sure that the source code for pipelines is in place by the time the coverage reports are rendered. |
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.
Thanks for providing more information, Adrian. I see only concerns around integrating this change with our CI. I left a comment in a relevant place in the source code.
Apart from this, I think it's 👍 .
| wantErr bool | ||
| }{ | ||
| { | ||
| name: "merge sources", |
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.
nit: I'm thinking now if it isn't simpler and easier to read to load these tests from a testdata directory. WDYT?
|
|
||
| // GetPipelineCoverage returns a coverage report for the provided set of ingest pipelines. | ||
| func GetPipelineCoverage(options testrunner.TestOptions, pipelines []ingest.Pipeline) (*testrunner.CoberturaCoverage, error) { | ||
| packagePath, err := packages.MustFindPackageRoot() |
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.
Isn't the package root present in TestOptions?
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.
Turns out it is.
| pipelineName = pipelineName[:nameEnd] | ||
| } | ||
|
|
||
| // File path has to be relative to the packagePath added to the cobertura Sources list |
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.
Let's discuss the safe deployment of this feature.
If we merge this PR and release a new elastic-package, will it break the CI tests for Elastic Integrations? If it breaks, then we need to go the other way round and adjust the Jenkinsfile first and make sure that pipeline sources are in the right directory (relative to the runner?).
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.
There's no reason to believe it will break any tests, I've tested it multiple times with all the existing integrations.
I think you're misunderstanding the CI issues that will need to be addressed. I explained them in this comment: #585 (comment)
Those issues will not cause a test failure. Just the coverage report displayed in CI will not show annotated source code.
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.
Yes, that's what I mean. Let me share my concerns, Jenkins uses coverageReport function to collect the coverage stats. I don't know what will happen if that function files (due to missing pipeline sources). Will it not show the coverage split by source code or fail the entire CI pipeline?
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.
It is not causing a CI pipeline failure in this PR, just the source code is reported missing. See:
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.
Understood, thanks for clarifying this.
This PR updates the pipeline tests to generate code-coverage (at the processor level) for ingest pipelines:
Changes in CI will be needed so that coverage reports are visible in CI.
For local testing, reports are available under
build/test-coverageand can be visualized with a tool like Report Generator.