Skip to content

Commit

Permalink
test: integ test for being able to resnapshot dirty pages ater failure
Browse files Browse the repository at this point in the history
After having a failure during snapshot we're trying to do it again and
expect all the dirty pages to be snapshotted on the second attempt if it
succeeds.

Signed-off-by: Roman Kovtyukh <HelloDearGrandma@gmail.com>
Co-authored-by: Pablo Barbáchano <pablob@amazon.com>
  • Loading branch information
pb8o authored and Grandmother committed Jan 19, 2024
1 parent 74fd6b0 commit 97ad1c8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
@@ -0,0 +1,45 @@
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""Test that the no dirty pages lost in case of error during snapshot creation."""

import subprocess
import time
from pathlib import Path


def test_not_loosing_dirty_pages_on_snapshot_failure(uvm_plain, microvm_factory):
"""
Test that in case of error during snapshot creation no dirty pages were lost.
"""
vm_mem_size = 128
uvm = uvm_plain
uvm.spawn()
uvm.basic_config(mem_size_mib=vm_mem_size, track_dirty_pages=True)
uvm.add_net_iface()
uvm.start()
uvm.ssh.run("true")

chroot = Path(uvm.chroot())

# Create a large file, so we run out of space (ENOSPC) during the snapshot
# Assumes a Docker /srv tmpfs of 1G, derived by trial and error
fudge = chroot / "fudge"
subprocess.check_call(f"fallocate -l 550M {fudge}", shell=True)

try:
uvm.snapshot_diff()
except RuntimeError:
msg = "No space left on device"
uvm.check_log_message(msg)
else:
assert False, "This should fail"

fudge.unlink()

# Now there is enough space for it to work
snap2 = uvm.snapshot_diff()

vm2 = microvm_factory.build()
vm2.spawn()
vm2.restore_from_snapshot(snap2, resume=True)
vm2.ssh.run("true")
2 changes: 1 addition & 1 deletion tools/devtool
Expand Up @@ -309,7 +309,7 @@ run_devctr() {
--rm \
--volume /dev:/dev \
--volume "$FC_ROOT_DIR:$CTR_FC_ROOT_DIR:z" \
--tmpfs /srv:exec,dev,size=32G \
--tmpfs /srv:exec,dev,size=1G \
-v /boot:/boot \
--env PYTHONDONTWRITEBYTECODE=1 \
"$DEVCTR_IMAGE" "${ctr_args[@]}"
Expand Down

0 comments on commit 97ad1c8

Please sign in to comment.