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

simulators/portal: refactor sims into 1 sim multi suite format #994

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/continue_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
# this makes sure the rust code is good
rust-simulators:
docker:
- image: cimg/rust:1.71.1
- image: cimg/rust:1.75.0
steps:
- checkout
- run:
Expand Down
2 changes: 1 addition & 1 deletion clients/trin-bridge/trin_bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ else
exit 1
fi

RUST_LOG=debug portal-bridge --node-count 1 $FLAGS --executable-path ./usr/bin/trin --mode test:/test_data_collection_of_forks_blocks.yaml --external-ip $IP_ADDR --epoch-accumulator-path . trin
RUST_LOG=debug portal-bridge --node-count 1 $FLAGS --executable-path ./usr/bin/trin --mode test:/test_data_collection_of_forks_blocks.yaml --el-provider test --external-ip $IP_ADDR --epoch-accumulator-path . trin
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "rpc-compat"
name = "beacon"
version = "0.1.0"
authors = ["Ognyan Genev <[email protected]>", "Kolby ML (Moroz Liebl) <[email protected]>"]
edition = "2021"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM rust:1.71.1 AS builder
FROM rust:1.75.0 AS builder

# create a new empty shell project
RUN USER=root cargo new --bin rpc-compat
WORKDIR /rpc-compat
RUN USER=root cargo new --bin beacon
WORKDIR /beacon

RUN apt-get update && apt-get install clang -y

Expand All @@ -19,8 +19,8 @@ FROM ubuntu:22.04
RUN apt update && apt install wget -y

# copy build artifacts from build stage
COPY --from=builder /rpc-compat/target/release/rpc-compat .
COPY --from=builder /beacon/target/release/beacon .

ENV RUST_LOG=debug

ENTRYPOINT ["./rpc-compat"]
ENTRYPOINT ["./beacon"]
43 changes: 43 additions & 0 deletions simulators/portal/beacon/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
mod suites;

use hivesim::{Simulation, Suite, TestSpec};
use suites::rpc_compat::run_rpc_compat_test_suite;

#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let mut beacon_rpc_compat = Suite {
name: "beacon-rpc-compat".to_string(),
description: "The RPC-compatibility test suite runs a set of RPC related tests against a
running node. It tests client implementations of the JSON-RPC API for
conformance with the portal network API specification."
.to_string(),
tests: vec![],
};

beacon_rpc_compat.add(TestSpec {
name: "client launch".to_string(),
description: "This test launches the client and collects its logs.".to_string(),
always_run: false,
run: run_rpc_compat_test_suite,
client: None,
});

let sim = Simulation::new();
run_suite(sim, vec![beacon_rpc_compat]).await;
}

