-
Notifications
You must be signed in to change notification settings - Fork 2k
test(metrics): collect Firecracker vhost-user metrics #4246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wearyzen
merged 1 commit into
firecracker-microvm:main
from
wearyzen:vhost_user_ci_metrics
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
tests/integration_tests/performance/test_vhost_user_metrics.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
"""Tests to collect Firecracker metrics for vhost-user devices.""" | ||
|
||
import time | ||
|
||
import pytest | ||
|
||
import host_tools.drive as drive_tools | ||
from framework.utils_drive import resize_vhost_user_drive, spawn_vhost_user_backend | ||
|
||
|
||
@pytest.mark.parametrize("vcpu_count", [1, 2], ids=["1vcpu", "2vcpu"]) | ||
def test_vhost_user_block_metrics( | ||
microvm_factory, guest_kernel, rootfs_ubuntu_22, vcpu_count, metrics | ||
): | ||
""" | ||
This test tries to boot a VM with vhost-user-block | ||
as a scratch device, resize the vhost-user scratch drive to have | ||
config change notifications, collects and then uploads the related | ||
vhost-user FirecrackerMetrics to Cloudwatch. | ||
Having vhost-user as root device vs a scratch should not impact metrics, however, | ||
we choose to have it as a scratch device because we are interested in config change | ||
metrics which we cannot extract when vhost-user is root device | ||
(read only rootfs won't have a config change). | ||
""" | ||
orig_size = 10 # MB | ||
# Picked from test_config_change assuming that the intention is to change size from | ||
# low->high->low->high and so the numbers are not in monotonic sequence. | ||
new_sizes = [20, 10, 30] # MB | ||
vhost_user_socket = "/vub.socket" | ||
|
||
vm = microvm_factory.build(guest_kernel, rootfs_ubuntu_22, monitor_memory=False) | ||
vm.spawn(log_level="Info") | ||
vm.basic_config(vcpu_count=vcpu_count) | ||
|
||
# Add a block device to test resizing. | ||
fs = drive_tools.FilesystemFile(size=orig_size) | ||
_backend = spawn_vhost_user_backend(vm, fs.path, vhost_user_socket) | ||
vm.add_vhost_user_drive("scratch", vhost_user_socket) | ||
vm.start() | ||
|
||
# vhost-user-block is activated during boot but it takes a while so we wait. | ||
# 300msec picked by the limited number of experiments tried to see how long | ||
# it takes to get the activate_time_us metrics. | ||
time.sleep(0.3) | ||
|
||
metrics.set_dimensions( | ||
{ | ||
"performance_test": "vhost_user_block_metrics", | ||
"io_engine": "vhost-user", | ||
**vm.dimensions, | ||
} | ||
) | ||
fc_metrics = vm.flush_metrics() | ||
assert 0 == fc_metrics["vhost_user_block_scratch"]["activate_fails"] | ||
assert fc_metrics["vhost_user_block_scratch"]["init_time_us"] | ||
assert fc_metrics["vhost_user_block_scratch"]["activate_time_us"] | ||
|
||
metrics.put_metric( | ||
"init_time_us", | ||
fc_metrics["vhost_user_block_scratch"]["init_time_us"], | ||
unit="Microseconds", | ||
) | ||
metrics.put_metric( | ||
"activate_time_us", | ||
fc_metrics["vhost_user_block_scratch"]["activate_time_us"], | ||
unit="Microseconds", | ||
) | ||
|
||
for new_size in new_sizes: | ||
# Instruct the backend to resize the device. | ||
# It will both resize the file and update its device config. | ||
resize_vhost_user_drive(vm, new_size) | ||
|
||
# Instruct Firecracker to reread device config and notify | ||
# the guest of a config change. | ||
vm.patch_drive("scratch") | ||
|
||
fc_metrics = vm.flush_metrics() | ||
assert 0 == fc_metrics["vhost_user_block_scratch"]["cfg_fails"] | ||
assert fc_metrics["vhost_user_block_scratch"]["config_change_time_us"] | ||
metrics.put_metric( | ||
"config_change_time_us", | ||
fc_metrics["vhost_user_block_scratch"]["config_change_time_us"], | ||
unit="Microseconds", | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.