Skip to content

Commit e779c54

Browse files
dianpopaJonathanWoollett-Light
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 <dpopa@amazon.com>
1 parent 01eba51 commit e779c54

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tests/framework/microvm.py

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

942-
RX_TIMEOUT_S = 5
942+
RX_TIMEOUT_S = 20
943943

944944
def __init__(self, vm):
945945
"""Initialize a new Serial object."""
@@ -988,6 +988,7 @@ def rx(self, token="\n"):
988988
if rx_str.endswith(token):
989989
break
990990
if (time.time() - start) >= self.RX_TIMEOUT_S:
991+
self._vm.kill()
991992
assert False
992993

993994
return rx_str

tests/integration_tests/functional/test_serial_io.py

Lines changed: 10 additions & 7 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,19 +57,18 @@ 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+
if PLATFORM == "x86_64":
7172
serial.rx(token="login: ")
7273
serial.tx("root")
7374
serial.rx("Password: ")
@@ -76,15 +77,17 @@ def test_serial_after_snapshot(bin_cloner_path):
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, ssh_key, SnapshotType.FULL)
80+
81+
# Create snapshot.
82+
snapshot = snapshot_builder.create(
83+
[root_disk.local_path()], ssh_key, SnapshotType.FULL
84+
)
8285
# Kill base microVM.
8386
microvm.kill()
8487

8588
# Load microVM clone from snapshot.
8689
test_microvm, _ = vm_builder.build_from_snapshot(
87-
snapshot, resume=True, diff_snapshots=False, daemonize=False
90+
snapshot, resume=True, daemonize=False
8891
)
8992
serial = Serial(test_microvm)
9093
serial.open()

0 commit comments

Comments
 (0)