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

Add support for bazel coverage with BwoB #16475

Closed

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Oct 14, 2022

With --experimental_split_coverage_postprocessing and experimental_fetch_all_coverage_outputs, all that is needed to get coverage runs to succeed with --remote_download_minimal is to explicitly request the raw and processed coverage files. This is made possible by the machinery introduced for
--experimental_remote_download_regex.

Work towards #4685

With `--experimental_split_coverage_postprocessing` and
`experimental_fetch_all_coverage_outputs`, all that is needed to get
coverage runs to succeed with `--remote_download_minimal` is to
explicitly request the raw and processed coverage files. This is made
possible by the machinery introduced for
`--experimental_remote_download_regex`.
@fmeum fmeum marked this pull request as ready for review October 14, 2022 16:07
@fmeum fmeum requested a review from a team as a code owner October 14, 2022 16:07
@sgowroji sgowroji added team-Remote-Exec Issues and PRs for the Execution (Remote) team awaiting-review PR is awaiting review from an assigned reviewer labels Oct 14, 2022
@fmeum
Copy link
Collaborator Author

fmeum commented Oct 14, 2022

@coeuvre @c-mita Could you take a look? It's a kind of a cross-team PR and I would really like someone to check my regexes actually match all coverage files (and as few unrelated files as possible).

@coeuvre
Copy link
Member

coeuvre commented Oct 14, 2022

I am not sure whether using regex to pass the information around is the best option. As I mentioned in #6862 (comment), BwoB will be able to download output groups, can we somehow define an output group for those files?

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 14, 2022

I am not sure whether using regex to pass the information around is the best option. As I mentioned in #6862 (comment), BwoB will be able to download output groups, can we somehow define an output group for those files?

I agree that regexes are less than ideal. They have the benefit of working with minimal though - would we be able to force downloading a particular output group even with that setting or would it require toplevel?

I will look into the output group approach, I can't say yet whether it's feasible.

@coeuvre
Copy link
Member

coeuvre commented Oct 14, 2022

the problem with minimal is the requested files (either through regex or output groups) are only downloaded if the generating actions didn't hit the skyframe cache.

In an incremental build, if you only change the requested regex, no additional intermediate files will be downloaded. However, toplevel always works. We can force minimal to download requested output groups but it has the same problem with regex.

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 14, 2022

It seems to be possible for the coverage reports created for individual tests to be included in an output group. We may need to explicitly fetch bazel-out/_coverage/_coverage_report.dat as that seems to be requested right from within Skyframe/BuildView and isn't associated with a target, but it would be a single static path rather than a regex.

@coeuvre Do you have a branch with a prototype of the output group fetching functionality that I could use to test this approach with?

@coeuvre
Copy link
Member

coeuvre commented Oct 14, 2022

not yet, but I plan to create a PR for that in a few days.

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 14, 2022

not yet, but I plan to create a PR for that in a few days.

Great, thanks. Just ping me when you have something. I will set this PR to draft for now.

@fmeum fmeum marked this pull request as draft October 14, 2022 16:59
@coeuvre
Copy link
Member

coeuvre commented Oct 25, 2022

The PR #16524 is merged. It now listens to TestAttempt event and downloads all the available test outputs.

You can play with it but it may already be able to download coverage outputs in which case can you add an integration test for it?

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 25, 2022

@coeuvre Just tested it, but the coverage outputs aren't downloaded. How would I go about registering them as test outputs? I have a commit that adds them to a new output group, but how would I register that with the downloader?

@coeuvre
Copy link
Member

coeuvre commented Oct 25, 2022

The TestAttempt event is fired here. You can follow the testOutputs to find where to register them.

If you think coverage outputs should be always downloaded by default if they exist, maybe just add them to the test output instead of using output group.

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 25, 2022

It looks like coverage artifacts and reports are already declared outputs of the test action. However, the spawn that is supposed to take the coverage artifacts and generates a report from them fails to do so as it doesn't see the coverage artifacts.

@coeuvre If a remotely run SimpleSpawn declares a tree artifact as an input that is a declared output of a remotely run test, does it need to do anything special to "see" the files in the tree artifact? The files are there in RemoteExecutionService#injectRemoteArtifacts, but aren't available on the remote executor when the SimpleSpawn is executed. How is the relation between the individual injected files and the original tree artifact tracked?

