Skip to content

test(usb): fix broken NodeUSBDevices e2e test#2297

Merged
danilrwx merged 27 commits into
mainfrom
test/usb/broken-tests
Apr 29, 2026
Merged

test(usb): fix broken NodeUSBDevices e2e test#2297
danilrwx merged 27 commits into
mainfrom
test/usb/broken-tests

Conversation

@danilrwx
Copy link
Copy Markdown
Contributor

@danilrwx danilrwx commented Apr 28, 2026

Description

Stabilize the VirtualMachineUSB e2e scenario and simplify the USB handling flow in the guest.

Changes include:

  • check NodeUSBDevice detached state before creating the VM;
  • wait for the VM guest agent and USB readiness explicitly;
  • extract repeated USB test actions into helper methods;
  • rescan SCSI hosts before mount attempts in the guest;
  • detect the guest USB disk through lsblk while validating that the expected USB serial is present;
  • remount the USB filesystem after migration before reading the test data;
  • flush data with sync and unmount the filesystem before migration;
  • increase retries/timeouts around guest-side USB disk discovery after reconnect.

Why do we need it, and what problem does it solve?

The USB e2e scenario was flaky in several places:

  • the detached check ran after VM creation and raced with attachment;
  • the guest could see the USB device in lsusb before the block disk was ready;
  • after migration the USB disk could reconnect later and require additional wait time before remounting;
  • data could remain in cache if the filesystem was not flushed before migration.

These changes make the test validate the expected sequence more accurately and reduce random failures caused by delayed guest-side USB storage discovery.

What is the expected result?

Run the USB e2e scenario:

FOCUS="VirtualMachineUSB" task e2e:run

Expected behavior:

  1. NodeUSBDevice is detached before VM creation.
  2. VM starts and reports the USB device as attached and ready.
  3. The guest finds and mounts the USB mass-storage disk.
  4. Test data is written, flushed, and unmounted.
  5. VM is migrated.
  6. The guest waits for the USB disk to reappear and remounts it after reconnect.
  7. The previously written data is still present.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: test
type: fix
summary: Stabilized the VirtualMachineUSB e2e test by improving guest USB disk detection, remount flow, and timeouts around migration.
impact_level: low

@danilrwx danilrwx added this to the v1.9.0 milestone Apr 29, 2026
danilrwx added 26 commits April 29, 2026 12:06
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx force-pushed the test/usb/broken-tests branch from a04f6dc to 71a7617 Compare April 29, 2026 10:06
@danilrwx danilrwx marked this pull request as ready for review April 29, 2026 10:21
@danilrwx danilrwx requested a review from Isteb4k as a code owner April 29, 2026 10:21
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx merged commit bc0eae4 into main Apr 29, 2026
27 of 28 checks passed
@danilrwx danilrwx deleted the test/usb/broken-tests branch April 29, 2026 12:34
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.

2 participants