Skip to content

vmtests: create#2300

Draft
dbungert wants to merge 1 commit intocanonical:mainfrom
dbungert:vmtest
Draft

vmtests: create#2300
dbungert wants to merge 1 commit intocanonical:mainfrom
dbungert:vmtest

Conversation

@dbungert
Copy link
Member

Add a vmtests directory with a framework based on pytest, virt-install, and autoinstall to automate test runs in a VM.

Sample invocation:

pytest-3 --iso=/srv/iso/resolute/resolute-live-server-amd64.iso

Has some marked FIXMEs, I expect to tweak the initial contents of the actual tests also.

@dbungert dbungert marked this pull request as draft January 27, 2026 01:00
Copy link
Member

@ogayot ogayot left a comment

Choose a reason for hiding this comment

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

Thanks for making vmtest a thing! I have some suggestions but nothing blocks merging in my opinion.

I would like to have a way to specify the libvirt instance to use (i.e., qemu:///session vs qemu:///system).

It can be passed to virsh and virt-install using virsh --connect qemu:///session and virt-install --connect qemu:///session.

Maybe, define a virsh function?

def virsh(args: list[str], **kwargs):
    prefix = ["virsh"]
    if libvirt_instance is not None:
        prefix.extend(["--connect", libvirt_instance])
    return runcmd(prefix + args, **kwargs)

cloud_config["autoinstall"]["ssh"]["authorized-keys"] = [pubkey]

result = self.tempdir / "cloud-config.yaml"
with open(result, "w") as fp:
Copy link
Member

Choose a reason for hiding this comment

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

I like result.write_text(...) but it's up to you!

https://docs.python.org/3/library/pathlib.html#pathlib.Path.write_text

@dbungert
Copy link
Member Author

Thanks @ogayot for the first round feedback. Updates since that round:

  • more type info on functions
  • a few docstring updates
  • rethink the keyword argument name on VM() for the test cloud config partial snippet, going with cloud_config
  • fix handling VM(cloud_config=None)
  • dynamically determine the minimal source ID, thus allowing this to run desktop-style ISOs
  • some function names that should be clearer, for instance s/_assert_install_success/_assert_state_late_commands
  • log directory also uses seconds in the directory name
  • some FIXMEs closed, some added
  • default all waits with a timeout to 300s
  • handle tests that have late-commands

@dbungert
Copy link
Member Author

And the virsh part is still outstanding

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