iota_aws_orchestrator/protocol/
mod.rs1use std::path::PathBuf;
6
7use crate::{
8 benchmark::{BenchmarkParameters, BenchmarkType},
9 client::Instance,
10 display,
11};
12
13pub mod iota;
14
15pub trait ProtocolCommands<T: BenchmarkType> {
18 fn protocol_dependencies(&self) -> Vec<&'static str>;
20
21 fn db_directories(&self) -> Vec<PathBuf>;
24
25 fn genesis_command<'a, I>(&self, instances: I, parameters: &BenchmarkParameters<T>) -> String
28 where
29 I: Iterator<Item = &'a Instance>;
30
31 fn node_command<I>(
34 &self,
35 instances: I,
36 parameters: &BenchmarkParameters<T>,
37 ) -> Vec<(Instance, String)>
38 where
39 I: IntoIterator<Item = Instance>;
40
41 fn monitor_command<I>(&self, instances: I) -> Vec<(Instance, String)>
42 where
43 I: IntoIterator<Item = Instance>;
44
45 fn client_command<I>(
48 &self,
49 instances: I,
50 parameters: &BenchmarkParameters<T>,
51 ) -> Vec<(Instance, String)>
52 where
53 I: IntoIterator<Item = Instance>;
54}
55
56pub trait ProtocolMetrics {
59 const BENCHMARK_DURATION: &'static str;
62 const TOTAL_TRANSACTIONS: &'static str;
65 const LATENCY_BUCKETS: &'static str;
67 const LATENCY_SUM: &'static str;
70 const LATENCY_SQUARED_SUM: &'static str;
73
74 fn nodes_metrics_path<I, T>(
76 &self,
77 instances: I,
78 parameters: &BenchmarkParameters<T>,
79 ) -> Vec<(Instance, String)>
80 where
81 I: IntoIterator<Item = Instance>,
82 T: BenchmarkType;
83 fn nodes_metrics_command<I, T>(
85 &self,
86 instances: I,
87 parameters: &BenchmarkParameters<T>,
88 ) -> Vec<(Instance, String)>
89 where
90 I: IntoIterator<Item = Instance>,
91 T: BenchmarkType,
92 {
93 self.nodes_metrics_path(instances, parameters)
94 .into_iter()
95 .map(|(instance, path)| {
96 (instance, {
97 display::action(format!("\ncurl {path}"));
98 format!("curl {path}")
99 })
100 })
101 .collect()
102 }
103
104 fn clients_metrics_path<I, T>(
106 &self,
107 instances: I,
108 parameters: &BenchmarkParameters<T>,
109 ) -> Vec<(Instance, String)>
110 where
111 I: IntoIterator<Item = Instance>,
112 T: BenchmarkType;
113 fn clients_metrics_command<I, T>(
115 &self,
116 instances: I,
117 parameters: &BenchmarkParameters<T>,
118 ) -> Vec<(Instance, String)>
119 where
120 I: IntoIterator<Item = Instance>,
121 T: BenchmarkType,
122 {
123 self.clients_metrics_path(instances, parameters)
124 .into_iter()
125 .map(|(instance, path)| (instance, format!("curl {path}")))
126 .collect()
127 }
128}
129
130#[cfg(test)]
131pub mod test_protocol_metrics {
132 use super::ProtocolMetrics;
133 use crate::{
134 benchmark::{BenchmarkParameters, BenchmarkType},
135 client::Instance,
136 };
137
138 pub struct TestProtocolMetrics;
139
140 impl ProtocolMetrics for TestProtocolMetrics {
141 const BENCHMARK_DURATION: &'static str = "benchmark_duration";
142 const TOTAL_TRANSACTIONS: &'static str = "latency_s_count";
143 const LATENCY_BUCKETS: &'static str = "latency_s";
144 const LATENCY_SUM: &'static str = "latency_s_sum";
145 const LATENCY_SQUARED_SUM: &'static str = "latency_squared_s";
146
147 fn nodes_metrics_path<I, T>(
148 &self,
149 instances: I,
150 _parameters: &BenchmarkParameters<T>,
151 ) -> Vec<(Instance, String)>
152 where
153 I: IntoIterator<Item = Instance>,
154 T: BenchmarkType,
155 {
156 instances
157 .into_iter()
158 .enumerate()
159 .map(|(i, instance)| (instance, format!("localhost:{}/metrics", 8000 + i as u16)))
160 .collect()
161 }
162
163 fn clients_metrics_path<I, T>(
164 &self,
165 instances: I,
166 _parameters: &BenchmarkParameters<T>,
167 ) -> Vec<(Instance, String)>
168 where
169 I: IntoIterator<Item = Instance>,
170 T: BenchmarkType,
171 {
172 instances
173 .into_iter()
174 .enumerate()
175 .map(|(i, instance)| (instance, format!("localhost:{}/metrics", 9000 + i as u16)))
176 .collect()
177 }
178 }
179}