async fn run_suite(host: Simulation, suites: Vec<Suite>) {
for suite in suites {
let name = suite.clone().name;
let description = suite.clone().description;

let suite_id = host.start_suite(name, description, "".to_string()).await;

for test in &suite.tests {
test.run_test(host.clone(), suite_id, suite.clone()).await;
}

host.end_suite(suite_id).await;
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
pub const HIVE_PORTAL_NETWORKS_SELECTED: &str = "HIVE_PORTAL_NETWORKS_SELECTED";
pub const BEACON_STRING: &str = "beacon";

// trin-bridge constants
pub const TRIN_BRIDGE_CLIENT_TYPE: &str = "trin-bridge";
2 changes: 2 additions & 0 deletions simulators/portal/beacon/src/suites/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod constants;
pub mod rpc_compat;

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions .../portal/history/portal-interop/Cargo.toml → simulators/portal/history/Cargo.toml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "portal-interop"
name = "history"
version = "0.1.0"
authors = ["Ognyan Genev <[email protected]>", "Kolby ML (Moroz Liebl) <[email protected]>"]
edition = "2021"
Expand All @@ -8,9 +8,10 @@ edition = "2021"
ethportal-api = { git = "https://github.com/ethereum/trin", rev = "2a32224e3c2b0b80bc37c1b692c33016371f197a" }
portal-spec-test-utils-rs = { git = "https://github.com/ethereum/portal-spec-tests", rev = "d1e996d0d4dc2136b3cd38d9e25cdc3a6b74dcd9" }
hivesim = { git = "https://github.com/ethereum/portal-hive", rev = "8ff1e3d3c941dd00d56dacd777a5dfb71edf402f" }
itertools = "0.10.5"
futures = "0.3.25"
serde_json = "1.0.87"
serde_yaml = "0.9"
tokio = { version = "1", features = ["full"] }
tracing = "0.1.37"
tracing-subscriber = "0.3.16"
itertools = "0.10.5"
serde_yaml = "0.9"
tokio = { version = "1", features = ["full"] }
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM rust:1.71.1 AS builder
FROM rust:1.75.0 AS builder

# create a new empty shell project
RUN USER=root cargo new --bin portal-interop
WORKDIR /portal-interop
RUN USER=root cargo new --bin history
WORKDIR /history

# copy over manifests and source to build image
COPY Cargo.toml ./Cargo.toml
Expand All @@ -17,9 +17,9 @@ FROM ubuntu:22.04
RUN apt update && apt install wget -y

# copy build artifacts from build stage
COPY --from=builder /portal-interop/target/release/portal-interop .
COPY --from=builder /history/target/release/history .
ADD https://raw.githubusercontent.com/ethereum/portal-spec-tests/master/tests/mainnet/history/hive/test_data_collection_of_forks_blocks.yaml ./test-data/test_data_collection_of_forks_blocks.yaml

ENV RUST_LOG=debug

ENTRYPOINT ["./portal-interop"]
ENTRYPOINT ["./history"]
1 change: 0 additions & 1 deletion simulators/portal/history/portal-interop/src/constants.rs

This file was deleted.

14 changes: 0 additions & 14 deletions simulators/portal/history/portal-mesh/Cargo.toml

This file was deleted.

24 changes: 0 additions & 24 deletions simulators/portal/history/portal-mesh/Dockerfile

This file was deleted.

14 changes: 0 additions & 14 deletions simulators/portal/history/rpc-compat/Cargo.toml

This file was deleted.

24 changes: 0 additions & 24 deletions simulators/portal/history/rpc-compat/Dockerfile

This file was deleted.

92 changes: 92 additions & 0 deletions simulators/portal/history/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
pub mod suites;

use hivesim::{Simulation, Suite, TestSpec};
use suites::interop::test_portal_interop;
use suites::mesh::test_portal_scenarios;
use suites::rpc_compat::run_rpc_compat_test_suite;
use suites::trin_bridge::test_portal_bridge;

#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let mut rpc_compat = Suite {
name: "history-rpc-compat".to_string(),
description: "The RPC-compatibility test suite runs a set of RPC related tests against a
running node. It tests client implementations of the JSON-RPC API for
conformance with the portal network API specification."
.to_string(),
tests: vec![],
};

rpc_compat.add(TestSpec {
name: "client launch".to_string(),
description: "This test launches the client and collects its logs.".to_string(),
always_run: false,
run: run_rpc_compat_test_suite,
client: None,
});

let mut interop = Suite {
name: "history-interop".to_string(),
description:
"The interop test suite runs a set of scenarios to test interoperability between
portal network clients"
.to_string(),
tests: vec![],
};

interop.add(TestSpec {
name: "client launch".to_string(),
description: "This test launches the client and collects its logs.".to_string(),
always_run: false,
run: test_portal_interop,
client: None,
});

let mut mesh = Suite {
name: "history-mesh".to_string(),
description: "The portal mesh test suite runs a set of scenarios to test 3 clients"
.to_string(),
tests: vec![],
};

mesh.add(TestSpec {
name: "client launch".to_string(),
description: "This test launches the client and collects its logs.".to_string(),
always_run: false,
run: test_portal_scenarios,
client: None,
});

let mut trin_bridge = Suite {
name: "history-trin-bridge".to_string(),
description: "The portal bridge test suite".to_string(),
tests: vec![],
};

trin_bridge.add(TestSpec {
name: "client launch".to_string(),
description: "This test launches the client and collects its logs.".to_string(),
always_run: false,
run: test_portal_bridge,
client: None,
});

let sim = Simulation::new();
run_suite(sim, vec![rpc_compat, interop, mesh, trin_bridge]).await;
}

async fn run_suite(host: Simulation, suites: Vec<Suite>) {
for suite in suites {
let name = suite.clone().name;
let description = suite.clone().description;

let suite_id = host.start_suite(name, description, "".to_string()).await;

for test in &suite.tests {
test.run_test(host.clone(), suite_id, suite.clone()).await;
}

host.end_suite(suite_id).await;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pub const TEST_DATA_FILE_PATH: &str = "./test-data/test_data_collection_of_forks_blocks.yaml";

// trin-bridge constants
pub const TRIN_BRIDGE_CLIENT_TYPE: &str = "trin-bridge";
pub const BOOTNODES_ENVIRONMENT_VARIABLE: &str = "HIVE_BOOTNODES";
pub const HIVE_CHECK_LIVE_PORT: &str = "HIVE_CHECK_LIVE_PORT";
pub const TEST_DATA_FILE_PATH: &str = "./test-data/test_data_collection_of_forks_blocks.yaml";
Loading