Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/framework/microvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@ def spawn(
# and leave 0.2 delay between them.
if "no-api" not in self.jailer.extra_args:
self._wait_create()
if "config-file" in self.jailer.extra_args and self.iface:
self.wait_for_up()
if self.log_file and log_level in ("Trace", "Debug", "Info"):
self.check_log_message("Running Firecracker")

Expand Down Expand Up @@ -876,6 +878,9 @@ def start(self):
# Check that the VM has started
assert self.state == "Running"

if self.iface:
self.wait_for_up()

def pause(self):
"""Pauses the microVM"""
self.api.vm.patch(state="Paused")
Expand Down Expand Up @@ -956,6 +961,9 @@ def restore_from_snapshot(
enable_diff_snapshots=snapshot.is_diff,
resume_vm=resume,
)
# This is not a "wait for boot", but rather a "VM still works after restoration"
if snapshot.net_ifaces and resume:
self.wait_for_up()
return jailed_snapshot

def enable_entropy_device(self):
Expand Down
2 changes: 0 additions & 2 deletions tests/integration_tests/functional/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def test_drive_io_engine(uvm_plain):
test_microvm.api.drive.put(**kwargs)

test_microvm.start()
test_microvm.wait_for_up()

assert test_microvm.api.vm_config.get().json()["drives"][0]["io_engine"] == "Sync"

Expand Down Expand Up @@ -1166,7 +1165,6 @@ def test_get_full_config_after_restoring_snapshot(microvm_factory, uvm_nano):
}
]

uvm_nano.wait_for_up()
snapshot = uvm_nano.snapshot_full()
uvm2 = microvm_factory.build()
uvm2.spawn()
Expand Down
11 changes: 0 additions & 11 deletions tests/integration_tests/functional/test_balloon.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def test_rss_memory_lower(uvm_plain_any):

# Start the microvm.
test_microvm.start()
test_microvm.wait_for_up()

_test_rss_memory_lower(test_microvm)

Expand All @@ -151,7 +150,6 @@ def test_inflate_reduces_free(uvm_plain_any):

# Start the microvm
test_microvm.start()
test_microvm.wait_for_up()
firecracker_pid = test_microvm.firecracker_pid

# Get the free memory before ballooning.
Expand Down Expand Up @@ -198,7 +196,6 @@ def test_deflate_on_oom(uvm_plain_any, deflate_on_oom):

# Start the microvm.
test_microvm.start()
test_microvm.wait_for_up()
firecracker_pid = test_microvm.firecracker_pid

# We get an initial reading of the RSS, then calculate the amount
Expand Down Expand Up @@ -243,7 +240,6 @@ def test_reinflate_balloon(uvm_plain_any):

# Start the microvm.
test_microvm.start()
test_microvm.wait_for_up()
firecracker_pid = test_microvm.firecracker_pid

# First inflate the balloon to free up the uncertain amount of memory
Expand Down Expand Up @@ -303,7 +299,6 @@ def test_size_reduction(uvm_plain_any):

# Start the microvm.
test_microvm.start()
test_microvm.wait_for_up()
firecracker_pid = test_microvm.firecracker_pid

# Check memory usage.
Expand Down Expand Up @@ -348,7 +343,6 @@ def test_stats(uvm_plain_any):

# Start the microvm.
test_microvm.start()
test_microvm.wait_for_up()
firecracker_pid = test_microvm.firecracker_pid

# Give Firecracker enough time to poll the stats at least once post-boot
Expand Down Expand Up @@ -417,7 +411,6 @@ def test_stats_update(uvm_plain_any):

# Start the microvm.
test_microvm.start()
test_microvm.wait_for_up()
firecracker_pid = test_microvm.firecracker_pid

# Dirty 30MB of pages.
Expand Down Expand Up @@ -469,7 +462,6 @@ def test_balloon_snapshot(microvm_factory, guest_kernel, rootfs):
)

vm.start()
vm.wait_for_up()

# Dirty 60MB of pages.
make_guest_dirty_memory(vm.ssh, amount_mib=60)
Expand All @@ -496,8 +488,6 @@ def test_balloon_snapshot(microvm_factory, guest_kernel, rootfs):
microvm.spawn()
microvm.restore_from_snapshot(snapshot, resume=True)

