From a60fe94651483816c8e20605891d09d9448dc1b2 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Wed, 12 Feb 2025 19:34:30 +0800 Subject: [PATCH 1/3] fix(test): add retry to tests that do heavy downloading tasks --- Cargo.lock | 69 ++++++++++++++++++++++++++++++----------- Cargo.toml | 1 + tests/manifest_tests.rs | 2 ++ tests/tool_tests.rs | 2 ++ 4 files changed, 56 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d255e9ff41e5..33656b664dba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,9 +1239,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.28" +version = "4.5.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e77c3243bd94243c03672cb5154667347c457ca271254724f9f393aee1c05ff" +checksum = "8acebd8ad879283633b343856142139f2da2317c96b05b4dd6181c61e2480184" dependencies = [ "clap_builder", "clap_derive", @@ -1249,9 +1249,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.27" +version = "4.5.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" +checksum = "f6ba32cbda51c7e1dfd49acc1457ba1a7dec5b64fe360e828acb13ca8dc9c2f9" dependencies = [ "anstream", "anstyle", @@ -1289,6 +1289,16 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +[[package]] +name = "colored" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" +dependencies = [ + "lazy_static", + "windows-sys 0.59.0", +] + [[package]] name = "colored" version = "3.0.0" @@ -2450,6 +2460,28 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "fickle" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e520185ef7e909160ad4250e08603ae35feb9fd33ecbbf05dab2829e8cfbbbb2" +dependencies = [ + "colored 2.2.0", + "fickle-macros", + "itertools 0.13.0", + "thiserror 1.0.69", +] + +[[package]] +name = "fickle-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cf792125fca464ddbf54eb4e2d5826fd4988164d060d777a30b43405548c1a3" +dependencies = [ + "quote", + "syn 2.0.98", +] + [[package]] name = "fil_actor_account_state" version = "19.1.0" @@ -2948,7 +2980,7 @@ dependencies = [ "cid 0.10.1", "cid 0.11.1", "clap", - "colored", + "colored 3.0.0", "console-subscriber", "criterion", "crypto_secretbox", @@ -2966,6 +2998,7 @@ dependencies = [ "either", "ethereum-types", "ez-jsonrpc-types", + "fickle", "fil_actor_account_state", "fil_actor_cron_state", "fil_actor_datacap_state", @@ -4471,9 +4504,9 @@ dependencies = [ [[package]] name = "impl-codec" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67aa010c1e3da95bf151bd8b4c059b2ed7e75387cdb969b4f8f2723a43f9941" +checksum = "2d40b9d5e17727407e55028eafc22b2dc68781786e6d7eb8a21103f5058e3a14" dependencies = [ "parity-scale-codec", ] @@ -5836,9 +5869,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" dependencies = [ "adler2", ] @@ -6970,9 +7003,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" +checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" dependencies = [ "bytes", "prost-derive", @@ -6980,12 +7013,12 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" +checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools 0.13.0", + "itertools 0.14.0", "proc-macro2", "quote", "syn 2.0.98", @@ -6993,9 +7026,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2f1e56baa61e93533aebc21af4d2134b70f66275e0fcdf3cbe43d77ff7e8fc" +checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" dependencies = [ "prost", ] @@ -7715,9 +7748,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.22" +version = "0.23.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb9263ab4eb695e42321db096e3b8fbd715a59b154d5c88d82db2175b681ba7" +checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" dependencies = [ "log", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index fc1d25e3591e..3d2eaf688e2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -237,6 +237,7 @@ cbor4ii = { version = "0.2", default-features = false, features = ["serde1"] } criterion = { version = "0.5", features = ["async_tokio", "csv"] } cs_serde_bytes = "0.12" derive-quickcheck-arbitrary = "0.1" +fickle = "0.3" fvm_shared3 = { package = "fvm_shared", version = "~3.12", features = ["arb", "proofs", "testing"] } fvm_shared4 = { package = "fvm_shared", version = "~4.5.3", features = ["arb", "proofs", "testing"] } glob = "0.3" diff --git a/tests/manifest_tests.rs b/tests/manifest_tests.rs index e559cac01e0e..b26d832857d2 100644 --- a/tests/manifest_tests.rs +++ b/tests/manifest_tests.rs @@ -4,9 +4,11 @@ pub mod common; use crate::common::tool; +use fickle::fickle; use std::path::PathBuf; #[test] +#[fickle] fn create_manifest_json() { // This downloads lots of bundles from Github, which may be down at the time // of local development. If GH is down, the CI will likely fail as well. diff --git a/tests/tool_tests.rs b/tests/tool_tests.rs index de80d39680a4..7ede18e0d453 100644 --- a/tests/tool_tests.rs +++ b/tests/tool_tests.rs @@ -7,6 +7,7 @@ use common::{daemon, CommonArgs}; use predicates::prelude::*; use crate::common::{create_tmp_config, tool}; +use fickle::fickle; // Exporting an empty archive should fail but not panic #[test] @@ -28,6 +29,7 @@ fn export_empty_archive() { // Running `forest-tool state-migration actor-bundle` may not fail. #[test] +#[fickle] fn state_migration_actor_bundle_runs() { let temp_dir = tempfile::tempdir().unwrap(); let bundle = temp_dir.path().join("bundle.car"); From cef96b1040ef9beb7a60283617e57893b76e0db2 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Wed, 12 Feb 2025 20:11:51 +0800 Subject: [PATCH 2/3] run actor bundle tests in sequence --- Cargo.lock | 41 +++++++++++++++++++ Cargo.toml | 1 + ..._tests.rs => cmd_state_migration_tests.rs} | 26 +++++++++--- tests/tool_tests.rs | 19 --------- 4 files changed, 62 insertions(+), 25 deletions(-) rename tests/{manifest_tests.rs => cmd_state_migration_tests.rs} (67%) diff --git a/Cargo.lock b/Cargo.lock index 33656b664dba..eb54350249af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3108,6 +3108,7 @@ dependencies = [ "serde_tuple 1.1.0", "serde_with", "serde_yaml", + "serial_test", "sha2 0.10.8", "shared_memory", "similar", @@ -7928,6 +7929,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scc" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea091f6cac2595aa38993f04f4ee692ed43757035c36e67c180b6828356385b1" +dependencies = [ + "sdd", +] + [[package]] name = "schannel" version = "0.1.27" @@ -7975,6 +7985,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sdd" +version = "3.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07779b9b918cc05650cb30f404d4d7835d26df37c235eded8a6832e2fb82cca" + [[package]] name = "sec1" version = "0.7.3" @@ -8213,6 +8229,31 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "serial_test" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9" +dependencies = [ + "futures", + "log", + "once_cell", + "parking_lot", + "scc", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "sha1" version = "0.10.6" diff --git a/Cargo.toml b/Cargo.toml index 3d2eaf688e2e..8f35f7a72e2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -253,6 +253,7 @@ quickcheck_async = "0.1" quickcheck_macros = "1" ra_ap_syntax = "0.0.263" regex-automata = "0.4" +serial_test = "3" syn = { version = "2", default-features = false, features = ["full", "parsing", "visit", "printing", "extra-traits"] } tokio-test = "0.4" diff --git a/tests/manifest_tests.rs b/tests/cmd_state_migration_tests.rs similarity index 67% rename from tests/manifest_tests.rs rename to tests/cmd_state_migration_tests.rs index b26d832857d2..d3200512cf9e 100644 --- a/tests/manifest_tests.rs +++ b/tests/cmd_state_migration_tests.rs @@ -5,17 +5,31 @@ pub mod common; use crate::common::tool; use fickle::fickle; +use serial_test::serial; use std::path::PathBuf; #[test] #[fickle] -fn create_manifest_json() { - // This downloads lots of bundles from Github, which may be down at the time - // of local development. If GH is down, the CI will likely fail as well. - if std::env::var("CI").is_err() { - return; - } +#[serial] +fn state_migration_actor_bundle() { + let temp_dir = tempfile::tempdir().unwrap(); + let bundle = temp_dir.path().join("bundle.car"); + tool() + .arg("state-migration") + .arg("actor-bundle") + .arg(&bundle) + .assert() + .success(); + + assert!(bundle.exists()); + assert!(zstd::decode_all(std::fs::File::open(&bundle).unwrap()).is_ok()); +} + +#[test] +#[fickle] +#[serial] +fn state_migration_generate_actors_metadata() { let json = tool() .arg("state-migration") .arg("generate-actors-metadata") diff --git a/tests/tool_tests.rs b/tests/tool_tests.rs index 7ede18e0d453..86f293ca687d 100644 --- a/tests/tool_tests.rs +++ b/tests/tool_tests.rs @@ -7,7 +7,6 @@ use common::{daemon, CommonArgs}; use predicates::prelude::*; use crate::common::{create_tmp_config, tool}; -use fickle::fickle; // Exporting an empty archive should fail but not panic #[test] @@ -27,24 +26,6 @@ fn export_empty_archive() { )); } -// Running `forest-tool state-migration actor-bundle` may not fail. -#[test] -#[fickle] -fn state_migration_actor_bundle_runs() { - let temp_dir = tempfile::tempdir().unwrap(); - let bundle = temp_dir.path().join("bundle.car"); - - tool() - .arg("state-migration") - .arg("actor-bundle") - .arg(&bundle) - .assert() - .success(); - - assert!(bundle.exists()); - assert!(zstd::decode_all(std::fs::File::open(&bundle).unwrap()).is_ok()); -} - #[test] fn peer_id_from_keypair() { let temp_dir = tempfile::tempdir().unwrap(); From 286c4609b66ed8bcb2db06a98bfbd15d9213f631 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Wed, 12 Feb 2025 20:28:59 +0800 Subject: [PATCH 3/3] update nextest config --- .config/nextest.toml | 8 +++++--- .github/workflows/unit-tests.yml | 11 +++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 97a64b262618..bf4e1cdba0a0 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,20 +1,22 @@ [profile.default] slow-timeout = { period = "10s", terminate-after = 3 } +# This test downloads bundles from the network, which can take a while. +# It is only run on CI, so we can afford to be more patient. [[profile.default.overrides]] -filter = 'test(state_migration_actor_bundle_runs)' +filter = 'test(networks::actors_bundle::tests::check_bundles_are_mirrored)' slow-timeout = { period = "120s", terminate-after = 3 } # This test downloads bundles from the network, which can take a while. # It is only run on CI, so we can afford to be more patient. [[profile.default.overrides]] -filter = 'test(networks::actors_bundle::tests::check_bundles_are_mirrored)' +filter = 'test(state_migration_actor_bundle)' slow-timeout = { period = "120s", terminate-after = 3 } # This test downloads bundles from the network, which can take a while. # It is only run on CI, so we can afford to be more patient. [[profile.default.overrides]] -filter = 'test(create_manifest_json)' +filter = 'test(state_migration_generate_actors_metadata)' slow-timeout = { period = "120s", terminate-after = 3 } # This test downloads RPC test snapshot files from the network, which can take a while. diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index b8d72e3d76f1..fac442dda111 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -15,14 +15,14 @@ on: # run when moved out of draft. types: [opened, synchronize, reopened, ready_for_review] paths-ignore: - - 'docs/**' - - '.github/workflows/docs-*.yml' + - "docs/**" + - ".github/workflows/docs-*.yml" push: branches: - main paths-ignore: - - 'docs/**' - - '.github/workflows/docs-*.yml' + - "docs/**" + - ".github/workflows/docs-*.yml" env: CI: 1 @@ -74,3 +74,6 @@ jobs: - name: install nextest uses: taiki-e/install-action@nextest - run: make test-release + env: + # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times + RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld"