@@ -50,15 +50,41 @@ pub async fn run(clients: Vec<ReqwestClient>, config: Config) -> Result<()> {
5050 }
5151
5252 let mut workload_group_index = 0 ;
53+ let read_client = clients[ 0 ] . clone ( ) ;
5354
5455 loop {
55- let current_traffic_gen = & config. workload_groups [ workload_group_index] ;
56+ let workload_group = & config. workload_groups [ workload_group_index] ;
5657 info ! (
57- "Starting workload group phase {}: {:? }" ,
58- workload_group_index, current_traffic_gen . name
58+ "Starting workload group phase {}: {}" ,
59+ workload_group_index, workload_group . name
5960 ) ;
6061
61- run_workload_group ( & clients, & config, workload_group_index) . await ?;
62+ let start_time = Utc :: now ( ) ;
63+ let metrics = Arc :: new ( Metrics :: default ( ) ) ;
64+ if let Err ( e) =
65+ run_workload_group ( & clients, & config, workload_group_index, metrics. clone ( ) ) . await
66+ {
67+ error ! (
68+ workload_group = workload_group. name,
69+ "Failed to run workload group: {e:?}"
70+ ) ;
71+ }
72+
73+ if let Some ( report_dir) = config. report_dir . as_deref ( ) {
74+ let report = Report :: new (
75+ config. clone ( ) ,
76+ workload_group_index,
77+ start_time,
78+ & metrics,
79+ & read_client,
80+ config. prom_url . clone ( ) ,
81+ )
82+ . await ;
83+
84+ if let Err ( e) = report. to_json_file ( report_dir. as_ref ( ) ) {
85+ error ! ( "Failed to write report: {e:?}" ) ;
86+ }
87+ } ;
6288
6389 workload_group_index = ( workload_group_index + 1 ) % config. workload_groups . len ( ) ;
6490 }
@@ -71,6 +97,7 @@ async fn run_workload_group(
7197 clients : & [ ReqwestClient ] ,
7298 config : & Config ,
7399 workload_group_index : usize ,
100+ metrics : Arc < Metrics > ,
74101) -> Result < ( ) > {
75102 let workload_group = & config. workload_groups [ workload_group_index] ;
76103 let read_client = clients[ 0 ] . clone ( ) ;
@@ -79,7 +106,6 @@ async fn run_workload_group(
79106 let shutdown_clone = Arc :: clone ( & shutdown) ;
80107
81108 // shared state for monitoring
82- let metrics = Arc :: new ( Metrics :: default ( ) ) ;
83109 let sent_txs = Arc :: new ( DashMap :: with_capacity ( 100_000 ) ) ;
84110
85111 // Shared tasks for all workers in the workload group
@@ -148,11 +174,9 @@ async fn run_workload_group(
148174
149175 let runtime_seconds = ( workload_group. runtime_minutes * 60. ) as u64 ;
150176 let timeout = tokio:: time:: sleep ( Duration :: from_secs ( runtime_seconds) ) ;
151- // Start time is after all tasks are started. Tasks take some time to start up so this is a better approximation of the start time
152- let start_time = Utc :: now ( ) ;
153177
154178 // Wait for all tasks to complete or timeout
155- let result = tokio:: select! {
179+ tokio:: select! {
156180 _ = timeout => {
157181 info!( "Traffic phase completed after {} minutes" , workload_group. runtime_minutes) ;
158182 shutdown_clone. store( true , Ordering :: Relaxed ) ;
@@ -171,26 +195,7 @@ async fn run_workload_group(
171195 }
172196 }
173197 }
174- } ;
175-
176- // Write report regardless of result and return result regardless of reporting errors
177- if let Some ( report_dir) = config. report_dir . as_deref ( ) {
178- let report = Report :: new (
179- config. clone ( ) ,
180- workload_group_index,
181- start_time,
182- & metrics,
183- & read_client,
184- config. prom_url . clone ( ) ,
185- )
186- . await ;
187-
188- if let Err ( e) = report. to_json_file ( report_dir. as_ref ( ) ) {
189- error ! ( "Failed to write report: {e:?}" ) ;
190- }
191- } ;
192-
193- result
198+ }
194199}
195200
196201fn run_traffic_gen (
0 commit comments