Skip to content

Commit 79a0ffc

Browse files
committed
test: enable serial console in integration tests
If SSH to guest is failing, we don't really get much useful in terms of logs in our ci artifacts. Enable serial console so that we get guest dmesg always. Disable pylint's "too-many-statements" lint, because it started firing in microvm.spawn() Signed-off-by: Patrick Roy <[email protected]>
1 parent 4737442 commit 79a0ffc

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

tests/framework/microvm.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ def __init__(
254254

255255
self.api = None
256256
self.log_file = None
257+
self.serial_log_file = None
257258
self.metrics_file = None
258259
self._spawned = False
259260
self._killed = False
@@ -618,6 +619,7 @@ def add_pre_cmd(self, pre_cmd):
618619
def spawn(
619620
self,
620621
log_file="fc.log",
622+
serial_log_file="serial.log",
621623
log_level="Debug",
622624
log_show_level=False,
623625
log_show_origin=False,
@@ -648,6 +650,12 @@ def spawn(
648650
if log_show_origin:
649651
self.jailer.extra_args["show-log-origin"] = None
650652

653+
if serial_log_file is not None:
654+
self.serial_log_file = Path(self.path) / serial_log_file
655+
self.serial_log_file.touch()
656+
self.create_jailed_resource(self.serial_log_file)
657+
self.jailer.extra_args.update({"serial-out-path": serial_log_file})
658+
651659
if metrics_path is not None:
652660
self.metrics_file = Path(self.path) / metrics_path
653661
self.metrics_file.touch()
@@ -789,10 +797,9 @@ def basic_config(
789797
The function checks the response status code and asserts that
790798
the response is within the interval [200, 300).
791799
792-
If boot_args is None, the default boot_args in Firecracker is
793-
reboot=k panic=1 pci=off nomodule 8250.nr_uarts=0
794-
i8042.noaux i8042.nomux i8042.nopnp i8042.dumbkbd
795-
800+
If boot_args is None, the default boot_args used in tests is
801+
reboot=k panic=1 pci=off nomodule console=ttyS0
802+
which differs from Firecracker's default only in the enabling of the serial console.
796803
Reference: file:../../src/vmm/src/vmm_config/boot_source.rs::DEFAULT_KERNEL_CMDLINE
797804
"""
798805
self.api.machine_config.put(
@@ -816,6 +823,8 @@ def basic_config(
816823

817824
if boot_args is not None:
818825
self.boot_args = boot_args
826+
else:
827+
self.boot_args = "reboot=k panic=1 pci=off nomodule console=ttyS0"
819828
boot_source_args = {
820829
"kernel_image_path": self.create_jailed_resource(self.kernel_file),
821830
"boot_args": self.boot_args,
@@ -1301,13 +1310,13 @@ def open(self):
13011310
return
13021311

13031312
attempt = 0
1304-
while not Path(self._vm.screen_log).exists() and attempt < 5:
1313+
while not Path(self._vm.serial_log_file).exists() and attempt < 5:
13051314
time.sleep(0.2)
13061315
attempt += 1
13071316

1308-
screen_log_fd = os.open(self._vm.screen_log, os.O_RDONLY)
1317+
serial_log_fd = os.open(self._vm.serial_log_file, os.O_RDONLY)
13091318
self._poller = select.poll()
1310-
self._poller.register(screen_log_fd, select.POLLIN | select.POLLHUP)
1319+
self._poller.register(serial_log_fd, select.POLLIN | select.POLLHUP)
13111320

13121321
def tx(self, input_string, end="\n"):
13131322
# pylint: disable=invalid-name

tests/integration_tests/functional/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ def test_get_full_config_after_restoring_snapshot(microvm_factory, uvm_nano):
11361136
expected_cfg["boot-source"] = {
11371137
"kernel_image_path": uvm_nano.get_jailed_resource(uvm_nano.kernel_file),
11381138
"initrd_path": None,
1139-
"boot_args": None,
1139+
"boot_args": "reboot=k panic=1 pci=off nomodule console=ttyS0",
11401140
}
11411141

11421142
# no ipv4_address or imds_compat specified during PUT /mmds/config so we expect the default

tests/integration_tests/functional/test_cmd_line_parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_describe_snapshot_all_versions(
2929
jailer_binary_path=firecracker_release.jailer,
3030
)
3131
# FIXME: Once only FC versions >= 1.12 are supported, drop log_level="warn"
32-
vm.spawn(log_level="warn")
32+
vm.spawn(log_level="warn", serial_log_file=None)
3333
vm.basic_config(track_dirty_pages=True)
3434
vm.start()
3535
snapshot = vm.snapshot_diff()

tests/integration_tests/functional/test_max_devices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# On aarch64, IRQs are available from 32 to 127. We always use one IRQ each for
1313
# the VMGenID and RTC devices, so the maximum number of devices supported
1414
# at the same time is 94.
15-
MAX_DEVICES_ATTACHED = {"x86_64": 18, "aarch64": 94}.get(platform.machine())
15+
MAX_DEVICES_ATTACHED = {"x86_64": 18, "aarch64": 93}.get(platform.machine())
1616

1717

1818
def test_attach_maximum_devices(microvm_factory, guest_kernel, rootfs):

tests/integration_tests/functional/test_serial_io.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,12 @@ def test_serial_block(uvm_plain_any):
173173
"""
174174
test_microvm = uvm_plain_any
175175
test_microvm.help.enable_console()
176-
test_microvm.spawn()
176+
test_microvm.spawn(serial_log_file=None)
177177
# Set up the microVM with 1 vCPU so we make sure the vCPU thread
178178
# responsible for the SSH connection will also run the serial.
179179
test_microvm.basic_config(
180180
vcpu_count=1,
181181
mem_size_mib=512,
182-
boot_args="console=ttyS0 reboot=k panic=1 pci=off",
183182
)
184183
test_microvm.add_net_iface()
185184
test_microvm.start()

tests/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ disable = [
5656
"too-many-positional-arguments",
5757
"too-few-public-methods",
5858
"too-many-branches",
59+
"too-many-statements",
5960
]

0 commit comments

Comments
 (0)