microsoft / lisa

LISA is developed and maintained by Microsoft, to empower Linux validation.
https://aka.ms/lisa
MIT License
203 stars 170 forks source link

Supporting Hyper-V on Windows 10/11? #3327

Open PatrickLang opened 3 months ago

PatrickLang commented 3 months ago

Background

I use Hyper-V on Windows 10/11 desktops regularly for development and testing. This is mostly for my personal interest and open-source contributions, but I sometimes use it to reproduce issues developers report at work related to our internal tools.

I have some rough scripts I use to speed up setting up new distros, and generally use those instead of Vagrant so that I can also review and understand changes to the setup experience. Additionally, some desktop distributions still lack a full 'kickstart' or cloud-init which makes them much harder to manage through Vagrant.

Once installed, I generally do some basic checks with lsmod, journalctl, and other tools to verify the correct modules are installed. I look at reported resolutions, errors, and other clues around Wayland or X11 initialization. I have been able to submit bugs and/or fixes to Fedora to make hyperv_drm the default, and more recently to diagnose and test a bug that prevented KDE Plasma's wayland compositor from starting in a Hyper-V VM. Resolution switching now works well in Fedora, but some issues still remain in Ubuntu 22+.

Proposal

Since there are already ways to run on Azure, AWS, QEmu, I would like to see a way to wrap up local Hyper-V management with Lisa as well. The desktop distros I normally test are not often used in cloud environments, so I don't see Azure being a replacement for this testing.

Right now it looks like the best way I could take advantage of Lisa is to use the "Ready" runbook, but that still leaves VM management up to me. I think that could work as a good starting point for tests once a VM has been deployed.

One possible workflow I'm considering is:

  1. Find or create a simple PyTest fixture that will serve as a wrapper to handle the basic VM operations needed. It does not need to be comprehensive, just a set of common configurations that should work for most modern distros. Generation 2, Secure Boot on w/ open-source signing certificate configured, auto snapshot disabled, and default resolution set to 1080p. This could just be a wrapper around some short PowerShell scripts initially
  2. Capture kickstart files, or manual test steps that could be relayed to a user doing manual testing following the VM configuration, leading them through the remaining steps needed to finish the distro install through enabling SSH. This sounds a lot like Vagrant's job, but as mentioned above, that is not always suitable when working with desktop distro testing from ISO files
  3. Bootstrap Python and the code in this repo
  4. Run the "READY" runbook
  5. Run an additional runbook focused on basic smoke tests for the desktop environment. Capture screenshots at each step to help identify defects. This should include confirming the appropriate display protocol (Wayland preferred), resolution set, resolution enumeration, etc
  6. Copy results & screenshots out of the VM
  7. Clean up VM
PatrickLang commented 3 months ago

Well - it looks like some progress has been made, but there are no docs. https://github.com/microsoft/lisa/pull/3152

It also appears that it only configures VMs from a premade VHD/VHDX file, rather than doing a distro install.

Can you provide any more info on how this is intended to be used, and if it is still a work-in-progress?

squirrelsc commented 3 months ago

@anirudhrb can you help add document for hyperv platform here and an example runbook?

@PatrickLang , the hyperv platform completed first phase, it looks enough for your scenario. Please check below example, and let us know, if there is any question. For checks of guest Linux, you can create your own test case, and reference it in LISA to run. The tools of LISA can help dealing with compatibility of different distros.

platform:
  - type: hyperv
    keep_environment: $(keep_environment)
    admin_username: $(vhd_admin_username)
    admin_password: $(vhd_admin_password)
    requirement:
      core_count:
        min: 32
      memory_mb:
        min: 65536
      hyperv:
        hyperv_generation: 2
    hyperv:
      source:
        type: local
        files:
          - source: $(vhd)
            unzip: true
      servers:
        - address: $(hv_server_address)
          username: $(hv_server_username)
          password: $(hv_server_password)
anirudhrb commented 3 months ago

@squirrelsc ack, I will add documentation.