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
6 changes: 4 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ def pytest_addoption(parser: pytest.Parser) -> None:
"--volume-size",
action="store",
default="1GiB",
help="Default volume size for tests"
help="Default volume size for tests."
" Accepts sizes like '1GiB', '2.5TiB', or symbolic values 'VHD_MAX', 'QCOW2_MAX'."
)
parser.addoption(
"--write-volume-cap",
action="store",
default="2GiB",
help="Maximum amount of data written to a volume"
help="Maximum amount of data written to a volume."
" Accepts sizes like '1GiB', '2.5TiB', or symbolic values 'VHD_MAX', 'QCOW2_MAX'."
)

def pytest_configure(config: pytest.Config) -> None:
Expand Down
13 changes: 12 additions & 1 deletion lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,21 @@
GiB = KiB**3
TiB = KiB**4

VHD_MAX = 2040 * GiB
QCOW2_MAX = 16 * TiB - 2561 * MiB

_SYMBOLIC_SIZES: dict[str, int] = {
'VHD_MAX': VHD_MAX,
'QCOW2_MAX': QCOW2_MAX,
}

def parse_size(size_str: str) -> int:
"""
Parse a size string like "2.5TiB", "1GiB" or "1024".
Parse a size string like "2.5TiB", "1GiB", "1024", "VHD_MAX", or "QCOW2_MAX".
"""
symbolic = _SYMBOLIC_SIZES.get(size_str.strip().upper())
if symbolic is not None:
return symbolic
try:
return int(size_str)
except ValueError:
Expand Down
4 changes: 2 additions & 2 deletions tests/storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

from lib import config
from lib.commands import SSHCommandFailed
from lib.common import Defer, GiB, MiB, TiB, strtobool, wait_for
from lib.common import QCOW2_MAX, VHD_MAX, Defer, GiB, MiB, TiB, strtobool, wait_for
from lib.host import Host
from lib.sr import SR
from lib.vdi import VDI, ImageFormat
from lib.vm import VM

from typing import Literal

MAX_VDI_SIZE: dict[ImageFormat, int] = {'qcow2': 16 * TiB - 2561 * MiB, 'vhd': 2040 * GiB}
MAX_VDI_SIZE: dict[ImageFormat, int] = {'qcow2': QCOW2_MAX, 'vhd': VHD_MAX}

def try_to_create_sr_with_missing_device(sr_type, label, host) -> None:
try:
Expand Down
Loading