@coeuvre
Copy link
Member

coeuvre commented Oct 25, 2022

It looks like coverage artifacts and reports are already declared outputs of the test action.

Yes, I remember it is the case so I said it may already works, but apparently, there are some other issues.

does it need to do anything special to "see" the files in the tree artifact?

I think it should just work otherwise there are some bugs in RemoteActionFileSystem.

Can you please share a minimal repro so I can look into?

/cc @tjgq

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 25, 2022

The integration tests added by this PR are reproducers (even if you replace --remote_download_minimal with --remote_download_toplevel).

I debugged this for a bit and think that the problem is the way the coverage tree artifact is created without properly registering it with Skyframe. That means that SpawnInputExpander is not able to expand it and then remote execution stages it as an empty directory. Doesn't seem to be an issue on the RBE side.

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 25, 2022

Adding slightly more detail: You assessed the situation in #15276 (comment). Either the spawn manually expands the tree artifact and doesn't pick up files that only exist remotely, or it sends a tree artifact that SpawnInputExpander doesn't know about und thus can't expand.

Not sure what the right direction is. Maybe looking into how tree artifacts created during the execution of the action could be injected into SpawnInputExpander?

@coeuvre
Copy link
Member

coeuvre commented Oct 26, 2022

I have a working patch that just read tree artifacts from action fs. I will create a PR soon.

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 26, 2022

Superseded by #16556

@fmeum fmeum closed this Oct 26, 2022
@fmeum fmeum deleted the remote-download-minimal-coverage branch October 26, 2022 12:08
copybara-service bot pushed a commit that referenced this pull request Jan 18, 2023
This PR solves the problem in a different way that #16475 tries to solve:

1. #16812 allows skyframe read metadata from ActionFS.
2. Use `ActionFileSystem` to check existence of coverage data.
3. Fire event `CoverageReport` in the action after the coverage report is generated and listen to it in `ToplevelArtifactsDownloader` to download the report.

Closes #16556.

PiperOrigin-RevId: 502854552
Change-Id: I2796baaa962857831ff161423be6dffa6eb73e5c
coeuvre added a commit to coeuvre/bazel that referenced this pull request Feb 2, 2023
This PR solves the problem in a different way that bazelbuild#16475 tries to solve:

1. bazelbuild#16812 allows skyframe read metadata from ActionFS.
2. Use `ActionFileSystem` to check existence of coverage data.
3. Fire event `CoverageReport` in the action after the coverage report is generated and listen to it in `ToplevelArtifactsDownloader` to download the report.

Closes bazelbuild#16556.

PiperOrigin-RevId: 502854552
Change-Id: I2796baaa962857831ff161423be6dffa6eb73e5c
ShreeM01 added a commit that referenced this pull request Feb 7, 2023
* Returns null if filesystem of test outputs is not ActionFS when processing test attempt event.

Previously, we assert that the filesystem of test outputs is ActionFS when we are processing test attempt event. However this is not true when the test hits action cache.

This CL looses the check to return null.

PiperOrigin-RevId: 501023752
Change-Id: I17cbb26e0a2b5fd30cb781818e42172ac672919e

* Make `bazel coverage` work with minimal mode

This PR solves the problem in a different way that #16475 tries to solve:

1. #16812 allows skyframe read metadata from ActionFS.
2. Use `ActionFileSystem` to check existence of coverage data.
3. Fire event `CoverageReport` in the action after the coverage report is generated and listen to it in `ToplevelArtifactsDownloader` to download the report.

Closes #16556.

PiperOrigin-RevId: 502854552
Change-Id: I2796baaa962857831ff161423be6dffa6eb73e5c

---------

Co-authored-by: kshyanashree <[email protected]>
hvadehra pushed a commit that referenced this pull request Feb 14, 2023
This PR solves the problem in a different way that #16475 tries to solve:

1. #16812 allows skyframe read metadata from ActionFS.
2. Use `ActionFileSystem` to check existence of coverage data.
3. Fire event `CoverageReport` in the action after the coverage report is generated and listen to it in `ToplevelArtifactsDownloader` to download the report.

Closes #16556.

PiperOrigin-RevId: 502854552
Change-Id: I2796baaa962857831ff161423be6dffa6eb73e5c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review PR is awaiting review from an assigned reviewer team-Remote-Exec Issues and PRs for the Execution (Remote) team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants