Skip to content

Commit 0858ee4

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. Since serial console is enabled by default now, this means we can stop explicitly passing modified bootargs in a bunch of tests now. Disable it for the tests that interact with the serial console via stdin/stdout (here we are not daemonizing, so we are capturing serial output anyway). Disable pylint's "too-many-statements" lint, because it started firing in microvm.spawn() Signed-off-by: Patrick Roy <[email protected]>
1 parent bc7aa2f commit 0858ee4

File tree

8 files changed

+32
-25
lines changed

8 files changed

+32
-25
lines changed

tests/framework/microvm.py

Lines changed: 17 additions & 8 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,
@@ -1313,9 +1322,9 @@ def open(self):
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.screen_log, 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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,8 +1136,10 @@ 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 nomodule swiotlb=noforce console=ttyS0",
11401140
}
1141+
if not uvm_nano.pci_enabled:
1142+
expected_cfg["boot-source"]["boot_args"] += " pci=off"
11411143

11421144
# no ipv4_address or imds_compat specified during PUT /mmds/config so we expect the default
11431145
expected_cfg["mmds-config"] = {

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_kernel_cmdline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_init_params(uvm_plain):
1414
"""
1515
vm = uvm_plain
1616
vm.help.enable_console()
17-
vm.spawn()
17+
vm.spawn(serial_log_file=None)
1818
vm.memory_monitor = None
1919

2020
# We will override the init with /bin/cat so that we try to read the

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: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ def test_serial_after_snapshot(uvm_plain, microvm_factory):
5151
"""
5252
microvm = uvm_plain
5353
microvm.help.enable_console()
54-
microvm.spawn()
54+
microvm.spawn(serial_log_file=None)
5555
microvm.basic_config(
5656
vcpu_count=2,
5757
mem_size_mib=256,
58-
boot_args="console=ttyS0 reboot=k panic=1 swiotlb=noforce",
5958
)
6059
serial = Serial(microvm)
6160
serial.open()
@@ -72,7 +71,7 @@ def test_serial_after_snapshot(uvm_plain, microvm_factory):
7271
# Load microVM clone from snapshot.
7372
vm = microvm_factory.build()
7473
vm.help.enable_console()
75-
vm.spawn()
74+
vm.spawn(serial_log_file=None)
7675
vm.restore_from_snapshot(snapshot, resume=True)
7776
serial = Serial(vm)
7877
serial.open()
@@ -92,16 +91,14 @@ def test_serial_console_login(uvm_plain_any):
9291
"""
9392
microvm = uvm_plain_any
9493
microvm.help.enable_console()
95-
microvm.spawn()
94+
microvm.spawn(serial_log_file=None)
9695

9796
# We don't need to monitor the memory for this test because we are
9897
# just rebooting and the process dies before pmap gets the RSS.
9998
microvm.memory_monitor = None
10099

101100
# Set up the microVM with 1 vCPU and a serial console.
102-
microvm.basic_config(
103-
vcpu_count=1, boot_args="console=ttyS0 reboot=k panic=1 swiotlb=noforce"
104-
)
101+
microvm.basic_config(vcpu_count=1)
105102

106103
microvm.start()
107104

@@ -146,7 +143,6 @@ def test_serial_dos(uvm_plain_any):
146143
# Set up the microVM with 1 vCPU and a serial console.
147144
microvm.basic_config(
148145
vcpu_count=1,
149-
boot_args="console=ttyS0 reboot=k panic=1 swiotlb=noforce",
150146
)
151147
microvm.add_net_iface()
152148
microvm.start()
@@ -174,13 +170,12 @@ def test_serial_block(uvm_plain_any):
174170
"""
175171
test_microvm = uvm_plain_any
176172
test_microvm.help.enable_console()
177-
test_microvm.spawn()
173+
test_microvm.spawn(serial_log_file=None)
178174
# Set up the microVM with 1 vCPU so we make sure the vCPU thread
179175
# responsible for the SSH connection will also run the serial.
180176
test_microvm.basic_config(
181177
vcpu_count=1,
182178
mem_size_mib=512,
183-
boot_args="console=ttyS0 reboot=k panic=1 swiotlb=noforce",
184179
)
185180
test_microvm.add_net_iface()
186181
test_microvm.start()

tests/integration_tests/performance/test_initrd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_microvm_initrd_with_serial(uvm_with_initrd, huge_pages):
2929
"""
3030
vm = uvm_with_initrd
3131
vm.help.enable_console()
32-
vm.spawn()
32+
vm.spawn(serial_log_file=None)
3333
vm.memory_monitor = None
3434

3535
vm.basic_config(

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)