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

feat(cli): run test modules in parallel #9815

Merged
merged 100 commits into from
Apr 28, 2021

Conversation

caspervonb
Copy link
Contributor

@caspervonb caspervonb commented Mar 17, 2021

This runs test modules in parallel when the number of concurrent jobs passed via --jobs=<N> is greater than 1.
The default is to run with a limit of 1 to retain backwards compatibility, as not all test suites in the wild are concurrency safe.

Closes #6559
Closes #9284

@caspervonb caspervonb mentioned this pull request Mar 17, 2021
cli/main.rs Outdated Show resolved Hide resolved
cli/ops/test_dispatcher.rs Outdated Show resolved Hide resolved
cli/program_state.rs Show resolved Hide resolved
cli/test_dispatcher.rs Outdated Show resolved Hide resolved
runtime/js/40_testing.js Outdated Show resolved Hide resolved
@caspervonb caspervonb force-pushed the feat-run-test-modules-in-parallel branch from 6f92263 to aec16f9 Compare March 19, 2021 15:58
@caspervonb caspervonb force-pushed the feat-run-test-modules-in-parallel branch from aec16f9 to c14a1c0 Compare March 19, 2021 16:03
@caspervonb caspervonb force-pushed the feat-run-test-modules-in-parallel branch from 0199aaa to 84f2e76 Compare March 19, 2021 16:20
@caspervonb

This comment has been minimized.

@caspervonb caspervonb force-pushed the feat-run-test-modules-in-parallel branch from 2cc1141 to 7601e72 Compare March 20, 2021 10:58
@caspervonb caspervonb force-pushed the feat-run-test-modules-in-parallel branch from 7601e72 to 0d0f3a2 Compare March 20, 2021 12:06
@bartlomieju
Copy link
Member

I've noticed two quirks that I'm not sure how big of an impact they'll have:

  1. There's Check <module name> for as many modules as there are discovered
Check file:///Users/biwanczuk/dev/deno_std/textproto/test.ts
Check file:///Users/biwanczuk/dev/deno_std/_util/deep_assign_test.ts
Check file:///Users/biwanczuk/dev/deno_std/_util/assert_test.ts
Check file:///Users/biwanczuk/dev/deno_std/flags/test.ts
Check file:///Users/biwanczuk/dev/deno_std/archive/tar_test.ts
Check file:///Users/biwanczuk/dev/deno_std/bytes/test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/_fnv/util_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/sha512_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/fnv_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/sha256_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/sha1_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/md5_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/sha3_test.ts
Check file:///Users/biwanczuk/dev/deno_std/datetime/test.ts
Check file:///Users/biwanczuk/dev/deno_std/fmt/colors_test.ts
Check file:///Users/biwanczuk/dev/deno_std/fmt/printf_test.ts
....
  1. For each test module (supposedly) there's running X tests printed:
running 4 tests
test [encoding/base64] testBase64EncodeString ... ok (2ms)
test [encoding/base64] testBase64EncodeBinary ... ok (2ms)
test [encoding/base64] testBase64EncodeBinaryBuffer ... ok (2ms)
test [encoding/base64] testBase64DecodeBinary ... ok (2ms)
running 4 tests
test [encoding.base32] encode ... ok (4ms)
test [encoding.base32] decode ... ok (2ms)
test [encoding.base32] decode bad length ... ok (1ms)
test [encoding.base32] decode bad padding ... ok (1ms)

I don't mind it, but maybe we could change it to running X tests in <module name>

@lucacasonato
Copy link
Member

There's Check <module name> for as many modules as there are discovered

This suggests each module is being type checked individually. AFAIK this is way slower than type-checking them all at once. cc @kitsonk

@caspervonb
Copy link
Contributor Author

  1. There's Check <module name> for as many modules as there are discovered
Check file:///Users/biwanczuk/dev/deno_std/textproto/test.ts
Check file:///Users/biwanczuk/dev/deno_std/_util/deep_assign_test.ts
Check file:///Users/biwanczuk/dev/deno_std/_util/assert_test.ts
Check file:///Users/biwanczuk/dev/deno_std/flags/test.ts
Check file:///Users/biwanczuk/dev/deno_std/archive/tar_test.ts
Check file:///Users/biwanczuk/dev/deno_std/bytes/test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/_fnv/util_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/sha512_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/fnv_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/sha256_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/sha1_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/md5_test.ts
Check file:///Users/biwanczuk/dev/deno_std/hash/sha3_test.ts
Check file:///Users/biwanczuk/dev/deno_std/datetime/test.ts
Check file:///Users/biwanczuk/dev/deno_std/fmt/colors_test.ts
Check file:///Users/biwanczuk/dev/deno_std/fmt/printf_test.ts
....

Doing the type checking and compilation before attempting to run is intentional.
Type errors occurs immediatly after the check statement so, it looks nice imo and accurately reflects what is going on.

This suggests each module is being type checked individually. AFAIK this is way slower than type-checking them all at once.

Yeah by one literally takes hours in the debug build @lucacasonato, but I do them all in one graph.

  1. For each test module (supposedly) there's running X tests printed:
running 4 tests
test [encoding/base64] testBase64EncodeString ... ok (2ms)
test [encoding/base64] testBase64EncodeBinary ... ok (2ms)
test [encoding/base64] testBase64EncodeBinaryBuffer ... ok (2ms)
test [encoding/base64] testBase64DecodeBinary ... ok (2ms)
running 4 tests
test [encoding.base32] encode ... ok (4ms)
test [encoding.base32] decode ... ok (2ms)
test [encoding.base32] decode bad length ... ok (1ms)
test [encoding.base32] decode bad padding ... ok (1ms)

I don't mind it, but maybe we could change it to running X tests in

I've got a branch with slightly nicer test output to address that after this.

@caspervonb
Copy link
Contributor Author

Ran into some caching issues after introducing the fake module stub that calls await Deno[Deno.internal].runTests.
For example switching from unit tests to std tests:

error: Module "file:///home/caspervonb/deno/test_util/std/fmt/printf_test.ts" is missing from the graph.
  From: file:///home/caspervonb/deno/$deno$test.ts

Also a few runs definitively used old cached versions of "$deno$test.ts" from disk.

@caspervonb caspervonb force-pushed the feat-run-test-modules-in-parallel branch from a28d05d to 49ac699 Compare April 27, 2021 19:55
Comment on lines +225 to +251
let join_handles = test_modules.iter().map(move |main_module| {
let program_state = program_state.clone();
let main_module = main_module.clone();
let test_module = test_module.clone();
let permissions = permissions.clone();
let sender = sender.clone();

tokio::task::spawn_blocking(move || {
let join_handle = std::thread::spawn(move || {
let future = run_test_file(
program_state,
main_module,
test_module,
permissions,
sender,
);

tokio_util::run_basic(future)
});

join_handle.join().unwrap()
})
});

let join_futures = stream::iter(join_handles)
.buffer_unordered(concurrent_jobs)
.collect::<Vec<Result<Result<(), AnyError>, tokio::task::JoinError>>>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piscisaureus please take a look at this part

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 thank you Casper, this is a great feature to have

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

deno test - Cannot resolve module Request: Add --parallel to deno test
3 participants