Skip to content

Commit b722401

Browse files
committed
ft-orchestration fix ipfixcol2 log download when test failed
1 parent 901a367 commit b722401

2 files changed

Lines changed: 23 additions & 7 deletions

File tree

tools/ft-orchestration/src/collector/ipfixcol2.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@ def download_logs(self, directory: str):
302302
directory : str
303303
Path to a local directory where logs should be stored.
304304
"""
305+
retries = 3
306+
while self._executor.is_running() and retries > 0:
307+
try:
308+
self.stop()
309+
except Exception:
310+
self._executor.wait_or_kill()
311+
retries -= 1
312+
305313
if self._executor.is_running():
306314
self._executor.terminate()
307315

tools/ft-orchestration/tests/simulation/test_simulation_threshold.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import gc
1313
import ipaddress
1414
import logging
15+
import math
1516
import os
1617
import shutil
1718
import sys
@@ -201,8 +202,11 @@ def test_simulation_threshold(
201202

202203
def cleanup():
203204
for obj in objects_to_cleanup:
204-
obj.stop()
205-
obj.cleanup()
205+
try:
206+
obj.stop()
207+
obj.cleanup()
208+
except Exception as e:
209+
logging.error(e)
206210

207211
objects_for_final_cleanup = []
208212

@@ -329,9 +333,10 @@ def run_single_test(loops: int, speed: MbpsSpeed) -> tuple[bool, StatisticalRepo
329333
try:
330334
# run test
331335
result, report = run_single_test(
332-
max(1, int(speed_current / scenario.default.mbps)),
336+
max(1, int(math.ceil(speed_current / scenario.default.mbps))),
333337
MbpsSpeed(speed_current),
334338
)
339+
report.print_results()
335340
except Exception as e:
336341
result = False
337342
report = None
@@ -354,10 +359,13 @@ def run_single_test(loops: int, speed: MbpsSpeed) -> tuple[bool, StatisticalRepo
354359
- speed_current % scenario.test.mbps_accuracy
355360
)
356361

357-
# cleanup devices
358-
finalizer_download_logs()
359-
if request.config.getoption("archive_test_data") == "always":
360-
shutil.move(tmp_dir, os.path.join(current_log_dir, "data"))
362+
try:
363+
# cleanup devices
364+
finalizer_download_logs()
365+
if request.config.getoption("archive_test_data") == "always":
366+
shutil.move(tmp_dir, os.path.join(current_log_dir, "data"))
367+
except Exception as e:
368+
logging.error(e)
361369
cleanup()
362370
objects_to_cleanup = []
363371
gc.collect()

0 commit comments

Comments
 (0)