refactor!: black-box integration tests#5087
refactor!: black-box integration tests#50870x009922 wants to merge 5 commits intohyperledger-iroha:mainfrom
Conversation
2cc8911 to
bf482f8
Compare
| tokio::spawn(async move { | ||
| while let Ok(e) = events.recv().await { | ||
| match e { | ||
| PeerLifecycleEvent::LogBlockCommitted { height } => { | ||
| println!("Last peer block committed: {height}") | ||
| } | ||
| _ => {} | ||
| } | ||
| } | ||
| }); |
There was a problem hiding this comment.
This task is not synchronized with the main one.
It's purpose is to only print messages?
Also logger is no longer available in integration tests, right?
There was a problem hiding this comment.
Yes, this is only for debugging. It sometimes fails due to timeout being too short (which is convenient for local development). Need to adjust further.
There was a problem hiding this comment.
Also
loggeris no longer available in integration tests, right?
test_logger() setup function is still available and will work as before, but I want to discourage its usage. Mainly because it requires initialisation before logs could be seen, which adds a layer of complexity to already complex tests.
If some advanced logging is needed (more advanced than println!), we can use log crate, for example. tracing is a bit too heavy imo.
| const PEER_KILL_TIMEOUT: Duration = Duration::from_secs(2); | ||
|
|
||
| // TODO: read from ENV? | ||
| const IROHA_BIN: &'static str = "/Users/qua/dev/iroha/target/release/irohad"; |
There was a problem hiding this comment.
Can we do smt like?
const IROHA_BIN: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/targer/release/irohad");
There was a problem hiding this comment.
Sure, that would be better, though still temporary. I plan to:
- Add ability to switch between
debugandrelease - Add a check before executing Iroha that the binary exists and give a recommendation to run
cargo build --bin irohad.- Or maybe even run
cargo build?
- Or maybe even run
There was a problem hiding this comment.
Replaced with usage of which, i.e. irohad must be available in $PATH before running test network.
The easiest way is to run cargo install --path creates/irohad.
c71c692 to
3e86d7b
Compare
| let (network, _rt) = NetworkBuilder::new().start_blocking().unwrap(); | ||
| let test_client = network.client(); |
There was a problem hiding this comment.
I suppose a network with 1 peer is created by default? I think that's ok. No need to test consensus every time
However, I hope that network.client() returns a random client when a multi-node network is started
There was a problem hiding this comment.
I suppose a network with 1 peer is created by default? I think that's ok. No need to test consensus every time
Yes, it is.
However, I hope that
network.client()returns a random client when a multi-node network is started
Currently not, but in light of your other comment of returning random peers by default, it will.
There was a problem hiding this comment.
Made network.client() and network.peer() both return random ones.
970429a to
2cc42a2
Compare
|
With hot-start (when all WASMs are pre-built) and using Some tests are still flaky though (e.g. |
| run: | | ||
| cargo build --bin irohad | ||
| export IROHAD_EXEC=$(realpath ./target/debug/irohad) | ||
| mold --run cargo install --path ./crates/irohad |
There was a problem hiding this comment.
If we end up fixing the cache, this will likely break without which irohad || because cargo install returns an error if the binary has been installed.
There was a problem hiding this comment.
Will do, but it doesn't currently work anyway =(
I have yet to investigate (logs take 200mb) why
There was a problem hiding this comment.
Added which irohad check
cargo install works, by the way. But I got a vast amount of "multiple items" errors in rust std while it compiles wasms/ui tests, haven't figured it out yet.
657617d to
574e713
Compare
7124982 to
9d61ee4
Compare
|
Investigation: CI seems to fail due to rust-lang/wg-cargo-std-aware#68. |
d4ccbbe to
8e5b726
Compare
iroha_test_networkSigned-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
8e5b726 to
9450aec
Compare
|
This PR becomes more and more God-like, too many things. After fixing CI, I am considering splitting it into smaller PRs as much as possible. |
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
And remove extra `iroha_wasm_builder` dependency Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
|
Finally! All checks are truly green! CI has successfully run all workspace tests with no default features in a single run within 53 seconds! Same with all features enabled: Note: these tests are expectedly flaky due to #5104 |
|
Closing this PR in order to split it into approximately these smaller chunks:
|
Context
Very early draft, work in progress!
iroha_test_networkhas a few problems:thread::sleeps with pipeline time instead of providing precise lifecycle hooksBlack boxing would mean to run Iroha through its CLI as a dedicated process, just as users would do.
Solution
Re-implement
iroha_test_network:irohadas a direct child process.irohadtarget (e.g.debug,release)fslock-based solution) - no more manual ports setting. Works intra-process (cargo test) and inter-process (cargo nextestUse Nextest #4987).SIGINT(Ctrl + C). It used to be suspended.Other changes:
irohada closed binary; don't exposeIroha; remove samples from it. Closes [suggestion] Refactor Iroha CLI #4136iroha_coreandiroha_torii.unstable_networktests: they rely on a direct violation of black boxing - the use ofFreezeStatusto make peers faulty. To be re-implemented in some other way.Further steps
iroha_test_networkan executable, use in pytests and in SDKsiroha_coreitself.Flaky tests
restarted_peer_should_have_the_same_asset_amount- possibly due to a bug in Iroha? Read FIXME comment there.extra_functional::connected_peers::*sometimes fail due to [BUG] Sumeragi panics with "index out of bounds" message after unregistering a peer #5104Migration Guide (optional)
TODO
Review notes (optional)
Due to Client still being blocking, there is some ugly code with
spawn_blocking.Checklist
CONTRIBUTING.md.Undraft:
Updateremove benches and examplesirohadbinary path via ENV?)