CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
102 lines
3.4 KiB
Python
102 lines
3.4 KiB
Python
# Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
"""Tests for the volume-scan logic absorbed from ais-volumes."""
|
|
|
|
# pylint: disable=missing-function-docstring,redefined-outer-name,unused-argument
|
|
|
|
import pytest
|
|
|
|
|
|
def _mount(ais_check, *, fstype, options="", source="/dev/nvme0n1", mountpoint="/data"):
|
|
return ais_check.Mount("259:0", mountpoint, fstype, source, options)
|
|
|
|
|
|
def test_fs_supported_xfs_always(ais_check):
|
|
assert ais_check.fs_supported(_mount(ais_check, fstype="xfs")) is True
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"options,expected",
|
|
[
|
|
("rw", True), # no data= option -> ordered default
|
|
("rw,data=ordered", True),
|
|
("rw,data=writeback", False),
|
|
("rw,data=journal", False),
|
|
],
|
|
)
|
|
def test_fs_supported_ext4_data_mode(ais_check, options, expected):
|
|
assert (
|
|
ais_check.fs_supported(_mount(ais_check, fstype="ext4", options=options))
|
|
is expected
|
|
)
|
|
|
|
|
|
def test_fs_supported_other_fs_rejected(ais_check):
|
|
assert ais_check.fs_supported(_mount(ais_check, fstype="btrfs")) is False
|
|
|
|
|
|
def test_fstype_label_folds_ext4_journal_mode(ais_check):
|
|
assert ais_check.fstype_label(_mount(ais_check, fstype="ext4")) == "ext4 (ordered)"
|
|
labelled = ais_check.fstype_label(
|
|
_mount(ais_check, fstype="ext4", options="rw,data=writeback")
|
|
)
|
|
assert labelled == "ext4 (writeback)"
|
|
assert ais_check.fstype_label(_mount(ais_check, fstype="xfs")) == "xfs"
|
|
|
|
|
|
def test_collect_skips_pseudo_and_non_block(ais_check, monkeypatch):
|
|
monkeypatch.setattr(ais_check, "backing_storage", lambda devno: ("nvme", "nvme0n1"))
|
|
monkeypatch.setattr(ais_check, "probe_odirect", lambda mp: True)
|
|
|
|
mounts = [
|
|
_mount(ais_check, fstype="tmpfs", source="tmpfs", mountpoint="/run"),
|
|
_mount(ais_check, fstype="xfs", source="/dev/nvme0n1", mountpoint="/data"),
|
|
]
|
|
rows = ais_check.collect(mounts)
|
|
|
|
assert [r["mountpoint"] for r in rows] == ["/data"]
|
|
assert rows[0]["capable"] is True
|
|
|
|
|
|
def test_collect_skips_network_mount_before_resolution(ais_check, monkeypatch):
|
|
def _fail_backing(devno):
|
|
raise AssertionError("backing_storage must not run on a non-block mount")
|
|
|
|
def _fail_probe(mp):
|
|
raise AssertionError("probe_odirect must not run on a non-block mount")
|
|
|
|
monkeypatch.setattr(ais_check, "backing_storage", _fail_backing)
|
|
monkeypatch.setattr(ais_check, "probe_odirect", _fail_probe)
|
|
|
|
# NFS export: virtual device (major 0) and a "server:/export" source.
|
|
nfs = ais_check.Mount("0:42", "/mnt/nfs", "nfs4", "server:/export", "rw")
|
|
assert ais_check.collect([nfs]) == []
|
|
|
|
|
|
def test_collect_unsupported_fs_not_probed(ais_check, monkeypatch):
|
|
monkeypatch.setattr(ais_check, "backing_storage", lambda devno: ("nvme", "nvme0n1"))
|
|
|
|
def _fail_probe(mp):
|
|
raise AssertionError("probe_odirect must not run on unsupported fs")
|
|
|
|
monkeypatch.setattr(ais_check, "probe_odirect", _fail_probe)
|
|
|
|
rows = ais_check.collect([_mount(ais_check, fstype="btrfs")])
|
|
|
|
assert rows[0]["capable"] is False
|
|
assert rows[0]["odirect"] is None
|
|
|
|
|
|
def test_capable_volumes_aggregates_any(ais_check, monkeypatch):
|
|
monkeypatch.setattr(ais_check, "parse_mountinfo", lambda: [])
|
|
monkeypatch.setattr(
|
|
ais_check,
|
|
"collect",
|
|
lambda mounts: [{"capable": False}, {"capable": True}],
|
|
)
|
|
rows, any_capable = ais_check.capable_volumes()
|
|
assert any_capable is True
|
|
assert len(rows) == 2
|