Skip to content

Commit

Permalink
Merge branch 'main' into clippy_cast_lossless
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Woollett-Light authored Nov 4, 2022
2 parents 0aec9ce + 3a26879 commit 5f46874
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 48 deletions.
19 changes: 19 additions & 0 deletions tests/framework/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,3 +765,22 @@ def start_screen_process(screen_log, session_name, binary_path, binary_params):
run_cmd(flush_cmd.format(session=session_name))

return screen_pid, binary_clone_pid


def guest_run_fio_iteration(ssh_connection, iteration):
"""Start FIO workload into a microVM."""
fio = """fio --filename=/dev/vda --direct=1 --rw=randread --bs=4k \
--ioengine=libaio --iodepth=16 --runtime=10 --numjobs=4 --time_based \
--group_reporting --name=iops-test-job --eta-newline=1 --readonly \
--output /tmp/fio{} > /dev/null &""".format(
iteration
)
exit_code, _, stderr = ssh_connection.execute_command(fio)
assert exit_code == 0, stderr.read()


def check_filesystem(ssh_connection, disk_fmt, disk):
"""Check for filesystem corruption inside a microVM."""
cmd = "fsck.{} -n {}".format(disk_fmt, disk)
exit_code, _, stderr = ssh_connection.execute_command(cmd)
assert exit_code == 0, stderr.read()
25 changes: 8 additions & 17 deletions tests/integration_tests/functional/test_snapshot_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
from framework.artifacts import ArtifactCollection, ArtifactSet
from framework.builder import MicrovmBuilder, SnapshotBuilder, SnapshotType
from framework.matrix import TestMatrix, TestContext
from framework.utils import wait_process_termination
from framework.utils import (
wait_process_termination,
check_filesystem,
)
from framework.utils_vsock import (
make_blob,
check_host_connections,
Expand All @@ -27,17 +30,6 @@
import host_tools.drive as drive_tools


def _guest_run_fio_iteration(ssh_connection, iteration):
fio = """fio --filename=/dev/vda --direct=1 --rw=randread --bs=4k \
--ioengine=libaio --iodepth=16 --runtime=10 --numjobs=4 --time_based \
--group_reporting --name=iops-test-job --eta-newline=1 --readonly \
--output /tmp/fio{} > /dev/null &""".format(
iteration
)
exit_code, _, _ = ssh_connection.execute_command(fio)
assert exit_code == 0


def _get_guest_drive_size(ssh_connection, guest_dev_name="/dev/vdb"):
# `lsblk` command outputs 2 lines to STDOUT:
# "SIZE" and the size of the device, in bytes.
Expand Down Expand Up @@ -112,9 +104,6 @@ def _test_seq_snapshots(context):
snapshot, resume=True, diff_snapshots=diff_snapshots
)

# Attempt to connect to resumed microvm.
ssh_connection = net_tools.SSHConnection(microvm.ssh_config)

