Skip to content

Commit c2127ab

Browse files
apollo_deployments: distributed layout jsonnet test
1 parent 8bb7c13 commit c2127ab

4 files changed

Lines changed: 126 additions & 1 deletion

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Distributed layout structure.
2+
local catalog = import '../infra/catalog.libsonnet';
3+
local templates = import '../infra/templates.libsonnet';
4+
{
5+
reactive:: catalog.reactive,
6+
active:: catalog.active,
7+
// Hosted-but-not-remote-served reactive components (LocalExecutionWithRemoteDisabled when hosted).
8+
localOnly:: ['config_manager', 'mempool_p2p'],
9+
10+
// Canonical per-component infra ports (shared across layouts).
11+
ports:: templates.componentPorts,
12+
serviceDns:: {
13+
batcher: 'sequencer-batcher-service',
14+
class_manager: 'sequencer-class-manager-service',
15+
committer: 'sequencer-committer-service',
16+
gateway: 'sequencer-gateway-service',
17+
l1: 'sequencer-l1-service',
18+
mempool: 'sequencer-mempool-service',
19+
proof_manager: 'sequencer-proof-manager-service',
20+
sierra_compiler: 'sequencer-sierra-compiler-service',
21+
signature_manager: 'sequencer-signature-manager-service',
22+
state_sync: 'sequencer-state-sync-service',
23+
},
24+
// Remote-client tuning of components homed in each service (get_scale_policy + get_retries).
25+
// Gateway/SierraCompiler are AutoScaled (idle 0); L1 uses RETRIES_FOR_L1_SERVICES (0); rest static.
26+
scale:: {
27+
batcher: { idle: templates.IDLE_STATIC, retries: templates.RETRIES_DEFAULT },
28+
class_manager: { idle: templates.IDLE_STATIC, retries: templates.RETRIES_DEFAULT },
29+
committer: { idle: templates.IDLE_STATIC, retries: templates.RETRIES_DEFAULT },
30+
gateway: { idle: templates.IDLE_AUTO_SCALED, retries: templates.RETRIES_DEFAULT },
31+
l1: { idle: templates.IDLE_STATIC, retries: templates.RETRIES_L1 },
32+
mempool: { idle: templates.IDLE_STATIC, retries: templates.RETRIES_DEFAULT },
33+
proof_manager: { idle: templates.IDLE_STATIC, retries: templates.RETRIES_DEFAULT },
34+
sierra_compiler: { idle: templates.IDLE_AUTO_SCALED, retries: templates.RETRIES_DEFAULT },
35+
signature_manager: { idle: templates.IDLE_STATIC, retries: templates.RETRIES_DEFAULT },
36+
state_sync: { idle: templates.IDLE_STATIC, retries: templates.RETRIES_DEFAULT },
37+
},
38+
// Per service: components hosted (runs) and reactive components consumed remotely (uses).
39+
// Everything not listed is Disabled. Transcribed from distributed.rs get_*_component_config.
40+
services:: {
41+
batcher: {
42+
runs: ['batcher', 'config_manager', 'monitoring_endpoint'],
43+
uses: ['class_manager', 'committer', 'l1_events_provider', 'mempool', 'proof_manager'],
44+
},
45+
class_manager: {
46+
runs: ['class_manager', 'config_manager', 'monitoring_endpoint'],
47+
uses: ['sierra_compiler'],
48+
},
49+
committer: {
50+
runs: ['committer', 'config_manager', 'monitoring_endpoint'],
51+
uses: ['batcher'],
52+
},
53+
consensus_manager: {
54+
runs: ['config_manager', 'consensus_manager', 'monitoring_endpoint'],
55+
uses: ['batcher', 'class_manager', 'l1_gas_price_provider', 'proof_manager', 'state_sync', 'signature_manager'],
56+
},
57+
http_server: {
58+
runs: ['config_manager', 'http_server', 'monitoring_endpoint'],
59+
uses: ['gateway'],
60+
},
61+
gateway: {
62+
runs: ['gateway', 'config_manager', 'monitoring_endpoint'],
63+
uses: ['class_manager', 'mempool', 'proof_manager', 'state_sync'],
64+
},
65+
l1: {
66+
runs: [
67+
'l1_gas_price_provider',
68+
'l1_events_provider',
69+
'config_manager',
70+
'l1_gas_price_scraper',
71+
'l1_events_scraper',
72+
'monitoring_endpoint',
73+
],
74+
uses: ['state_sync', 'batcher'],
75+
},
76+
proof_manager: {
77+
runs: ['proof_manager', 'config_manager', 'monitoring_endpoint'],
78+
uses: [],
79+
},
80+
mempool: {
81+
runs: ['mempool', 'mempool_p2p', 'config_manager', 'monitoring_endpoint'],
82+
uses: ['class_manager', 'gateway', 'proof_manager'],
83+
},
84+
sierra_compiler: {
85+
runs: ['sierra_compiler', 'config_manager', 'monitoring_endpoint'],
86+
uses: [],
87+
},
88+
signature_manager: {
89+
runs: ['signature_manager', 'config_manager', 'monitoring_endpoint'],
90+
uses: [],
91+
},
92+
state_sync: {
93+
runs: ['state_sync', 'config_manager', 'monitoring_endpoint'],
94+
uses: ['class_manager'],
95+
},
96+
},
97+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Generates the `components` map for every service of the distributed layout.
2+
local derive = import '../lib/infra/derive.libsonnet';
3+
local distributed = import '../lib/layouts/distributed.libsonnet';
4+
5+
{
6+
[service]: derive.infraFor(distributed, service)
7+
for service in std.objectFields(distributed.services)
8+
}

crates/apollo_deployments/src/deployment_definitions_test.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ use strum::IntoEnumIterator;
1010
use tempfile::NamedTempFile;
1111

1212
use crate::deployment_definitions::ComponentConfigInService;
13-
use crate::jsonnet::{test_consolidated_infra_matches_rust, test_hybrid_infra_matches_rust};
13+
use crate::jsonnet::{
14+
test_consolidated_infra_matches_rust,
15+
test_distributed_infra_matches_rust,
16+
test_hybrid_infra_matches_rust,
17+
};
1418
use crate::service::NodeType;
1519
use crate::test_utils::SecretsConfigOverride;
1620

@@ -36,6 +40,16 @@ fn consolidated_infra_matches_rust() {
3640
test_consolidated_infra_matches_rust();
3741
}
3842

43+
/// Verifies the jsonnet distributed infra config matches the Rust deployment definitions
44+
/// (distributed.rs).
45+
#[test]
46+
fn distributed_infra_matches_rust() {
47+
env::set_current_dir(resolve_project_relative_path("").unwrap())
48+
.expect("Couldn't set working dir.");
49+
50+
test_distributed_infra_matches_rust();
51+
}
52+
3953
/// Test that the deployment file is up to date.
4054
#[test]
4155
fn deployment_files_are_up_to_date() {

crates/apollo_deployments/src/jsonnet.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use serde_json::Value;
66
use strum::IntoEnumIterator;
77

88
use crate::deployments::consolidated::ConsolidatedNodeServiceName;
9+
use crate::deployments::distributed::DistributedNodeServiceName;
910
use crate::deployments::hybrid::HybridNodeServiceName;
1011
use crate::service::{GetComponentConfigs, NodeService, NodeType};
1112

@@ -69,6 +70,11 @@ pub fn test_consolidated_infra_matches_rust() {
6970
assert_infra_matches_rust::<ConsolidatedNodeServiceName>();
7071
}
7172

73+
/// The jsonnet distributed infra matches `deployments/distributed.rs`.
74+
pub fn test_distributed_infra_matches_rust() {
75+
assert_infra_matches_rust::<DistributedNodeServiceName>();
76+
}
77+
7278
/// Clones a `components` map with `url` and `port` removed from each component object — the two
7379
/// fields the Rust config leaves as deploy-time placeholders, so they can't be compared against the
7480
/// jsonnet's baked-in real values.

0 commit comments

Comments
 (0)