Skip to content

Commit bc7aa2f

Browse files
committed
refactor(test): capture screen log via file copy
Copy the screen log file (which contains firecracker's stdout/guest dmesg if non-daemonized / no log file specified) to the test_results directory, to be included in artifacts, instead of explicitly reading one file and subsequently writing another file in Python code. Signed-off-by: Patrick Roy <[email protected]>
1 parent 3a6b518 commit bc7aa2f

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ def microvm_factory(request, record_property, results_dir, netns_factory):
384384
utils.run_cmd(["dmesg", "-dPx"]).stdout
385385
)
386386
shutil.copy(f"/firecracker/build/img/{platform.machine()}/id_rsa", uvm_data)
387+
if Path(uvm.screen_log).exists():
388+
shutil.copy(uvm.screen_log, uvm_data)
387389

388390
uvm_root = Path(uvm.chroot())
389391
for item in os.listdir(uvm_root):
@@ -392,9 +394,6 @@ def microvm_factory(request, record_property, results_dir, netns_factory):
392394
continue
393395
dst = uvm_data / item
394396
shutil.copy(src, dst)
395-
console_data = uvm.console_data
396-
if console_data:
397-
uvm_data.joinpath("guest-console.log").write_text(console_data)
398397

399398
uvm_factory.kill()
400399

tests/framework/microvm.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,6 @@ def log_data(self):
463463
return ""
464464
return self.log_file.read_text()
465465

466-
@property
467-
def console_data(self):
468-
"""Return the output of microVM's console"""
469-
if self.screen_log is None:
470-
return None
471-
file = Path(self.screen_log)
472-
if not file.exists():
473-
return None
474-
return file.read_text(encoding="utf-8")
475-
476466
@property
477467
def state(self):
478468
"""Get the InstanceInfo property and return the state field."""

0 commit comments

Comments
 (0)