Skip to content

test: add zram compression tests for crypto_zstd and crypto_lz4#4390

Open
rlmenge wants to merge 3 commits intomicrosoft:mainfrom
rlmenge:rlmenge/zram-compressions
Open

test: add zram compression tests for crypto_zstd and crypto_lz4#4390
rlmenge wants to merge 3 commits intomicrosoft:mainfrom
rlmenge:rlmenge/zram-compressions

Conversation

@rlmenge
Copy link
Collaborator

@rlmenge rlmenge commented Mar 24, 2026

Add a new ZramCompression test suite that validates zram block device functionality with zstd and lz4 compression algorithms on Azure Linux 3.0+.

Each test case loads the crypto module and zram, configures the compression algorithm, creates an ext4 filesystem on the zram device, and verifies data integrity via write/read. Cleanup tears down the device and unloads modules in a finally block.

Description

Adds a new ZramCompression test suite that validates zram block device functionality with zstd and lz4 compression algorithms. The tests are restricted to Azure Linux 3.0+.

Test Cases

  1. verify_zram_crypto_zstd — Tests zram with zstd compression
  2. verify_zram_crypto_lz4 — Tests zram with lz4 compression

What Each Test Does

  1. Checks that the crypto module (crypto_zstd or crypto_lz4) and zram are available in the kernel
  2. Loads the crypto module and zram with num_devices=1
  3. Sets the compression algorithm via comp_algorithm and verifies it is active
  4. Sets a 256MB disk size and verifies it was applied
  5. Creates an ext4 filesystem on zram0, mounts it, writes test data, and reads it back to confirm integrity
  6. Verifies the zram module is loaded via lsmod
  7. Cleans up: unmounts, resets the zram device, and unloads all modules (runs in finally block)

Related Issue

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Documentation update

Checklist

  • Description is filled in above
  • No credentials, secrets, or internal details are included
  • Peer review requested (if not, add required peer reviewers after raising PR)
  • Tests executed and results posted below

Test Validation

Key Test Cases:

verify_zram_crypto_zstd|verify_zram_crypto_lz4

Impacted LISA Features:

None (uses Modprobe, Lsmod, Mount, Mkfs tools — no LISA features)

Tested Azure Marketplace Images:

  • MicrosoftCBLMariner:azure-linux-3:azure-linux-3:latest
  • MicrosoftCBLMariner:azure-linux-3:azure-linux-3-arm64:latest
  • Canonical:ubuntu-24_04-lts:server:latest

Test Results

Note the following had an updated kernel from microsoft/azurelinux#16268

Image VM Size Result
MicrosoftCBLMariner:azure-linux-3:azure-linux-3-arm64:latest Standard_D16plds_v6 PASSED
MicrosoftCBLMariner:azure-linux-3:azure-linux-3:latest Standard_D16as_v4 PASSED
Canonical:ubuntu-24_04-lts:server:latest Standard_D2ads_v5 SKIPPED

Add a new ZramCompression test suite that validates zram block device
functionality with zstd and lz4 compression algorithms on Azure Linux 3.0+.

Each test case loads the crypto module and zram, configures the compression
algorithm, creates an ext4 filesystem on the zram device, and verifies
data integrity via write/read. Cleanup tears down the device and unloads
modules in a finally block.
Copilot AI review requested due to automatic review settings March 24, 2026 22:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new LISA core test suite to validate zram block-device functionality using crypto_zstd and crypto_lz4 compression on Azure Linux (CBLMariner) 3.0+.

Changes:

  • Introduces ZramCompression test suite with two test cases covering zstd and lz4 zram compression backends.
  • Implements a shared helper that loads modules, configures zram via sysfs, formats/mounts ext4, and validates write/read integrity with cleanup.

rlmenge added 2 commits March 24, 2026 16:01
Check mount point exists before calling umount in the finally block.
If the test fails before mounting, umount raises on the missing mount
point and masks the original error.
@rlmenge rlmenge marked this pull request as ready for review March 25, 2026 01:18
Copilot AI review requested due to automatic review settings March 25, 2026 01:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

# Clean up: unmount, reset zram, unload modules
mount_tool = node.tools[Mount]
if mount_tool.check_mount_point_exist(self._ZRAM_MOUNT_POINT):
mount_tool.umount("zram0", self._ZRAM_MOUNT_POINT, erase=False)
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mount.umount takes disk_name as its first positional parameter. Here it’s passed as the string "zram0" while the device used elsewhere is "/dev/zram0", and the call site relies on erase=False so the mismatch is currently harmless. To avoid future breakage (e.g., if erase is ever changed or the signature is refactored), use keyword arguments and pass a consistent disk_name (e.g., the same value as _ZRAM_DEVICE, or an empty string when erase=False).

Suggested change
mount_tool.umount("zram0", self._ZRAM_MOUNT_POINT, erase=False)
mount_tool.umount(
disk_name=self._ZRAM_DEVICE,
mount_point=self._ZRAM_MOUNT_POINT,
erase=False,
)

Copilot uses AI. Check for mistakes.

# Check that the crypto module exists in the kernel
if not modprobe.module_exists(module):
raise SkippedException(f"Kernel module '{module}' is not available.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether there is a possibility that the module doesn't load yet?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's expected — module_exists() runs modprobe --dry-run to check if the module is available in the kernel tree, not whether it's currently loaded. We load it on the next line. This check just lets us skip gracefully if the kernel doesn't include the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants