Skip to content

Commit 6cde27c

Browse files
dianpopaandreitraistaru
authored andcommitted
fix intermittent serial_after_snapshot
The test started failling after latest AMI update on 4.14. Seems that reading from the screen log file the output of the microVM became slower. Signed-off-by: Diana Popa <[email protected]> (cherry picked from commit e779c54)
1 parent fae411b commit 6cde27c

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

tests/framework/microvm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ def __del__(self):
899899
class Serial:
900900
"""Class for serial console communication with a Microvm."""
901901

902-
RX_TIMEOUT_S = 5
902+
RX_TIMEOUT_S = 20
903903

904904
def __init__(self, vm):
905905
"""Initialize a new Serial object."""
@@ -952,6 +952,7 @@ def rx(self, token="\n"):
952952
if rx_str.endswith(token):
953953
break
954954
if (time.time() - start) >= self.RX_TIMEOUT_S:
955+
self._vm.kill()
955956
assert False
956957

957958
return rx_str

tests/integration_tests/functional/test_serial_io.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import host_tools.logging as log_tools
1818
import host_tools.network as net_tools
1919

20+
PLATFORM = platform.machine()
21+
2022

2123
class WaitTerminal(TestState): # pylint: disable=too-few-public-methods
2224
"""Initial state when we wait for the login prompt."""
@@ -55,40 +57,38 @@ def test_serial_after_snapshot(bin_cloner_path):
5557
"""
5658
vm_builder = MicrovmBuilder(bin_cloner_path)
5759
vm_instance = vm_builder.build_vm_nano(
58-
diff_snapshots=False,
5960
daemonize=False,
6061
)
6162
microvm = vm_instance.vm
6263
root_disk = vm_instance.disks[0]
6364
ssh_key = vm_instance.ssh_key
6465

65-
microvm.start()
6666
serial = Serial(microvm)
6767
serial.open()
68+
microvm.start()
6869

6970
# Image used for tests on aarch64 has autologon
70-
if platform.machine() == "x86_64":
71-
serial.rx(token='login: ')
71+
if PLATFORM == "x86_64":
72+
serial.rx(token="login: ")
7273
serial.tx("root")
7374
serial.rx("Password: ")
7475
serial.tx("root")
7576
# Make sure that at the time we snapshot the vm, the user is logged in.
7677
serial.rx("#")
7778

7879
snapshot_builder = SnapshotBuilder(microvm)
79-
disks = [root_disk.local_path()]
80-
# Create diff snapshot.
81-
snapshot = snapshot_builder.create(disks,
82-
ssh_key,
83-
SnapshotType.FULL)
80+
81+
# Create snapshot.
82+
snapshot = snapshot_builder.create(
83+
[root_disk.local_path()], ssh_key, SnapshotType.FULL
84+
)
8485
# Kill base microVM.
8586
microvm.kill()
8687

8788
# Load microVM clone from snapshot.
88-
test_microvm, _ = vm_builder.build_from_snapshot(snapshot,
89-
resume=True,
90-
diff_snapshots=False,
91-
daemonize=False)
89+
test_microvm, _ = vm_builder.build_from_snapshot(
90+
snapshot, resume=True, daemonize=False
91+
)
9292
serial = Serial(test_microvm)
9393
serial.open()
9494
# We need to send a newline to signal the serial to flush

0 commit comments

Comments
 (0)