# Test vsock guest-initiated connections.
path = os.path.join(
microvm.path, make_host_port_path(VSOCK_UDS_PATH, ECHO_SERVER_PORT)
Expand All @@ -124,8 +113,10 @@ def _test_seq_snapshots(context):
path = os.path.join(microvm.jailer.chroot_path(), VSOCK_UDS_PATH)
check_host_connections(microvm, path, blob_path, blob_hash)

# Start a new instance of fio on each iteration.
_guest_run_fio_iteration(ssh_connection, i)
ssh_connection = net_tools.SSHConnection(microvm.ssh_config)

# Check that the root device is not corrupted.
check_filesystem(ssh_connection, "ext4", "/dev/vda")

logger.info("Create snapshot #{}.".format(i + 1))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
from framework.builder import MicrovmBuilder
from framework.defs import FC_WORKSPACE_DIR, DEFAULT_TEST_SESSION_ROOT_PATH
from framework.utils_vsock import check_vsock_device
from framework.utils import generate_mmds_session_token, generate_mmds_get_request
from framework.utils import (
generate_mmds_session_token,
generate_mmds_get_request,
guest_run_fio_iteration,
)
from framework.utils_cpuid import CpuVendor, get_cpu_vendor
from integration_tests.functional.test_mmds import _populate_data_store
from integration_tests.functional.test_snapshot_basic import _guest_run_fio_iteration
from integration_tests.functional.test_balloon import (
get_stable_rss_mem_by_pid,
make_guest_dirty_memory,
Expand Down Expand Up @@ -184,6 +187,8 @@ def test_snap_restore_from_artifacts(
)

# Run fio on the guest.
_guest_run_fio_iteration(ssh_connection, 0)
# TODO: check the result of FIO or use fsck to check that the root device is
# not corrupted. No obvious errors will be returned here.
guest_run_fio_iteration(ssh_connection, 0)

vm.kill()
99 changes: 71 additions & 28 deletions tests/integration_tests/performance/test_snapshot_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
get_kernel_version,
is_io_uring_supported,
)
from framework.utils_cpuid import get_instance_type
from framework.stats import core, consumer, producer, types, criteria, function
from integration_tests.performance.utils import handle_failure

Expand Down Expand Up @@ -64,42 +65,84 @@
# this is tracked here:
# https://github.com/firecracker-microvm/firecracker/issues/2027
# TODO: Update the table after fix. Target is < 5ms.
# TODO: we need to actually measure the numbers for m6i
# since they might be lower.
LOAD_LATENCY_BASELINES = {
"x86_64": {
"4.14": {
"sync": {
"2vcpu_256mb.json": {"target": 9},
"2vcpu_512mb.json": {"target": 9},
}
"m5d.metal": {
"4.14": {
"sync": {
"2vcpu_256mb.json": {"target": 9},
"2vcpu_512mb.json": {"target": 9},
}
},
"5.10": {
"sync": {
"2vcpu_256mb.json": {"target": 60},
"2vcpu_512mb.json": {"target": 60},
},
"async": {
"2vcpu_256mb.json": {"target": 190},
"2vcpu_512mb.json": {"target": 190},
},
},
},
"5.10": {
"sync": {
"2vcpu_256mb.json": {"target": 60},
"2vcpu_512mb.json": {"target": 60},
"m6a.metal": {
"4.14": {
"sync": {
"2vcpu_256mb.json": {"target": 15},
"2vcpu_512mb.json": {"target": 15},
}
},
"async": {
"2vcpu_256mb.json": {"target": 190},
"2vcpu_512mb.json": {"target": 190},
"5.10": {
"sync": {
"2vcpu_256mb.json": {"target": 60},
"2vcpu_512mb.json": {"target": 60},
},
"async": {
"2vcpu_256mb.json": {"target": 190},
"2vcpu_512mb.json": {"target": 190},
},
},
},
"m6i.metal": {
"4.14": {
"sync": {
"2vcpu_256mb.json": {"target": 9},
"2vcpu_512mb.json": {"target": 9},
}
},
"5.10": {
"sync": {
"2vcpu_256mb.json": {"target": 60},
"2vcpu_512mb.json": {"target": 60},
},
"async": {
"2vcpu_256mb.json": {"target": 190},
"2vcpu_512mb.json": {"target": 190},
},
},
},
},
"aarch64": {
"4.14": {
"sync": {
"2vcpu_256mb.json": {"target": 2},
"2vcpu_512mb.json": {"target": 2},
}
},
"5.10": {
"sync": {
"2vcpu_256mb.json": {"target": 2},
"2vcpu_512mb.json": {"target": 2},
"m6g.metal": {
"4.14": {
"sync": {
"2vcpu_256mb.json": {"target": 2},
"2vcpu_512mb.json": {"target": 2},
}
},
"async": {
"2vcpu_256mb.json": {"target": 125},
"2vcpu_512mb.json": {"target": 130},
"5.10": {
"sync": {
"2vcpu_256mb.json": {"target": 2},
"2vcpu_512mb.json": {"target": 2},
},
"async": {
"2vcpu_256mb.json": {"target": 125},
"2vcpu_512mb.json": {"target": 130},
},
},
},
}
},
}

Expand All @@ -124,7 +167,7 @@ def snapshot_create_measurements(vm_type, snapshot_type):

def snapshot_resume_measurements(vm_type, io_engine):
"""Define measurements for snapshot resume tests."""
load_latency = LOAD_LATENCY_BASELINES[platform.machine()][
load_latency = LOAD_LATENCY_BASELINES[platform.machine()][get_instance_type()][
get_kernel_version(level=1)
][io_engine][vm_type]

Expand Down Expand Up @@ -331,7 +374,7 @@ def _test_snapshot_resume_latency(context):
rw_disk = context.disk.copy()
# Get ssh key from read-only artifact.
ssh_key = context.disk.ssh_key()
# Create a fresh microvm from aftifacts.
# Create a fresh microvm from artifacts.
vm_instance = vm_builder.build(
kernel=context.kernel,
disks=[rw_disk],
Expand Down

0 comments on commit 5f46874

Please sign in to comment.