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: implement e2e-tests crate and kv-store example #931

Merged
merged 11 commits into from
Nov 14, 2024
Merged

Conversation

fbozic
Copy link
Member

@fbozic fbozic commented Nov 3, 2024

Asserting/expecting turned out to be a bad idea since I can not handle node stop properly. I will fix that in the follow-up PR.
The output format can be also improved massively.

Failing tests example:

❯ cargo run -p e2e-tests -- --input-dir ./e2e-tests/config --output-dir ./e2e-tests/corpus --merod-binary ./target/debug/merod --meroctl-binary ./target/debug/meroctl
Running command './target/debug/merod' ["--home", "./e2e-tests/corpus/nodes", "--node-name", "node1", "init", "--swarm-port", "2427", "--server-port", "2527"]
Running command './target/debug/merod' ["--home", "./e2e-tests/corpus/nodes", "--node-name", "node1", "run"]
Running command './target/debug/merod' ["--home", "./e2e-tests/corpus/nodes", "--node-name", "node2", "init", "--swarm-port", "2428", "--server-port", "2528"]
Running command './target/debug/merod' ["--home", "./e2e-tests/corpus/nodes", "--node-name", "node2", "run"]
Loaded test scenario from file: "./e2e-tests/config/scenarios/kv-store/test.json"
TestScenario { steps: [ContextCreate(CreateContextStep { application: LocalFile("./apps/kv-store/res/kv_store.wasm") }), JsonRpcExecute(JsonRpcExecuteStep { method_name: "set", args_json: Object {"key": String("foo"), "value": String("bar")}, expected_result_json: None }), JsonRpcExecute(JsonRpcExecuteStep { method_name: "get", args_json: Object {"key": String("foo")}, expected_result_json: Some(String("baz")) }), ContextInviteJoin(InviteJoinContextStep)] }
================= Starting step =================
Step: ContextCreate(CreateContextStep { application: LocalFile("./apps/kv-store/res/kv_store.wasm") })
Running command './target/debug/meroctl' ["--home", "./e2e-tests/corpus/nodes", "--node-name", "node1", "--output-format", "json", "app", "install", "--path", "./apps/kv-store/res/kv_store.wasm"]
Running command './target/debug/meroctl' ["--home", "./e2e-tests/corpus/nodes", "--node-name", "node1", "--output-format", "json", "context", "create", "-a", "BA8iKev6bGA3nedpnGDQvZFzhsK18QoAauDnk8Q4hJDL"]
================= Finished step =================
================= Starting step =================
Step: JsonRpcExecute(JsonRpcExecuteStep { method_name: "set", args_json: Object {"key": String("foo"), "value": String("bar")}, expected_result_json: None })
Running command './target/debug/meroctl' ["--home", "./e2e-tests/corpus/nodes", "--node-name", "node1", "--output-format", "json", "json-rpc", "3eLoXVo4U2QtWr6cPMmdRK2xnQmJPn8dR8LbMAkGjnem", "set", "--args-json", "{\"key\":\"foo\",\"value\":\"bar\"}"]
================= Finished step =================
================= Starting step =================
Step: JsonRpcExecute(JsonRpcExecuteStep { method_name: "get", args_json: Object {"key": String("foo")}, expected_result_json: Some(String("baz")) })
Running command './target/debug/meroctl' ["--home", "./e2e-tests/corpus/nodes", "--node-name", "node1", "--output-format", "json", "json-rpc", "3eLoXVo4U2QtWr6cPMmdRK2xnQmJPn8dR8LbMAkGjnem", "get", "--args-json", "{\"key\":\"foo\"}"]
Error: JSON RPC result output mismatch:
expected: "baz"
actual  : "bar"

Location:
    e2e-tests/src/steps/jsonrpc_execute.rs:38:17

@fbozic fbozic self-assigned this Nov 3, 2024
@fbozic fbozic requested a review from miraclx November 3, 2024 17:54
e2e-tests/src/meroctl.rs Outdated Show resolved Hide resolved
e2e-tests/src/tmp.rs Outdated Show resolved Hide resolved
e2e-tests/src/driver.rs Outdated Show resolved Hide resolved
e2e-tests/src/steps/context_create.rs Outdated Show resolved Hide resolved
e2e-tests/src/driver.rs Outdated Show resolved Hide resolved
Comment on lines +72 to +77
use nix::sys::signal::{self, Signal};
use nix::unistd::Pid;

if let Some(child_id) = child.id() {
signal::kill(Pid::from_raw(child_id as i32), Signal::SIGTERM)?;
}
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I've tried that initially but the node doesn't exit gracefully and we get a broken pipe error.

e2e-tests/src/main.rs Outdated Show resolved Hide resolved
@fbozic fbozic requested a review from miraclx November 13, 2024 19:47
@fbozic fbozic merged commit d303ad1 into master Nov 14, 2024
3 checks passed
@fbozic fbozic deleted the feat/e2e-tests branch November 14, 2024 11:04
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.

3 participants