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