microvm.wait_for_up()

# Get the firecracker from snapshot pid, and open an ssh connection.
firecracker_pid = microvm.firecracker_pid

Expand Down Expand Up @@ -549,7 +539,6 @@ def test_memory_scrub(microvm_factory, guest_kernel, rootfs):
)

microvm.start()
microvm.wait_for_up()

# Dirty 60MB of pages.
make_guest_dirty_memory(microvm.ssh, amount_mib=60)
Expand Down
3 changes: 0 additions & 3 deletions tests/integration_tests/functional/test_cmd_line_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def test_config_start_no_api_exit(uvm_plain, vm_config_file):
test_microvm.jailer.extra_args.update({"no-api": None})

test_microvm.spawn() # Start Firecracker and MicroVM
test_microvm.wait_for_up()
test_microvm.ssh.run("reboot") # Exit

test_microvm.mark_killed() # waits for process to terminate
Expand Down Expand Up @@ -419,7 +418,6 @@ def test_config_start_and_mmds_with_api(uvm_plain, vm_config_file):

# Network namespace has already been created.
test_microvm.spawn()
test_microvm.wait_for_up()

data_store = {
"latest": {
Expand Down Expand Up @@ -478,7 +476,6 @@ def test_with_config_and_metadata_no_api(uvm_plain, vm_config_file, metadata_fil
_configure_network_interface(test_microvm)
test_microvm.jailer.extra_args.update({"no-api": None})
test_microvm.spawn()
test_microvm.wait_for_up()

# Get MMDS version and IPv4 address configured from the file.
version, ipv4_address = _get_optional_fields_from_file(vm_config_file)
Expand Down
1 change: 0 additions & 1 deletion tests/integration_tests/functional/test_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def launch1():
microvm.basic_config(vcpu_count=1, mem_size_mib=128)
microvm.add_net_iface()
microvm.start()
microvm.wait_for_up()

with ThreadPoolExecutor(max_workers=NO_OF_MICROVMS) as tpe:
for _ in range(NO_OF_MICROVMS):
Expand Down
1 change: 0 additions & 1 deletion tests/integration_tests/functional/test_cpu_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,6 @@ def test_cpu_template(uvm_plain_any, cpu_template, microvm_factory):
restored_vm = microvm_factory.build()
restored_vm.spawn()
restored_vm.restore_from_snapshot(snapshot, resume=True)
restored_vm.wait_for_up()
check_masked_features(restored_vm, cpu_template)
check_enabled_features(restored_vm, cpu_template)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def test_cpu_features_with_static_template(
restored_vm = microvm_factory.build()
restored_vm.spawn()
restored_vm.restore_from_snapshot(snapshot, resume=True)
restored_vm.wait_for_up()
_check_cpu_features_arm(restored_vm, guest_kv, "v1n1")


Expand Down Expand Up @@ -143,5 +142,4 @@ def test_cpu_features_with_custom_template(
restored_vm = microvm_factory.build()
restored_vm.spawn()
restored_vm.restore_from_snapshot(snapshot, resume=True)
restored_vm.wait_for_up()
_check_cpu_features_arm(restored_vm, guest_kv, custom_cpu_template["name"])
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def test_dirty_pages_after_full_snapshot(uvm_plain):
uvm.basic_config(mem_size_mib=vm_mem_size, track_dirty_pages=True)
uvm.add_net_iface()
uvm.start()
uvm.wait_for_up()

snap_full = uvm.snapshot_full(vmstate_path="vmstate_full", mem_path="mem_full")
snap_diff = uvm.snapshot_diff(vmstate_path="vmstate_diff", mem_path="mem_diff")
Expand Down
5 changes: 0 additions & 5 deletions tests/integration_tests/functional/test_drive_vhost_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def test_vhost_user_block(microvm_factory, guest_kernel, rootfs_ubuntu_22):
"vhost_user_block", 1, aggr_supported=False
)
vm.start()
vm.wait_for_up()

# Now check that vhost-user-block with rw is last.
# 1-0 means line 1, column 0.
Expand Down Expand Up @@ -91,7 +90,6 @@ def test_vhost_user_block_read_write(microvm_factory, guest_kernel, rootfs_ubunt
vm.add_vhost_user_drive("rootfs", rootfs_rw, is_root_device=True)
vm.add_net_iface()
vm.start()
vm.wait_for_up()

# Now check that vhost-user-block with rw is last.
# 1-0 means line 1, column 0.
Expand Down Expand Up @@ -120,7 +118,6 @@ def test_vhost_user_block_disconnect(microvm_factory, guest_kernel, rootfs_ubunt
)
vm.add_net_iface()
vm.start()
vm.wait_for_up()

# Killing the backend
vm.disks_vhost_user["rootfs"].kill()
Expand Down Expand Up @@ -231,7 +228,6 @@ def test_partuuid_boot(
)
vm.add_net_iface()
vm.start()
vm.wait_for_up()

# Now check that vhost-user-block with rw is last.
# 1-0 means line 1, column 0.
Expand Down Expand Up @@ -275,7 +271,6 @@ def test_partuuid_update(microvm_factory, guest_kernel, rootfs_ubuntu_22):
"vhost_user_block", 1, aggr_supported=False
)
vm.start()
vm.wait_for_up()

# Now check that vhost-user-block with rw is last.
# 1-0 means line 1, column 0.
Expand Down
1 change: 0 additions & 1 deletion tests/integration_tests/functional/test_mmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def _validate_mmds_snapshot(
microvm = microvm_factory.build(**kwargs)
microvm.spawn()
microvm.restore_from_snapshot(snapshot, resume=True)
microvm.wait_for_up()

ssh_connection = microvm.ssh

Expand Down
3 changes: 0 additions & 3 deletions tests/integration_tests/functional/test_pause_resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def test_pause_resume(uvm_nano):
microvm.api.vm.patch(state="Resumed")

microvm.start()
microvm.wait_for_up()

# Pausing the microVM after it's been started is successful.
microvm.api.vm.patch(state="Paused")
Expand Down Expand Up @@ -69,14 +68,12 @@ def test_pause_resume(uvm_nano):
microvm.api.vm.patch(state="Resumed")

# Verify guest is active again.
microvm.wait_for_up()

# Resuming the microVM when it is already `Resumed` is allowed
# (microVM remains in the running state).
microvm.api.vm.patch(state="Resumed")

# Verify guest is still active.
microvm.wait_for_up()

microvm.kill()

Expand Down
1 change: 0 additions & 1 deletion tests/integration_tests/functional/test_rng.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def test_rng_snapshot(uvm_with_rng, microvm_factory):
new_vm = microvm_factory.build()
new_vm.spawn()
new_vm.restore_from_snapshot(snapshot, resume=True)
new_vm.wait_for_up()
assert_virtio_rng_is_current_hwrng_device(new_vm.ssh)
check_entropy(new_vm.ssh)

Expand Down
1 change: 0 additions & 1 deletion tests/integration_tests/functional/test_serial_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,5 @@ def test_no_serial_fd_error_when_daemonized(uvm_plain):
mem_size_mib=512,
)
test_microvm.start()
test_microvm.wait_for_up()

assert REGISTER_FAILED_WARNING not in test_microvm.log_data
14 changes: 0 additions & 14 deletions tests/integration_tests/functional/test_snapshot_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ def test_resume_after_restoration(uvm_nano, microvm_factory):
vm = uvm_nano
vm.add_net_iface()
vm.start()
vm.wait_for_up()

snapshot = vm.snapshot_full()

restored_vm = microvm_factory.build()
restored_vm.spawn()
restored_vm.restore_from_snapshot(snapshot)
restored_vm.resume()
restored_vm.wait_for_up()


def test_resume_at_restoration(uvm_nano, microvm_factory):
Expand All @@ -79,14 +77,12 @@ def test_resume_at_restoration(uvm_nano, microvm_factory):
vm = uvm_nano
vm.add_net_iface()
vm.start()
vm.wait_for_up()

snapshot = vm.snapshot_full()

restored_vm = microvm_factory.build()
restored_vm.spawn()
restored_vm.restore_from_snapshot(snapshot, resume=True)
restored_vm.wait_for_up()


def test_snapshot_current_version(uvm_nano):
Expand Down Expand Up @@ -150,7 +146,6 @@ def test_5_snapshots(
vm.add_net_iface()
vm.api.vsock.put(vsock_id="vsock0", guest_cid=3, uds_path=VSOCK_UDS_PATH)
vm.start()
vm.wait_for_up()

vm_blob_path = "/tmp/vsock/test.blob"
# Generate a random data file for vsock.
Expand Down Expand Up @@ -220,7 +215,6 @@ def test_patch_drive_snapshot(uvm_nano, microvm_factory):
scratch_disk1 = drive_tools.FilesystemFile(scratch_path1, size=128)
basevm.add_drive("scratch", scratch_disk1.path)
basevm.start()
basevm.wait_for_up()

# Update drive to have another backing file, double in size.
new_file_size_mb = 2 * int(scratch_disk1.size() / (1024 * 1024))
Expand All @@ -238,7 +232,6 @@ def test_patch_drive_snapshot(uvm_nano, microvm_factory):
vm = microvm_factory.build()
vm.spawn()
vm.restore_from_snapshot(snapshot, resume=True)
vm.wait_for_up()

# Attempt to connect to resumed microvm and verify the new microVM has the
# right scratch drive.
Expand Down Expand Up @@ -299,7 +292,6 @@ def test_cmp_full_and_first_diff_mem(microvm_factory, guest_kernel, rootfs):
)
vm.add_net_iface()
vm.start()
vm.wait_for_up()

logger.info("Create diff snapshot.")
# Create diff snapshot.
Expand All @@ -322,7 +314,6 @@ def test_negative_postload_api(uvm_plain, microvm_factory):
basevm.basic_config(track_dirty_pages=True)
basevm.add_net_iface()
basevm.start()
basevm.wait_for_up()

# Create base snapshot.
snapshot = basevm.snapshot_diff()
Expand Down Expand Up @@ -474,7 +465,6 @@ def test_diff_snapshot_overlay(guest_kernel, rootfs, microvm_factory):
basevm.basic_config(track_dirty_pages=True)
basevm.add_net_iface()
basevm.start()
basevm.wait_for_up()

# The first snapshot taken will always contain all memory (even if its specified as "diff").
# We use a diff snapshot here, as taking a full snapshot does not clear the dirty page tracking,
Expand Down Expand Up @@ -502,7 +492,6 @@ def test_diff_snapshot_overlay(guest_kernel, rootfs, microvm_factory):
new_vm.restore_from_snapshot(merged_snapshot, resume=True)

# Check that the restored VM works
new_vm.wait_for_up()


def test_snapshot_overwrite_self(guest_kernel, rootfs, microvm_factory):
Expand All @@ -518,7 +507,6 @@ def test_snapshot_overwrite_self(guest_kernel, rootfs, microvm_factory):
base_vm.basic_config()
base_vm.add_net_iface()
base_vm.start()
base_vm.wait_for_up()

snapshot = base_vm.snapshot_full()
base_vm.kill()
Expand All @@ -538,7 +526,6 @@ def test_snapshot_overwrite_self(guest_kernel, rootfs, microvm_factory):

# Check the overwriting the snapshot file from which this microvm was originally
# restored, with a new snapshot of this vm, does not break the VM
vm.wait_for_up()


@pytest.mark.parametrize("snapshot_type", [SnapshotType.DIFF, SnapshotType.FULL])
Expand All @@ -551,7 +538,6 @@ def test_vmgenid(guest_kernel_linux_6_1, rootfs, microvm_factory, snapshot_type)
base_vm.basic_config(track_dirty_pages=True)
base_vm.add_net_iface()
base_vm.start()
base_vm.wait_for_up()

snapshot = base_vm.make_snapshot(snapshot_type)
base_snapshot = snapshot
Expand Down
2 changes: 0 additions & 2 deletions tests/integration_tests/functional/test_snapshot_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def test_remove_regs(uvm_nano, microvm_factory):
vm = uvm_nano
vm.add_net_iface()
vm.start()
vm.wait_for_up()

snapshot = vm.snapshot_full()

Expand Down Expand Up @@ -72,4 +71,3 @@ def test_remove_regs(uvm_nano, microvm_factory):
new_vm = microvm_factory.build()
new_vm.spawn()
new_vm.restore_from_snapshot(snapshot, resume=True)
new_vm.wait_for_up()
Loading
Loading