-
Notifications
You must be signed in to change notification settings - Fork 279
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
refactor!: black-box integration tests #5087
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also
logger
is 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.
crates/iroha_test_network/src/lib.rs
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do smt like?
const IROHA_BIN: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/targer/release/irohad");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that would be better, though still temporary. I plan to:
- Add ability to switch between
debug
andrelease
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
.github/workflows/iroha2-dev-pr.yml
Outdated
@@ -76,8 +76,7 @@ jobs: | |||
path: ${{ env.DOCKER_COMPOSE_PATH }} | |||
- name: Run tests, with coverage | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_network
Signed-off-by: 0x009922 <[email protected]>
Signed-off-by: 0x009922 <[email protected]>
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 <[email protected]>
Signed-off-by: 0x009922 <[email protected]>
And remove extra `iroha_wasm_builder` dependency Signed-off-by: 0x009922 <[email protected]>
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_network
has a few problems:thread::sleep
s 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
:irohad
as a direct child process.irohad
target (e.g.debug
,release
)fslock
-based solution) - no more manual ports setting. Works intra-process (cargo test
) and inter-process (cargo nextest
Use Nextest #4987).SIGINT
(Ctrl + C). It used to be suspended.Other changes:
irohad
a closed binary; don't exposeIroha
; remove samples from it. Closes [suggestion] Refactor Iroha CLI #4136iroha_core
andiroha_torii
.unstable_network
tests: they rely on a direct violation of black boxing - the use ofFreezeStatus
to make peers faulty. To be re-implemented in some other way.Further steps
iroha_test_network
an executable, use in pytests and in SDKsiroha_core
itself.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 examplesirohad
binary path via ENV?)