Skip to content

Commit 97efa22

Browse files
authored
Excute E2E tests in parallel (#7456)
## Description This PR implements parallel execution of E2E tests by using the approach similar to one introduced by @JoshuaBatty for running LSP garbage collection tests in parallel. The approach is based on: - `test` binary getting an additional `--exact` option used by the parallel runner to run exactly one test passed as an argument to `--exact`. The argument is the full path to the test's `toml` file. - parallel runner that uses `rayon` and `std::process::Command` to span `test --exact <test toml path>` processes in parallel. The original command line argument passed to `test` get forwarded to `test --exact` only if they are applicable while running tests in parallel. On my laptop with 20 cores, **the execution time of the complete E2E test suite reduces from reproducible 10:48 minutes to reproducible 1:47 minutes**. Parallel execution is set to be the default one. Sequential execution can still be used via `--sequential` or `-s` flag: `cargo run -- -s` or `test -s`. Similar to parallel garbage collection tests, the parallel execution of E2E tests shows `stderr` output of the executed tests, but not the `stdout`. Being non-deterministic, the position of displayed errors will not come immediately after or before the failing test display, but will always be easy to relate to a concrete failing test. In practice, this will be perfectly enough for troubleshooting failing tests. If all the output is needed during troubleshooting, failing tests can always be executed sequentially, by using the `--sequential` or `-s` flag. Additionally the PR: - adds `no_output` flag to `BuildOpts` to instructs `forc-pkg` not to output build artifacts like bytecode, ABI JSON, or storage slots JSON. This improves test execution speed in general because it skips writing to disc artifacts that are anyhow not used in tests. Also, it simplifies parallelization, because in case of tests with several `test.<feature>.toml` files, we don't need to worry about racing conditions when writing output files. If needed for troubleshooting, output can still be optionally generated in tests by passing the newly added `--write-output` CLI flag to the `test` binary. This flag is ignored when running tests in parallel. A support for the `no_output` option is not added neither to `forc` CLI, nor to CLI of any other tools like, e.g., `forc deploy`. If it proves useful to those tools, we can always easily add it to their CLIs. - fixes #7449 by annotating the `test` binary `main` function with `#[tokio::main(flavor = "current_thread")]`. - renames `exclude_std` CLI option to `no_std_only` to follow the `_only` pattern in naming filters in `FilterConfig` that filter out only the tests with a certain property. Implementing parallel execution for snapshot and IR tests (if required) will be done in followup PRs. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers.
1 parent a5654fc commit 97efa22

File tree

17 files changed

+523
-184
lines changed

17 files changed

+523
-184
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Generated by Cargo
22
# will have compiled files and executables
33
**/*/target/
4-
**/*/json_abi_output.json
4+
**/*/json_abi_output*.json
55
**/*/json_abi_output_flat.json
6-
**/*/json_storage_slots_output.json
6+
**/*/json_storage_slots_output*.json
77
target
88

99
# These are backup files generated by rustfmt

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

forc-pkg/src/pkg.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ pub struct BuildOpts {
323323
pub experimental: Vec<sway_features::Feature>,
324324
/// Set of disabled experimental flags
325325
pub no_experimental: Vec<sway_features::Feature>,
326+
/// Do not output any build artifacts, e.g., bytecode, ABI JSON, etc.
327+
pub no_output: bool,
326328
}
327329

328330
/// The set of options to filter type of projects to build in a workspace.
@@ -2210,6 +2212,7 @@ pub fn build_with_options(
22102212
member_filter,
22112213
experimental,
22122214
no_experimental,
2215+
no_output,
22132216
..
22142217
} = &build_options;
22152218

@@ -2301,7 +2304,10 @@ pub fn build_with_options(
23012304
built_package.write_hexcode(&hexfile_path)?;
23022305
}
23032306

2304-
built_package.write_output(minify, &pkg_manifest.project.name, &output_dir)?;
2307+
if !no_output {
2308+
built_package.write_output(minify, &pkg_manifest.project.name, &output_dir)?;
2309+
}
2310+
23052311
built_workspace.push(Arc::new(built_package));
23062312
}
23072313

forc-plugins/forc-client/src/op/deploy.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ fn build_opts_from_cmd(cmd: &cmd::Deploy, member_filter: pkg::MemberFilter) -> p
867867
member_filter,
868868
experimental: cmd.experimental.experimental.clone(),
869869
no_experimental: cmd.experimental.no_experimental.clone(),
870+
no_output: false,
870871
}
871872
}
872873

forc-plugins/forc-client/src/op/run/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,5 +339,6 @@ fn build_opts_from_cmd(cmd: &cmd::Run) -> pkg::BuildOpts {
339339
member_filter: pkg::MemberFilter::only_scripts(),
340340
experimental: cmd.experimental.experimental.clone(),
341341
no_experimental: cmd.experimental.no_experimental.clone(),
342+
no_output: false,
342343
}
343344
}

forc-test/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ pub struct TestOpts {
164164
pub experimental: Vec<sway_features::Feature>,
165165
/// Set of disabled experimental flags
166166
pub no_experimental: Vec<sway_features::Feature>,
167+
/// Do not output any build artifacts, e.g., bytecode, ABI JSON, etc.
168+
pub no_output: bool,
167169
}
168170

169171
/// The set of options provided for controlling logs printed for each test.
@@ -468,6 +470,7 @@ impl From<TestOpts> for pkg::BuildOpts {
468470
member_filter: Default::default(),
469471
experimental: val.experimental,
470472
no_experimental: val.no_experimental,
473+
no_output: val.no_output,
471474
}
472475
}
473476
}
@@ -494,6 +497,7 @@ impl TestOpts {
494497
member_filter: Default::default(),
495498
experimental: self.experimental,
496499
no_experimental: self.no_experimental,
500+
no_output: self.no_output,
497501
}
498502
}
499503
}

forc/src/cli/commands/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ fn opts_from_cmd(cmd: Command) -> forc_test::TestOpts {
370370
build_target: cmd.build.build_target,
371371
experimental: cmd.experimental.experimental,
372372
no_experimental: cmd.experimental.no_experimental,
373+
no_output: false,
373374
}
374375
}
375376

forc/src/ops/forc_build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@ fn opts_from_cmd(cmd: BuildCommand) -> pkg::BuildOpts {
5050
member_filter: MemberFilter::default(),
5151
experimental: cmd.experimental.experimental,
5252
no_experimental: cmd.experimental.no_experimental,
53+
no_output: false,
5354
}
5455
}

forc/src/ops/forc_contract_id.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,6 @@ fn build_opts_from_cmd(cmd: &ContractIdCommand) -> pkg::BuildOpts {
8282
member_filter: pkg::MemberFilter::only_contracts(),
8383
experimental: cmd.experimental.experimental.clone(),
8484
no_experimental: cmd.experimental.no_experimental.clone(),
85+
no_output: false,
8586
}
8687
}

forc/src/ops/forc_predicate_root.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ fn build_opts_from_cmd(cmd: PredicateRootCommand) -> pkg::BuildOpts {
5151
member_filter: pkg::MemberFilter::only_predicates(),
5252
experimental: cmd.experimental.experimental,
5353
no_experimental: cmd.experimental.no_experimental,
54+
no_output: false,
5455
}
5556
}

0 commit comments

Comments
 (0)