Skip to content

Implement support for tests using real libvirt with FOG_LIBVIRT_URI - #197

Merged
ekohl merged 2 commits into
fog:masterfrom
davispuh:mock
Jul 29, 2026
Merged

Implement support for tests using real libvirt with FOG_LIBVIRT_URI#197
ekohl merged 2 commits into
fog:masterfrom
davispuh:mock

Conversation

@davispuh

Copy link
Copy Markdown
Contributor

Currently rake live fails with:

Fog::Compute[:libvirt] (libvirt)     
    fog-libvirt/tests/libvirt/compute_tests.rb
      Fog::Compute[:libvirt] (libvirt)
    Missing required arguments: libvirt_uri (ArgumentError)

First commit from this PR fixes that so rake live works.
2nd commit implements support for running tests against real libvirt by using FOG_LIBVIRT_URI env var.
All these are fully supported and work correctly:

$ rake
$ FOG_MOCK=true rake

$ FOG_MOCK=true FOG_LIBVIRT_URI=qemu:///session rake
$ FOG_MOCK=true FOG_LIBVIRT_URI=qemu:///system rake

$ FOG_MOCK=false rake
$ rake live

$ rake live_session
$ FOG_LIBVIRT_URI=qemu:///session rake
$ FOG_MOCK=false FOG_LIBVIRT_URI=qemu:///session rake
$ FOG_LIBVIRT_URI=qemu:///system rake
$ FOG_MOCK=false FOG_LIBVIRT_URI=qemu:///system rake

(something like FOG_LIBVIRT_URI=qemu+ssh://host/system rake should also work but I haven't tested)

I also fixed tests so they cleanup afterwards so there won't be test leftovers when running against real libvirt.
But note that with this feature tests shouldn't do something like servers.all.each(&:destroy) to not cause someone a bad day when run with real libvirt. If needed then such should only be run when using libvirt test driver only.

Copilot AI review requested due to automatic review settings July 28, 2026 22:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ekohl ekohl left a comment

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.

Thanks, looks really good. Only some minor inline comments but I'd be happy to merge this as is already.

Comment thread tests/libvirt/models/compute/server_tests.rb Outdated
Comment thread minitests/test_helper.rb Outdated
Comment thread Rakefile Outdated
@davispuh

Copy link
Copy Markdown
Contributor Author

Just pushed with all fixes applied.

@ekohl ekohl left a comment

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.

Thanks!

@ekohl
ekohl merged commit 6579e1a into fog:master Jul 29, 2026
7 of 8 checks passed
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