Add test sharding support for rust_test#3774
Conversation
illicitonion
left a comment
There was a problem hiding this comment.
This generally looks good to me (though I don't have enough batch skills to really verify the .bat file). One thought on provider organisation :)
|
|
||
| # Get the test binary from CrateInfo - it's the output of the compiled test | ||
| crate_info_provider = None | ||
| for p in providers: |
There was a problem hiding this comment.
Let's do something like edit rustc_compile_action to return a dict of provider types to providers, and then do a key lookup, rather than sniffing an ordered list.
There was a problem hiding this comment.
much better - done.
f6ec6ee to
a7f30a5
Compare
47f7781 to
c23d0dc
Compare
c23d0dc to
adb3e34
Compare
|
Remaining test breakages appear to be pre-existing issues unrelated to this change. The windows .bat file was a pain to test, but was able to get it to work eventually. I also have a branch where I use a small rust util to launch the tests - lemme know if we should explore that either here or as a followup. |
|
I would love to have the util be a rust wrapper. Seems like that would avoid multiple implementations and a bash dependency |
UebelAndre
left a comment
There was a problem hiding this comment.
Once upon a time we had a test wrapper and it ended up being problematic for debuggers. I'm very nervous about introducing this in this way. Is there not a test crate rules_rust could provide that would enable sharding instead?
There was a problem hiding this comment.
I think for cross-platform consistency, could this be a rust binary?
| E.g. `bazel test //src:rust_test --test_arg=foo::test::test_fn`. | ||
| """), | ||
| ), | ||
| "experimental_enable_sharding": attr.bool( |
There was a problem hiding this comment.
Should this not be a build flag similar to these?
rules_rust/rust/settings/BUILD.bazel
Lines 85 to 93 in cdaf15f
|
Any update on this ? we could really use this feature |
|
@brianduff @illicitonion good to see you again! We are starting to rely more heavily on Bazel for building https://github.com/openai/codex/ and are very interested in this change. I would be happy to help shepherd this through if I can! |
Our current thinking is the best path forward would be to either patch libtest harness or provide an alternate binary launcher that reuses libtest but adds support for the sharding env vars. (That's basically what Go does as well). Staying in-process should avoid bad interactions with debugger |
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. This keeps rustc_compile_action's provider-list API intact and updates rust_test to swap its executable for a generated sharding wrapper when experimental_enable_sharding is set. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. This updates rustc_compile_action to return a dict of named providers so rust_test can replace DefaultInfo without provider-shape sniffing when experimental_enable_sharding is set. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. This updates rustc_compile_action to return a dict of named providers so rust_test can replace DefaultInfo without provider-shape sniffing when experimental_enable_sharding is set. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. This updates rustc_compile_action to return a dict of named providers so rust_test can replace DefaultInfo without provider-shape sniffing when experimental_enable_sharding is set. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. This updates rustc_compile_action to return a dict of named providers so rust_test can replace DefaultInfo without provider-shape sniffing when experimental_enable_sharding is set. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. The implementation wraps rust_test executables when experimental_enable_sharding is set while keeping rustc_compile_action's existing provider-list API for internal and extension callers. rust_test now scans the returned providers to replace DefaultInfo for the wrapper, so extensions such as prost and wasm-bindgen continue to consume rustc_compile_action without API churn. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. The implementation wraps rust_test executables when experimental_enable_sharding is set while keeping rustc_compile_action's existing provider-list API for internal and extension callers. rust_test now scans the returned providers to replace DefaultInfo for the wrapper, so extensions such as prost and wasm-bindgen continue to consume rustc_compile_action without API churn. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. The implementation wraps rust_test executables when experimental_enable_sharding is set while keeping rustc_compile_action's existing provider-list API for internal and extension callers. rust_test now scans the returned providers to replace DefaultInfo for the wrapper, so extensions such as prost and wasm-bindgen continue to consume rustc_compile_action without API churn. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. The implementation wraps rust_test executables when experimental_enable_sharding is set while keeping rustc_compile_action's existing provider-list API for internal and extension callers. rust_test now scans the returned providers to replace DefaultInfo for the wrapper, so extensions such as prost and wasm-bindgen continue to consume rustc_compile_action without API churn. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. The implementation wraps rust_test executables when experimental_enable_sharding is set while keeping rustc_compile_action's existing provider-list API for internal and extension callers. rust_test now scans the returned providers to replace DefaultInfo for the wrapper, so extensions such as prost and wasm-bindgen continue to consume rustc_compile_action without API churn. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. The implementation wraps rust_test executables when experimental_enable_sharding is set while keeping rustc_compile_action's existing provider-list API for internal and extension callers. rust_test now scans the returned providers to replace DefaultInfo for the wrapper, so extensions such as prost and wasm-bindgen continue to consume rustc_compile_action without API churn. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. The implementation wraps rust_test executables when experimental_enable_sharding is set while keeping rustc_compile_action's existing provider-list API for internal and extension callers. rust_test now scans the returned providers to replace DefaultInfo for the wrapper, so extensions such as prost and wasm-bindgen continue to consume rustc_compile_action without API churn. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. The implementation wraps rust_test executables when experimental_enable_sharding is set while keeping rustc_compile_action's existing provider-list API for internal and extension callers. rust_test now scans the returned providers to replace DefaultInfo for the wrapper, so extensions such as prost and wasm-bindgen continue to consume rustc_compile_action without API churn. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Port the sharding wrapper feature from bazelbuild#3774 into the hermeticbuild fork. The implementation wraps rust_test executables when experimental_enable_sharding is set while keeping rustc_compile_action's existing provider-list API for internal and extension callers. rust_test now scans the returned providers to replace DefaultInfo for the wrapper, so extensions such as prost and wasm-bindgen continue to consume rustc_compile_action without API churn. Co-authored-by: Brian Duff <bduff@linkedin.com> Co-authored-by: Codex <noreply@openai.com>
Problem
rust_testtargets don't support Bazel's native test sharding. Whenshard_countis set on arust_test:--incompatible_check_sharding_support: all tests run N times (once per shard)--incompatible_check_sharding_support: the test fails because Rust's libtest harness doesn't readTEST_SHARD_INDEX/TEST_TOTAL_SHARDSenvironment variablesSolution
This PR adds opt-in sharding support via a new
experimental_enable_shardingattribute. When enabled, tests are executed via a wrapper script that:TEST_TOTAL_SHARDSenvironment variableTEST_SHARD_STATUS_FILEto advertise sharding support to Bazel--list --format terseflagindex % TEST_TOTAL_SHARDS == TEST_SHARD_INDEX--exactUsage