Skip to content

test: migrate VirtualMachineImageHotplug e2e test to new framework#2443

Open
eofff wants to merge 3 commits into
mainfrom
chore/rewrite-image-hotplug-on-new-framework
Open

test: migrate VirtualMachineImageHotplug e2e test to new framework#2443
eofff wants to merge 3 commits into
mainfrom
chore/rewrite-image-hotplug-on-new-framework

Conversation

@eofff

@eofff eofff commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

Migrate VirtualMachineImageHotplug e2e test to the new framework.

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: vm
type: chore
summary: Migrate VirtualMachineImageHotplug e2e test to new framework.

@eofff eofff force-pushed the chore/rewrite-image-hotplug-on-new-framework branch from 8ae0ba1 to 6dd1ae7 Compare June 4, 2026 08:22
@eofff eofff added this to the v1.9.0 milestone Jun 4, 2026
@eofff eofff requested a review from hardcoretime June 4, 2026 09:24
Comment thread test/e2e/internal/config/config.go Outdated
Comment thread test/e2e/vm/image_hotplug.go Outdated
Comment thread test/e2e/blockdevice/image_hotplug.go
Comment thread test/e2e/vm/image_hotplug.go Outdated
Comment thread test/e2e/vm/image_hotplug.go Outdated
Comment thread test/e2e/vm/image_hotplug.go Outdated
Comment thread test/e2e/vm/image_hotplug.go Outdated
@eofff eofff force-pushed the chore/rewrite-image-hotplug-on-new-framework branch from 6ea377b to e7a4413 Compare June 8, 2026 05:59
@universal-itengineer universal-itengineer modified the milestones: v1.9.0, v1.10.0 Jun 10, 2026
@eofff eofff force-pushed the chore/rewrite-image-hotplug-on-new-framework branch from b1ec9c9 to a2576d3 Compare June 15, 2026 09:03
@eofff eofff requested a review from hardcoretime June 15, 2026 11:23
Valeriy Khorunzhin added 2 commits June 15, 2026 14:24
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
@eofff eofff force-pushed the chore/rewrite-image-hotplug-on-new-framework branch from a2576d3 to a7d545a Compare June 15, 2026 11:25
@eofff eofff marked this pull request as ready for review June 15, 2026 12:49
@eofff eofff requested a review from Isteb4k as a code owner June 15, 2026 12:49
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>

remove legacy

Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>

resolve

Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
@eofff eofff force-pushed the chore/rewrite-image-hotplug-on-new-framework branch from a7d545a to 5c453d6 Compare June 15, 2026 13:00
Eventually(func(g Gomega) {
count, diskErr := util.GetDiskCount(f, vm.Name, vm.Namespace)
g.Expect(diskErr).NotTo(HaveOccurred())
g.Expect(count).To(Equal(initialDiskCount))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add a short description to the error message.

}
}
g.Expect(attached).To(
BeNumerically(">=", expectedAttached+1),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should use strict equality?

}

func tryMountReadOnly(f *framework.Framework, vm *v1alpha2.VirtualMachine, sourcePath, mountPoint string) (bool, error) {
cmd := fmt.Sprintf("if sudo mount -o ro %q %q >/dev/null 2>&1; then echo true; else echo false; fi", sourcePath, mountPoint)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this script returns an error, it will not be clear, and we will not see an error message.

}

func firstPartitionPath(f *framework.Framework, vm *v1alpha2.VirtualMachine, sourcePath string) (string, error) {
cmd := fmt.Sprintf("lsblk -lnpo PATH %q 2>/dev/null; true", sourcePath)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do not parse strings. Return the result in JSON format and unmarshal it into a structure. Then, work with the structure's fields.

}

func isBlockDeviceReadOnly(f *framework.Framework, vm *v1alpha2.VirtualMachine, blockDeviceByID string) (bool, error) {
if strings.HasPrefix(blockDeviceByID, cdRomByIDPrefix) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is the ReadOnly option not validated during mounting?

Comment on lines +276 to +280
if isMounted, err := mountReadOnly(f, vm, devicePath, mountPoint); err != nil {
return false, err
} else if !isMounted {
return false, nil
}

@hardcoretime hardcoretime Jun 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if isMounted, err := mountReadOnly(f, vm, devicePath, mountPoint); err != nil {
return false, err
} else if !isMounted {
return false, nil
}
isMounted, err := mountReadOnly(f, vm, devicePath, mountPoint)
if err != nil {
return false, err
}
if !isMounted {
return false, nil
}


func unmountPath(f *framework.Framework, vm *v1alpha2.VirtualMachine, path string) error {
cmd := fmt.Sprintf("sudo umount %q >/dev/null 2>&1; sudo rmdir %q >/dev/null 2>&1; true", path, path)
_, err := f.SSHCommand(vm.Name, vm.Namespace, cmd)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, when an error occurs, STDOUT may contain useful information for debugging. Do not ignore it.

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