sui_aws_orchestrator/protocol/
mod.rs1use std::path::PathBuf;
5
6use crate::{
7 benchmark::{BenchmarkParameters, BenchmarkType},
8 client::Instance,
9};
10
11pub mod narwhal;
12pub mod sui;
13
14pub trait ProtocolCommands<T: BenchmarkType> {
17 fn protocol_dependencies(&self) -> Vec<&'static str>;
19
20 fn db_directories(&self) -> Vec<PathBuf>;
22
23 fn genesis_command<'a, I>(&self, instances: I) -> String
26 where
27 I: Iterator<Item = &'a Instance>;
28
29 fn node_command<I>(
32 &self,
33 instances: I,
34 parameters: &BenchmarkParameters<T>,
35 ) -> Vec<(Instance, String)>
36 where
37 I: IntoIterator<Item = Instance>;
38
39 fn monitor_command<I>(&self, instances: I) -> Vec<(Instance, String)>
40 where
41 I: IntoIterator<Item = Instance>;
42
43 fn client_command<I>(
46 &self,
47 instances: I,
48 parameters: &BenchmarkParameters<T>,
49 ) -> Vec<(Instance, String)>
50 where
51 I: IntoIterator<Item = Instance>;
52}
53
54pub trait ProtocolMetrics {
57 const BENCHMARK_DURATION: &'static str;
59 const TOTAL_TRANSACTIONS: &'static str;
61 const LATENCY_BUCKETS: &'static str;
63 const LATENCY_SUM: &'static str;
66 const LATENCY_SQUARED_SUM: &'static str;
69
70 fn nodes_metrics_path<I>(&self, instances: I) -> Vec<(Instance, String)>
72 where
73 I: IntoIterator<Item = Instance>;
74 fn nodes_metrics_command<I>(&self, instances: I) -> Vec<(Instance, String)>
76 where
77 I: IntoIterator<Item = Instance>,
78 {
79 self.nodes_metrics_path(instances)
80 .into_iter()
81 .map(|(instance, path)| (instance, format!("curl {path}")))
82 .collect()
83 }
84
85 fn clients_metrics_path<I>(&self, instances: I) -> Vec<(Instance, String)>
87 where
88 I: IntoIterator<Item = Instance>;
89 fn clients_metrics_command<I>(&self, instances: I) -> Vec<(Instance, String)>
91 where
92 I: IntoIterator<Item = Instance>,
93 {
94 self.clients_metrics_path(instances)
95 .into_iter()
96 .map(|(instance, path)| (instance, format!("curl {path}")))
97 .collect()
98 }
99}
100
101#[cfg(test)]
102pub mod test_protocol_metrics {
103 use crate::client::Instance;
104
105 use super::ProtocolMetrics;
106
107 pub struct TestProtocolMetrics;
108
109 impl ProtocolMetrics for TestProtocolMetrics {
110 const BENCHMARK_DURATION: &'static str = "benchmark_duration";
111 const TOTAL_TRANSACTIONS: &'static str = "latency_s_count";
112 const LATENCY_BUCKETS: &'static str = "latency_s";
113 const LATENCY_SUM: &'static str = "latency_s_sum";
114 const LATENCY_SQUARED_SUM: &'static str = "latency_squared_s";
115
116 fn nodes_metrics_path<I>(&self, instances: I) -> Vec<(Instance, String)>
117 where
118 I: IntoIterator<Item = Instance>,
119 {
120 instances
121 .into_iter()
122 .enumerate()
123 .map(|(i, instance)| (instance, format!("localhost:{}/metrics", 8000 + i as u16)))
124 .collect()
125 }
126
127 fn clients_metrics_path<I>(&self, instances: I) -> Vec<(Instance, String)>
128 where
129 I: IntoIterator<Item = Instance>,
130 {
131 instances
132 .into_iter()
133 .enumerate()
134 .map(|(i, instance)| (instance, format!("localhost:{}/metrics", 9000 + i as u16)))
135 .collect()
136 }
137 }
138}