-
Notifications
You must be signed in to change notification settings - Fork 0
feat: adds vdbench wrapper and simple test #394
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
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
416a729
feat: add layer with java support
nhitar 6841519
feat: add wrap recipe for vdbench
nhitar 5db9f20
feat: add python wrap for vdbench with basic test
nhitar d0a9280
fix: ruff format
nhitar 30dc9f2
docs: translate readme
nhitar 30008be
refactor: specify vdbench output directory
nhitar 9ef46ff
refactor: swap kwargs for create_opt
nhitar 3a35e1b
refactor: change binary dir to sbin
nhitar 1637fa2
refactor: add final type
nhitar d82ae31
refactor: use LIB_DATA_DIR for store config and output files.
Artanias ac9a6a1
refactor: moves vdbench config and output creating into the subfolder.
Artanias cb21985
fix+refactor: correctly create folders for the vdbench config and inc…
Artanias 64092df
refactor: recreate folders if needs on the remote for the vdbench.
Artanias fcad41c
fix: get home path from the remote for the vdbench.
Artanias 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
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 |
|---|---|---|
|
|
@@ -7,3 +7,6 @@ uv.lock | |
| .coverage | ||
| pytest-coverage.xml | ||
| imgtests.egg-info | ||
|
|
||
| # External | ||
| vdbench.tar.gz | ||
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
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
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 |
|---|---|---|
|
|
@@ -168,4 +168,5 @@ IMAGE_INSTALL:append = " \ | |
| zip \ | ||
| zlib \ | ||
| zstd \ | ||
| vdbench \ | ||
| " | ||
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,7 @@ | ||
| To make the recipe work, you will need to attach an archive (with name vdbench.tar.gz) containing the following files: | ||
|
|
||
| - binary tool files; | ||
|
|
||
| - linux x64 file and config script; | ||
|
|
||
| - recipe license. |
19 changes: 19 additions & 0 deletions
19
layers/meta-image-tests/recipes-vdbench/vdbench/vdbench.bb
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,19 @@ | ||
| SUMMARY = "Vdbench" | ||
| # License must be withing the archive and md5sum should be updated. | ||
| LICENSE = "GPL-2.0-only" | ||
| LIC_FILES_CHKSUM = "file://LICENSE;md5=8a1984b6adf89397460816c68c05c616" | ||
|
|
||
| FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" | ||
| SRC_URI += "file://vdbench.tar.gz" | ||
|
|
||
| S = "${WORKDIR}/vdbench" | ||
|
|
||
| RDEPENDS:${PN} += "bash" | ||
|
|
||
| do_install() { | ||
| install -d ${D}${sbindir}/vdbench | ||
|
|
||
| cp -r ${S}/* ${D}${sbindir}/vdbench/ | ||
| } | ||
|
|
||
| FILES:${PN} = "${sbindir}/vdbench" | ||
Empty file.
Submodule meta-openjdk-temurin
added at
5804d9
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
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
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,105 @@ | ||
| import logging | ||
| from pathlib import Path | ||
| from typing import Final | ||
|
|
||
| from imgtests.constant import LIB_NAME | ||
| from imgtests.exec.base_util import GenericUtil | ||
| from imgtests.exec.exec import ExecResult, SSHClient, common_run_command | ||
| from imgtests.exec.utils import create_opt | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| VDBENCH_NAME: Final = "vdbench" | ||
| VDBENCH_DIR: Final = Path("/usr/sbin") / VDBENCH_NAME | ||
|
|
||
|
|
||
| class Vdbench(GenericUtil): | ||
| def __init__(self, ssh_client: SSHClient | None = None) -> None: | ||
| super().__init__(VDBENCH_NAME, ssh_client) | ||
| self.path = VDBENCH_DIR / VDBENCH_NAME | ||
|
|
||
| def validate_setup(self) -> ExecResult: | ||
| result = common_run_command(["ls", str(self.path)], self.ssh_client) | ||
| if result.returncode: | ||
| return ExecResult( | ||
| cmd=result.cmd, | ||
| stderr=f"Failed to locate '{self.name}'.", | ||
| returncode=1, | ||
| ) | ||
| return result | ||
|
|
||
| def configure_params( | ||
| self, | ||
| config_file: Path, | ||
| timeout_sec: int = 60, | ||
| block_size: int = 4096, | ||
| read_percentage: int = 70, | ||
| iorate: int = 1000, | ||
| ) -> ExecResult: | ||
| configuration = ( | ||
| f"sd=sd1,lun=storage.img,size=1024m\n" | ||
| f"wd=wd1,sd=sd1,xfersize={block_size},readpct={read_percentage},seekpct=100\n" | ||
| f"rd=run1,wd=wd1,iorate={iorate},elapsed={timeout_sec},interval=1" | ||
| ) | ||
| result = self.__provide_folder(config_file.parent) | ||
| if result.returncode: | ||
| return result | ||
| return common_run_command( | ||
| [ | ||
| "echo", | ||
| "-e", | ||
| f"'{configuration}'", | ||
| ">", | ||
| str(config_file), | ||
| ], | ||
| self.ssh_client, | ||
| ) | ||
|
|
||
| def run( | ||
| self, | ||
| timeout_sec: int, | ||
| block_size: int = 4096, | ||
| read_percentage: int = 70, | ||
| iorate: int = 1000, | ||
| ) -> tuple[ExecResult, Path | None]: | ||
| """Runs the vdbench. | ||
|
|
||
| Args: | ||
| timeout_sec (int): Execution time of the vdbench in seconds. | ||
| block_size (int): Block size in bytes for IO operations. | ||
| read_percentage (int): Percentage of read operations. | ||
| iorate (int): IO operations per second. | ||
| """ | ||
| result = self.validate_setup() | ||
| if result.returncode: | ||
| return result, None | ||
| result = common_run_command(["echo", "$HOME"], self.ssh_client) | ||
| home_dir = result.stdout.strip() | ||
| if result.returncode or not home_dir: | ||
| return result, None | ||
|
|
||
| config_file: Final = Path(home_dir) / LIB_NAME / VDBENCH_NAME / f"{VDBENCH_NAME}-config" | ||
| self.configure_params( | ||
| config_file=config_file, | ||
| timeout_sec=timeout_sec, | ||
| block_size=block_size, | ||
| read_percentage=read_percentage, | ||
| iorate=iorate, | ||
| ) | ||
|
|
||
| output_dir = Path(home_dir) / LIB_NAME / VDBENCH_NAME / f"{VDBENCH_NAME}-output" | ||
| result = self.__provide_folder(output_dir) | ||
| if result.returncode: | ||
| return result, None | ||
| opts = [ | ||
| *create_opt("f", config_file, use_one_dash=True), | ||
| *create_opt("o", output_dir, use_one_dash=True), | ||
| ] | ||
| result = self(opts) | ||
| return result, output_dir | ||
|
|
||
| def __provide_folder(self, folder: Path) -> ExecResult: | ||
| result = common_run_command(["test", "-d", str(folder)], self.ssh_client) | ||
| if result.returncode: | ||
| return common_run_command(["mkdir", "--parents", str(folder)], self.ssh_client) | ||
| return result |
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,46 @@ | ||
| from datetime import UTC, datetime | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from imgtests.exec.loaders import Vdbench | ||
| from imgtests.planning.base import AbstractRunnableTimeLimitedTest | ||
| from imgtests.types import Subsystem, TestResult, TestStatus | ||
|
|
||
| if TYPE_CHECKING: | ||
| from collections.abc import Iterable | ||
| from concurrent.futures import ThreadPoolExecutor | ||
|
|
||
| from imgtests.exec.exec import SSHClient | ||
|
|
||
|
|
||
| class VdbenchTest(AbstractRunnableTimeLimitedTest): | ||
| """Test that runs vdbench on a disk.""" | ||
|
|
||
| def __init__(self, timeout: int) -> None: | ||
| super().__init__( | ||
| "Load drives with vdbench.", | ||
| frozenset({Subsystem.FILE}), | ||
| timeout=timeout, | ||
| ) | ||
|
|
||
| def _run( | ||
| self, | ||
| executor: ThreadPoolExecutor, | ||
| client: SSHClient | None, | ||
| timeout: int, | ||
| ) -> Iterable[TestResult]: | ||
| vdbench = Vdbench(client) | ||
| started_at = datetime.now(UTC) | ||
| future = executor.submit( | ||
| vdbench.run, | ||
| timeout_sec=timeout, | ||
| block_size=4096, | ||
| read_percentage=70, | ||
| iorate=1000, | ||
| ) | ||
| result, output_dir = future.result() | ||
| yield TestResult( | ||
| metrics={"output_dir": output_dir}, | ||
| command=" ".join(result.cmd), | ||
| started_at=started_at, | ||
| status=TestStatus.PASSED if not result.returncode else TestStatus.FAILED, | ||
| ) |
Oops, something went wrong.
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.