Skip to content

Commit a264f75

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 b1291e6 commit a264f75

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

tests/framework/microvm.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ def __init__(
259259

260260
self.api = None
261261
self.log_file = None
262+
self.serial_log_file = None
262263
self.metrics_file = None
263264
self._spawned = False
264265
self._killed = False
@@ -624,6 +625,7 @@ def add_pre_cmd(self, pre_cmd):
624625
def spawn(
625626
self,
626627
log_file="fc.log",
628+
serial_log_file="serial.log",
627629
log_level="Debug",
628630
log_show_level=False,
629631
log_show_origin=False,
@@ -654,6 +656,12 @@ def spawn(
654656
if log_show_origin:
655657
self.jailer.extra_args["show-log-origin"] = None
656658

659+
if serial_log_file is not None:
660+
self.serial_log_file = Path(self.path) / serial_log_file
661+
self.serial_log_file.touch()
662+
self.create_jailed_resource(self.serial_log_file)
663+
self.jailer.extra_args.update({"serial-out-path": serial_log_file})
664+
657665
if metrics_path is not None:
658666
self.metrics_file = Path(self.path) / metrics_path
659667
self.metrics_file.touch()
@@ -795,12 +803,9 @@ def basic_config(
795803
The function checks the response status code and asserts that
796804
the response is within the interval [200, 300).
797805
798-
If boot_args is None, the default boot_args in Firecracker is
799-
reboot=k panic=1 nomodule 8250.nr_uarts=0 i8042.noaux i8042.nomux
800-
i8042.nopnp i8042.dumbkbd swiotlb=noforce
801-
802-
if PCI is disabled, Firecracker also passes to the guest pci=off
803-
806+
If boot_args is None, the default boot_args used in tests is
807+
reboot=k panic=1 nomodule swiotlb=noforce console=ttyS0 [pci=off]
808+
which differs from Firecracker's default only in the enabling of the serial console.
804809
Reference: file:../../src/vmm/src/vmm_config/boot_source.rs::DEFAULT_KERNEL_CMDLINE
805810
"""
806811
self.api.machine_config.put(
@@ -824,6 +829,10 @@ def basic_config(
824829

825830
if boot_args is not None:
826831
self.boot_args = boot_args
832+
else:
833+
self.boot_args = "reboot=k panic=1 nomodule swiotlb=noforce console=ttyS0"
834+
if not self.pci_enabled:
835+
self.boot_args += " pci=off"
827836
boot_source_args = {
828837
"kernel_image_path": self.create_jailed_resource(self.kernel_file),
829838
"boot_args": self.boot_args,
@@ -1309,13 +1318,13 @@ def open(self):
13091318
return
13101319

13111320
attempt = 0
1312-
while not Path(self._vm.screen_log).exists() and attempt < 5:
1321+
while not Path(self._vm.serial_log_file).exists() and attempt < 5:
13131322
time.sleep(0.2)
13141323
attempt += 1
13151324

1316-
screen_log_fd = os.open(self._vm.screen_log, os.O_RDONLY)
1325+
serial_log_fd = os.open(self._vm.serial_log_file, os.O_RDONLY)
13171326
self._poller = select.poll()
1318-
self._poller.register(screen_log_fd, select.POLLIN | select.POLLHUP)
1327+
self._poller.register(serial_log_fd, select.POLLIN | select.POLLHUP)
13191328

13201329
def tx(self, input_string, end="\n"):
13211330
# 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def max_devices(uvm):
1818
match platform.machine():
1919
case "aarch64":
2020
# On aarch64, IRQs are available from 32 to 127. We always use one IRQ each for
21-
# the VMGenID and RTC devices, so the maximum number of devices supported
22-
# at the same time is 94.
23-
return 94
21+
# the VMGenID, RTC and serial devices, so the maximum number of devices supported
22+
# at the same time is 93.
23+
return 93
2424
case "x86_64":
2525
# IRQs are available from 5 to 23. We always use one IRQ for VMGenID device, so
2626
# the maximum number of devices supported at the same time is 18.

tests/integration_tests/functional/test_serial_io.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,12 @@ def test_serial_block(uvm_plain_any):
174174
"""
175175
test_microvm = uvm_plain_any
176176
test_microvm.help.enable_console()
177-
test_microvm.spawn()
177+
test_microvm.spawn(serial_log_file=None)
178178
# Set up the microVM with 1 vCPU so we make sure the vCPU thread
179179
# responsible for the SSH connection will also run the serial.
180180
test_microvm.basic_config(
181181
vcpu_count=1,
182182
mem_size_mib=512,
183-
boot_args="console=ttyS0 reboot=k panic=1 swiotlb=noforce",
184183
)
185184
test_microvm.add_net_iface()
186185
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)