Skip to content

Commit 6b6136c

Browse files
dulinrileymeta-codesync[bot]
authored andcommitted
Turn on cargo test for the hyperactor crate (#1417)
Summary: Pull Request resolved: #1417 We should have Rust tests run in Github CI to ensure we don't break them. Before we were blocked on issues with `cargo test` running tests in threads, and we need process isolation because our tests modify things like environment variables. Use `cargo nextest` which is a package that runs test in parallel processes instead of threads. For now, just run these in a GPU environment. A cpu-only run may be beneficial for either cost savings, faster iteration cycles, or for test coverage itself. But I'll add that later. Some tests are failing in Github but not internally. Add a feature to skip these called "fb". Reviewed By: mariusae Differential Revision: D83856634 fbshipit-source-id: 87c1fe1053e092fc0c4076bca5856912be3c4ea0
1 parent ee34696 commit 6b6136c

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

.github/workflows/test-gpu-rust.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@ jobs:
5858
echo "Running OSS Rust tests..."
5959
# TODO: fix broken tests, then update to `cargo test --no-fail-fast`
6060
cargo test -p monarch_rdma
61+
# Uses cargo nextest to run tests in separate processes, which better matches
62+
# internal buck test behavior.
63+
# TODO: increase coverage to more crates.
64+
cargo nextest run -p hyperactor --no-fail-fast

hyperactor/src/channel.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,8 @@ mod tests {
919919
}
920920

921921
#[tokio::test]
922+
// TODO: OSS: called `Result::unwrap()` on an `Err` value: Server(Listen(Tcp([::1]:0), Os { code: 99, kind: AddrNotAvailable, message: "Cannot assign requested address" }))
923+
#[cfg_attr(not(feature = "fb"), ignore)]
922924
async fn test_dial_serve() {
923925
for addr in addrs() {
924926
let (listen_addr, mut rx) = crate::channel::serve::<i32>(addr).unwrap();
@@ -929,6 +931,8 @@ mod tests {
929931
}
930932

931933
#[tokio::test]
934+
// TODO: OSS: called `Result::unwrap()` on an `Err` value: Server(Listen(Tcp([::1]:0), Os { code: 99, kind: AddrNotAvailable, message: "Cannot assign requested address" }))
935+
#[cfg_attr(not(feature = "fb"), ignore)]
932936
async fn test_send() {
933937
let config = crate::config::global::lock();
934938

hyperactor/src/channel/net.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,6 +2559,8 @@ mod tests {
25592559

25602560
#[tracing_test::traced_test]
25612561
#[async_timed_test(timeout_secs = 30)]
2562+
// TODO: OSS: called `Result::unwrap()` on an `Err` value: Listen(Tcp([::1]:0), Os { code: 99, kind: AddrNotAvailable, message: "Cannot assign requested address" })
2563+
#[cfg_attr(not(feature = "fb"), ignore)]
25622564
async fn test_tcp_basic() {
25632565
let (addr, mut rx) = tcp::serve::<u64>("[::1]:0".parse().unwrap()).unwrap();
25642566
{
@@ -2581,6 +2583,8 @@ mod tests {
25812583

25822584
// The message size is limited by CODEC_MAX_FRAME_LENGTH.
25832585
#[async_timed_test(timeout_secs = 5)]
2586+
// TODO: OSS: called `Result::unwrap()` on an `Err` value: Listen(Tcp([::1]:0), Os { code: 99, kind: AddrNotAvailable, message: "Cannot assign requested address" })
2587+
#[cfg_attr(not(feature = "fb"), ignore)]
25842588
async fn test_tcp_message_size() {
25852589
let default_size_in_bytes = 100 * 1024 * 1024;
25862590
// Use temporary config for this test
@@ -2610,6 +2614,8 @@ mod tests {
26102614
}
26112615

26122616
#[async_timed_test(timeout_secs = 30)]
2617+
// TODO: OSS: called `Result::unwrap()` on an `Err` value: Listen(Tcp([::1]:0), Os { code: 99, kind: AddrNotAvailable, message: "Cannot assign requested address" })
2618+
#[cfg_attr(not(feature = "fb"), ignore)]
26132619
async fn test_ack_flush() {
26142620
let config = config::global::lock();
26152621
// Set a large value to effectively prevent acks from being sent except
@@ -2632,6 +2638,8 @@ mod tests {
26322638

26332639
#[tracing_test::traced_test]
26342640
#[tokio::test]
2641+
// TODO: OSS: failed to retrieve ipv6 address
2642+
#[cfg_attr(not(feature = "fb"), ignore)]
26352643
async fn test_meta_tls_basic() {
26362644
let addr = ChannelAddr::any(ChannelTransport::MetaTls(TlsMode::IpV6));
26372645
let meta_addr = match addr {
@@ -3235,6 +3243,8 @@ mod tests {
32353243

32363244
#[tracing_test::traced_test]
32373245
#[tokio::test]
3246+
// TODO: OSS: The logs_assert function returned an error: expected log not found
3247+
#[cfg_attr(not(feature = "fb"), ignore)]
32383248
async fn test_tcp_tx_delivery_timeout() {
32393249
// This link always fails to connect.
32403250
let link = MockLink::<u64>::fail_connects();
@@ -3659,12 +3669,16 @@ mod tests {
36593669

36603670
#[tracing_test::traced_test]
36613671
#[async_timed_test(timeout_secs = 30)]
3672+
// TODO: OSS: The logs_assert function returned an error: expected log not found
3673+
#[cfg_attr(not(feature = "fb"), ignore)]
36623674
async fn test_ack_exceeded_limit_with_connected_link() {
36633675
verify_ack_exceeded_limit(false).await;
36643676
}
36653677

36663678
#[tracing_test::traced_test]
36673679
#[async_timed_test(timeout_secs = 30)]
3680+
// TODO: OSS: The logs_assert function returned an error: expected log not found
3681+
#[cfg_attr(not(feature = "fb"), ignore)]
36683682
async fn test_ack_exceeded_limit_with_broken_link() {
36693683
verify_ack_exceeded_limit(true).await;
36703684
}
@@ -3834,6 +3848,8 @@ mod tests {
38343848
}
38353849

38363850
#[async_timed_test(timeout_secs = 300)]
3851+
// TODO: OSS: called `Result::unwrap()` on an `Err` value: Listen(Tcp([::1]:0), Os { code: 99, kind: AddrNotAvailable, message: "Cannot assign requested address" })
3852+
#[cfg_attr(not(feature = "fb"), ignore)]
38373853
async fn test_tcp_throughput() {
38383854
let config = config::global::lock();
38393855
let _guard =
@@ -3884,6 +3900,8 @@ mod tests {
38843900

38853901
#[tracing_test::traced_test]
38863902
#[async_timed_test(timeout_secs = 60)]
3903+
// TODO: OSS: The logs_assert function returned an error: expected log not found
3904+
#[cfg_attr(not(feature = "fb"), ignore)]
38873905
async fn test_net_tx_closed_on_server_reject() {
38883906
let link = MockLink::<u64>::new();
38893907
let receiver_storage = link.receiver_storage();

hyperactor/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ mod tests {
216216

217217
#[tracing_test::traced_test]
218218
#[test]
219+
// TODO: OSS: The logs_assert function returned an error: missing log lines: {"# export HYPERACTOR_DEFAULT_ENCODING=serde_multipart", ...}
220+
#[cfg_attr(not(feature = "fb"), ignore)]
219221
fn test_from_env() {
220222
// Set environment variables
221223
// SAFETY: TODO: Audit that the environment access only happens in single-threaded code.

hyperactor/src/host.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,8 @@ mod tests {
11941194
}
11951195

11961196
#[tokio::test]
1197+
// TODO: OSS: called `Result::unwrap()` on an `Err` value: ReadFailed { manifest_path: "/meta-pytorch/monarch/target/debug/deps/hyperactor-0e1fe83af739d976.resources.json", source: Os { code: 2, kind: NotFound, message: "No such file or directory" } }
1198+
#[cfg_attr(not(feature = "fb"), ignore)]
11971199
async fn test_process_proc_manager() {
11981200
hyperactor_telemetry::initialize_logging(crate::clock::ClockKind::default());
11991201

scripts/common-setup.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ setup_rust_toolchain() {
3333
source "${HOME}"/.cargo/env
3434
rustup toolchain install nightly
3535
rustup default nightly
36+
# We use cargo nextest to run tests in individual processes for similarity
37+
# to buck test.
38+
# Replace "cargo test" commands with "cargo nextest run".
39+
cargo install cargo-nextest --locked
3640
}
3741

3842
install_build_dependencies() {

0 commit comments

Comments
 (0)