@@ -184,3 +184,52 @@ def test_gromacs_repeats(mutable_config, mutable_mock_workspace_path):
184
184
assert "gromacs.water_bare.pme_single_rank" in data
185
185
assert "gromacs.water_bare.pme_single_rank.1" not in data
186
186
assert "gromacs.water_bare.pme_single_rank.2" not in data
187
+
188
+
189
+ @pytest .mark .long
190
+ def test_repeat_stats (mutable_config , mutable_mock_workspace_path , request ):
191
+ test_config = """
192
+ ramble:
193
+ variables:
194
+ n_nodes: 1
195
+ processes_per_node: 1
196
+ mpi_command: ''
197
+ batch_submit: '{execute_experiment}'
198
+ applications:
199
+ sleep:
200
+ workloads:
201
+ sleep:
202
+ experiments:
203
+ sleep_test:
204
+ n_repeats: 3
205
+ """
206
+ workspace_name = request .node .name
207
+ with ramble .workspace .create (workspace_name ) as ws :
208
+ ws .write ()
209
+ config_path = os .path .join (ws .config_dir , ramble .workspace .config_file_name )
210
+ with open (config_path , "w+" ) as f :
211
+ f .write (test_config )
212
+ ws ._re_read ()
213
+
214
+ workspace ("setup" , "--dry-run" , global_args = ["-w" , workspace_name ])
215
+
216
+ base_exp_dir = os .path .join (ws .root , "experiments" , "sleep" , "sleep" , "sleep_test" )
217
+ for r in range (1 , 4 ):
218
+ dir = f"{ base_exp_dir } .{ r } "
219
+ log_path = os .path .join (dir , f"{ os .path .basename (dir )} .out" )
220
+ with open (log_path , "w+" ) as f :
221
+ f .write (f"{ r } :0.0elapsed\n " )
222
+ # Purposely fail the last experiment
223
+ if r != 3 :
224
+ f .write (f"Sleep for { 60 * r } seconds\n " )
225
+
226
+ workspace ("analyze" , "-s" , global_args = ["-w" , workspace_name ])
227
+ result_file = glob .glob (os .path .join (ws .root , "results.latest.txt" ))[0 ]
228
+ with open (result_file ) as f :
229
+ data = f .read ()
230
+ assert "summary::n_total_repeats = 3 repeats" in data
231
+ assert "summary::n_successful_repeats = 2 repeats" in data
232
+ assert "summary::min = 1.0 minutes" in data
233
+ # Assert that the last experiment is not included in the stats
234
+ assert "summary::max = 2.0 minutes" in data
235
+ assert "summary::mean = 1.5 minutes" in data
0 commit comments