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

Improve overall test time #60

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

eagr
Copy link
Contributor

@eagr eagr commented Nov 19, 2023

The rough idea of what we talked about. :)) @liamaharon

@liamaharon
Copy link
Contributor

liamaharon commented Nov 20, 2023

Looking good, thanks!

It would be nice if we could specify a block number we'd like it to run to before proceeding as well.

@eagr
Copy link
Contributor Author

eagr commented Nov 21, 2023

Could you elaborate a bit on "a block number we'd like it to run to"?

@liamaharon
Copy link
Contributor

Poll the current block of the spun up chain and yield after a block has been mined.

@eagr
Copy link
Contributor Author

eagr commented Nov 29, 2023

You mean something like this?

async fn block_hash(from: u64, to: u64, url: &str, timeout: u64) -> Result<Vec<Hash>, String>;

Comment on lines 80 to 85
let result = ChainApi::<(), Hash, Header, ()>::block_hash(
&rpc,
Some(ListOrValue::Value(NumberOrHex::Number(block_number))),
)
.await
.map_err(|_| "Couldn't get block hash".to_string())?;
Copy link
Contributor

Choose a reason for hiding this comment

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

What I mean is by the time you get there, the block may not have been mined yet so probably needs to continue waiting after it has connected until confirmation that the target block is mined

@eagr eagr changed the title Try connecting in tests Improve overall test time Nov 30, 2023
@eagr
Copy link
Contributor Author

eagr commented Nov 30, 2023

By grouping the integration tests, on my machine, it could save ~70s and ~1GB disk space. In case it's not obvious from the report, this essential reduces the amount of build targets, therefore reduces the overall amount of work (linking) and generated artifacts.

Original
image

Grouped
image

@eagr
Copy link
Contributor Author

eagr commented Nov 30, 2023

Thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: 
GlobalLoggerError(SetLoggerError(SetLoggerError(())))',
/Users/eagr/.cargo/git/checkouts/polkadot-sdk-cff69157b985ed76/1d5d4a4/substrate/test-utils/cli/src/lib.rs:66

I suspect this is due to we're running the tests in parallel now, spinning up multiple dev nodes at the same time. Any ideas?

@eagr
Copy link
Contributor Author

eagr commented Dec 2, 2023

This would solve the issue, and the tests also run faster this way. But I'm not sure whether this is what you want. The logs are all mixed up as the tests run in parallel now.

@eagr
Copy link
Contributor Author

eagr commented Dec 2, 2023

Currently, the tests run sequentially in separate processes. There are no problems because by the time the next test runs, the dev node has exited with the previous test process.

After grouping the tests run in one process concurrently (different threads). The problem originates from setting the logger multiple times in a process, which is disallowed by the tracing crate.

https://docs.rs/tracing-log/latest/tracing_log/log_tracer/struct.SetLoggerError.html

Making the tests run sequentially (either with lock or --test-threads=1) wouldn't work, unless there is a way to force the dev node to exit at the end of a test.

TL;DR Grouping the tests has the benefits of faster compilation (-1min) and execution (-3min), but if running tests in parallel on the same node isn't what you want, let's revert the changes.

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.

2 participants