Skip to content

Commit 9fa10ad

Browse files
apollo_infra_utils,apollo_integration_tests: fix max ports gen, support hybrid node args (#9671)
1 parent 901031d commit 9fa10ad

File tree

11 files changed

+36
-14
lines changed

11 files changed

+36
-14
lines changed

.github/workflows/hybrid_system_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ jobs:
297297
run: chmod +x ./target/debug/sequencer_node_setup ./target/debug/sequencer_simulator
298298

299299
- name: Create storage files
300-
run: ./target/debug/sequencer_node_setup --output-base-dir ./output --data-prefix-path /data --n-consolidated 1 --n-distributed 0
300+
run: ./target/debug/sequencer_node_setup --output-base-dir ./output --data-prefix-path /data --n-consolidated 1 --n-hybrid 0 --n-distributed 0
301301

302302
- name: Export application config dir
303303
run: |

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/apollo_infra_utils/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license-file.workspace = true
77
description = "Infrastructure utility."
88

99
[features]
10-
testing = ["colored", "dep:assert-json-diff", "socket2", "tempfile"]
10+
testing = ["colored", "dep:assert-json-diff", "socket2", "strum", "tempfile"]
1111

1212
[lints]
1313
workspace = true
@@ -20,6 +20,7 @@ num_enum.workspace = true
2020
serde = { workspace = true, features = ["derive"] }
2121
serde_json.workspace = true
2222
socket2 = { workspace = true, optional = true }
23+
strum = { workspace = true, optional = true }
2324
tempfile = { workspace = true, optional = true }
2425
thiserror.workspace = true
2526
tokio = { workspace = true, features = ["process", "rt", "time"] }
@@ -32,6 +33,7 @@ nix.workspace = true
3233
pretty_assertions.workspace = true
3334
rstest.workspace = true
3435
socket2.workspace = true
36+
strum.workspace = true
3537
tempfile.workspace = true
3638
tokio = { workspace = true, features = ["macros", "rt", "signal", "sync"] }
3739
toml.workspace = true

crates/apollo_infra_utils/src/test_utils.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ use assert_json_diff::{assert_json_matches_no_panic, CompareMode, Config};
44
use num_enum::IntoPrimitive;
55
use serde::Serialize;
66
use socket2::{Domain, Socket, Type};
7+
use strum::EnumCount;
78
use tracing::{info, instrument};
89

910
const PORTS_PER_INSTANCE: u16 = 60;
1011
pub const MAX_NUMBER_OF_INSTANCES_PER_TEST: u16 = 28;
11-
const MAX_NUMBER_OF_TESTS: u16 = 11;
12+
#[allow(clippy::as_conversions)]
13+
const MAX_NUMBER_OF_TESTS: u16 = TestIdentifier::COUNT as u16;
1214
const BASE_PORT: u16 = 11000;
1315

1416
// Ensure available ports don't exceed u16::MAX.
@@ -21,7 +23,7 @@ const _: () = {
2123
};
2224

2325
#[repr(u16)]
24-
#[derive(Debug, Copy, Clone, IntoPrimitive)]
26+
#[derive(Debug, Copy, Clone, IntoPrimitive, EnumCount)]
2527
// TODO(Nadin): Come up with a better name for this enum.
2628
pub enum TestIdentifier {
2729
EndToEndFlowTest,

crates/apollo_integration_tests/src/bin/sequencer_node_end_to_end_integration_tests/integration_test_central_and_p2p_sync_flow.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ async fn main() {
1818
const N_CONSOLIDATED_SEQUENCERS: usize = 2;
1919
/// The number of distributed remote sequencers that participate in the test.
2020
const N_DISTRIBUTED_SEQUENCERS: usize = 0;
21-
21+
/// The number of hybrid sequencers that participate in the test.
22+
const N_HYBRID_SEQUENCERS: usize = 0;
2223
const CENTRAL_SYNC_NODE: usize = 1;
2324

2425
let mut integration_test_manager = IntegrationTestManager::new(
2526
N_CONSOLIDATED_SEQUENCERS,
2627
N_DISTRIBUTED_SEQUENCERS,
28+
N_HYBRID_SEQUENCERS,
2729
None,
2830
TestIdentifier::SyncFlowIntegrationTest,
2931
)

crates/apollo_integration_tests/src/bin/sequencer_node_end_to_end_integration_tests/integration_test_positive_flow.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ async fn main() {
1313
/// The number of consolidated local sequencers that participate in the test.
1414
const N_CONSOLIDATED_SEQUENCERS: usize = 3;
1515
/// The number of distributed remote sequencers that participate in the test.
16-
const N_DISTRIBUTED_SEQUENCERS: usize = 2;
16+
const N_DISTRIBUTED_SEQUENCERS: usize = 1;
17+
/// The number of hybrid sequencers that participate in the test.
18+
const N_HYBRID_SEQUENCERS: usize = 1;
1719

1820
// Get the sequencer configurations.
1921
let mut integration_test_manager = IntegrationTestManager::new(
2022
N_CONSOLIDATED_SEQUENCERS,
2123
N_DISTRIBUTED_SEQUENCERS,
24+
N_HYBRID_SEQUENCERS,
2225
None,
2326
TestIdentifier::PositiveFlowIntegrationTest,
2427
)

crates/apollo_integration_tests/src/bin/sequencer_node_end_to_end_integration_tests/integration_test_restart_flow.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ async fn main() {
2525
/// The number of consolidated local sequencers that participate in the test.
2626
const N_CONSOLIDATED_SEQUENCERS: usize = 1;
2727
/// The number of distributed remote sequencers that participate in the test.
28-
const N_DISTRIBUTED_SEQUENCERS: usize = 2;
28+
const N_DISTRIBUTED_SEQUENCERS: usize = 1;
29+
/// The number of hybrid sequencers that participate in the test.
30+
const N_HYBRID_SEQUENCERS: usize = 1;
2931
// The indices of the nodes that we will be shutting down.
3032
// The test restarts a hybrid node and shuts down a non-consolidated (hybrid/distributed) node.
3133
const RESTART_NODE: usize = N_CONSOLIDATED_SEQUENCERS;
@@ -35,6 +37,7 @@ async fn main() {
3537
let mut integration_test_manager = IntegrationTestManager::new(
3638
N_CONSOLIDATED_SEQUENCERS,
3739
N_DISTRIBUTED_SEQUENCERS,
40+
N_HYBRID_SEQUENCERS,
3841
None,
3942
TestIdentifier::RestartFlowIntegrationTest,
4043
)

crates/apollo_integration_tests/src/bin/sequencer_node_end_to_end_integration_tests/integration_test_revert_flow.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ async fn main() {
2525
const N_L1_HANDLER_TXS: usize = 0;
2626
/// The number of consolidated local sequencers that participate in the test.
2727
const N_CONSOLIDATED_SEQUENCERS: usize = 5;
28+
/// The number of hybrid sequencers that participate in the test.
29+
const N_HYBRID_SEQUENCERS: usize = 0;
2830
/// The number of distributed remote sequencers that participate in the test.
2931
const N_DISTRIBUTED_SEQUENCERS: usize = 0;
3032

@@ -36,6 +38,7 @@ async fn main() {
3638
let mut integration_test_manager = IntegrationTestManager::new(
3739
N_CONSOLIDATED_SEQUENCERS,
3840
N_DISTRIBUTED_SEQUENCERS,
41+
N_HYBRID_SEQUENCERS,
3942
None,
4043
TestIdentifier::RevertFlowIntegrationTest,
4144
)

crates/apollo_integration_tests/src/bin/sequencer_node_setup.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ async fn main() {
2727
let test_manager = IntegrationTestManager::new(
2828
args.n_consolidated,
2929
args.n_distributed,
30+
args.n_hybrid,
3031
Some(custom_paths),
3132
// TODO(Tsabary/Nadin): add a different identifier.
3233
TestIdentifier::PositiveFlowIntegrationTest,
@@ -58,6 +59,9 @@ struct Args {
5859
#[arg(long)]
5960
n_distributed: usize,
6061

62+
#[arg(long)]
63+
n_hybrid: usize,
64+
6165
#[arg(long)]
6266
output_base_dir: String,
6367

crates/apollo_integration_tests/src/integration_test_manager.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ impl IntegrationTestManager {
265265
pub async fn new(
266266
num_of_consolidated_nodes: usize,
267267
num_of_distributed_nodes: usize,
268+
num_of_hybrid_nodes: usize,
268269
custom_paths: Option<CustomPaths>,
269270
test_unique_id: TestIdentifier,
270271
) -> Self {
@@ -274,6 +275,7 @@ impl IntegrationTestManager {
274275
&tx_generator,
275276
num_of_consolidated_nodes,
276277
num_of_distributed_nodes,
278+
num_of_hybrid_nodes,
277279
custom_paths,
278280
test_unique_id,
279281
)
@@ -856,23 +858,23 @@ async fn get_sequencer_setup_configs(
856858
// TODO(Tsabary/Nadin): instead of number of nodes, this should be a vector of deployments.
857859
num_of_consolidated_nodes: usize,
858860
num_of_distributed_nodes: usize,
861+
num_of_hybrid_nodes: usize,
859862
custom_paths: Option<CustomPaths>,
860863
test_unique_id: TestIdentifier,
861864
) -> (Vec<NodeSetup>, HashSet<usize>) {
862865
let mut available_ports_generator = AvailablePortsGenerator::new(test_unique_id.into());
863866

864-
let mut node_component_configs =
865-
Vec::with_capacity(num_of_consolidated_nodes + num_of_distributed_nodes);
867+
let mut node_component_configs = Vec::with_capacity(
868+
num_of_consolidated_nodes + num_of_distributed_nodes + num_of_hybrid_nodes,
869+
);
866870
for _ in 0..num_of_consolidated_nodes {
867871
node_component_configs.push(create_consolidated_component_configs());
868872
}
869-
// Testing the two various node configurations: distributed and hybrid.
870-
// TODO(Tsabary): better handling of the number of each type.
871-
for _ in 0..num_of_distributed_nodes / 2 {
873+
for _ in 0..num_of_hybrid_nodes {
872874
node_component_configs
873875
.push(create_hybrid_component_configs(&mut available_ports_generator));
874876
}
875-
for _ in num_of_distributed_nodes / 2..num_of_distributed_nodes {
877+
for _ in 0..num_of_distributed_nodes {
876878
node_component_configs
877879
.push(create_distributed_component_configs(&mut available_ports_generator));
878880
}

0 commit comments

Comments
 (0)