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

Integration tests #8

Merged

Conversation

paweljakubas
Copy link
Collaborator

@paweljakubas paweljakubas commented Oct 30, 2024

There are two suites of tests to be added.

  1. Instantiating websocket server with client and showing that websocket server emulating hydra emits the expected events. Running:
cargo test hydra_emulation -- --nocapture
  1. Using the websocket server emulating hydra and treating it as source and connecting to hydra-oura-stdout pipeline as driven by examples/hydra.config.toml. This running:
cargo test hydra_oura_stdout -- --nocapture

Here we use dedicated daemon.toml which produces json. Every run it is truncated to 0, but one can inspect how it looks like -> tests/hydra/logs.txt

@paweljakubas paweljakubas self-assigned this Oct 30, 2024
tests/hydra.rs Outdated
Comment on lines 467 to 485
fn hydra_oura_stdout_scenario_1() -> TestResult {
let tx_event = r#"{"event":"apply","point":{"hash":"84e657e3dd5241caac75b749195f78684023583736cc08b2896290ab","slot":7},"record":{"hex":"84a300d9010281825820f0a39560ea80ccc68e8dffb6a4a077c8927811f06c5d9058d0fa2d1a8d047d2000018282581d605e4e214a6addd337126b3a61faad5dfe1e4f14f637a8969e3a05eefd1a001e848082581d600d45f2b310a98e766cee2ab2f6756c91719bd7b35929cef058365b651a015ef3c00200a100d90102818258200f193a88190f6dace0a3db1e0e50797a6e28cd4b6e289260dc96b5a8d7934bf858401b13ee550f3167a1b94796f2a2f5e22d782d628336a7797c5b798f358fa564dbe92ea75a4e2449eb2cef59c097d8497545ef1e4ea441b88a481194323ae7c608f5f6"}}"#;
let events = vec![
"PeerConnected".to_string(),
"PeerConnected".to_string(),
"Greetings".to_string(),
"HeadIsInitializing".to_string(),
"Committed".to_string(),
"Committed".to_string(),
"Committed".to_string(),
"HeadIsOpen".to_string(),
"TxValid".to_string(),
tx_event.to_string(),
"SnapshotConfirmed".to_string(),
"HeadIsClosed".to_string(),
"ReadyToFanout".to_string(),
"HeadIsFinalized".to_string(),
];
hydra_oura_stdout_test("tests/hydra/scenario_1.txt".to_string(), events)
Copy link
Owner

Choose a reason for hiding this comment

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

I tried mutating the expectations: tweaking 1) tx binary, 2) tx event slot, 3) dropping an event, but the test appears to still pass

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

now it signals when failing. nice catch.thanks

tests/hydra.rs Outdated Show resolved Hide resolved
tests/hydra.rs Outdated
predicates.push(predicate_fn.eval(json));
count += 1;
}
assert_eq!(predicates, vec![true; expected.len()]);
Copy link
Owner

Choose a reason for hiding this comment

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

Off the top of my head, I find it odd that the oura_pipeline is responsible for both capturing the output and performing the assertion. Did you consider returning the captured outputs in the result?

And — maybe we could check the output with something like goldenfile instead of assert_eq if the output is deterministic? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added golden as suggested 👍

refining testing plus gitignore

spawn cmd process and fix typo

truncate log file

make sure result of tests is taken into account

clean redundant tests
- Use random TCP ports
- Use random output files
- Use goldenfile (has the practical UPDATE_GOLDENFILES=1 flag)
@Anviking Anviking mentioned this pull request Nov 12, 2024
Copy link
Owner

@Anviking Anviking left a comment

Choose a reason for hiding this comment

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

Wonderful to have 👍 I created a PR with some tweaks to this PR #10

@paweljakubas paweljakubas merged commit bbfc0c3 into paweljakubas/test-framework Nov 12, 2024
@paweljakubas paweljakubas deleted the paweljakubas/integration-tests branch November 12, 2024 12:01
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