From 6656b3460bed3908cf1cfd55b702cd0eda7839a5 Mon Sep 17 00:00:00 2001 From: Leos Stejskal Date: Mon, 18 Nov 2024 09:51:14 +0100 Subject: [PATCH] Fixes #38017 - Update libvirt gems & fix tests Gems: * Use fog-libvirt 0.13.0 * Use ruby-libvirt 0.8.3 Tests: * Use "test:///default" for testing * Fix failing tests --- bundler.d/libvirt.rb | 4 ++-- test/controllers/hosts_controller_test.rb | 3 --- test/factories/compute_resources.rb | 4 ++++ test/fixtures/compute_resources.yml | 4 ++-- test/unit/compute_resource_host_importer_test.rb | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bundler.d/libvirt.rb b/bundler.d/libvirt.rb index 80b3f8c5a12..3d3b8718bbb 100644 --- a/bundler.d/libvirt.rb +++ b/bundler.d/libvirt.rb @@ -1,4 +1,4 @@ group :libvirt do - gem 'fog-libvirt', '>= 0.12.0' - gem 'ruby-libvirt', '~> 0.5', :require => 'libvirt' + gem 'fog-libvirt', '~> 0.13.0' + gem 'ruby-libvirt', '>= 0.8.3', :require => 'libvirt' end diff --git a/test/controllers/hosts_controller_test.rb b/test/controllers/hosts_controller_test.rb index f3e2a414d3f..e512cf27bcd 100644 --- a/test/controllers/hosts_controller_test.rb +++ b/test/controllers/hosts_controller_test.rb @@ -1218,9 +1218,6 @@ def test_submit_multiple_rebuild_config_pessimistic context 'Fog.mock!' do setup do Fog.mock! - Foreman::Model::Libvirt.any_instance.stubs(:hypervisor).returns(stub(:hypervisor)) - Foreman::Model::Libvirt.any_instance.expects(:max_cpu_count).returns(10) - Foreman::Model::Libvirt.any_instance.expects(:max_memory).returns(10000000000) end teardown { Fog.unmock! } diff --git a/test/factories/compute_resources.rb b/test/factories/compute_resources.rb index e43e67fae47..ee6882996e0 100644 --- a/test/factories/compute_resources.rb +++ b/test/factories/compute_resources.rb @@ -15,6 +15,10 @@ trait :libvirt do provider { 'Libvirt' } + # url { 'test:///default' } prevents the error: + # Call to virConnectOpen failed: Cannot read CA certificate + # '/etc/pki/CA/cacert.pem': No such file or directory + url { 'test:///default' } end trait :openstack do diff --git a/test/fixtures/compute_resources.yml b/test/fixtures/compute_resources.yml index 4e2ff8195d8..52c0b740da4 100644 --- a/test/fixtures/compute_resources.yml +++ b/test/fixtures/compute_resources.yml @@ -2,7 +2,7 @@ one: name: bigcompute description: MyString - url: qemu://stam/system + url: test:///default user: MyString password: encrypted-NEN1YVJtdWdaaTdlOHdiUXRHd29nWUZsOHc1UjdMb3p1MFZLenlLekFEbz0tLVA0MGVzUEorUDlJZHVUV2F6azUzUEE9PQ==--9f45d5c88ec582eeb48ebb906ae0a66345ded0fa uuid: MyString @@ -11,7 +11,7 @@ one: mycompute: name: mycompute description: mycompute - url: test:///default # test hypervisor URI needed to try listing vms + url: test:///default # test hypervisor URI needed to try listing vms user: MyString password: encrypted-QU5oNkZVSkRRTW81U2hSemhqcU1mdFpYM0FXUEpVZndseWl2NERvS0laWT0tLWpsU295K0kxcWNLT2g1WTRrcC9TVXc9PQ==--5936541f0bda1b2262bb610340facf3c3880bdd0 uuid: mycompute diff --git a/test/unit/compute_resource_host_importer_test.rb b/test/unit/compute_resource_host_importer_test.rb index a255175178f..8b86443a680 100644 --- a/test/unit/compute_resource_host_importer_test.rb +++ b/test/unit/compute_resource_host_importer_test.rb @@ -75,11 +75,11 @@ class ComputeResourceHostImporterTest < ActiveSupport::TestCase context 'on libvirt' do let(:compute_resource) { FactoryBot.build(:libvirt_cr) } - let(:uuid) { 'fog-449765558356062' } + let(:uuid) { '6695eb01-f6a4-8304-79aa-97f2502e193f' } test 'imports the VM with all parameters' do - assert_equal 'fog-dom1', host.name - assert_equal 'dom.uuid', host.uuid + assert_equal 'test', host.name + assert_equal uuid, host.uuid assert_nil host.domain assert_equal 'aa:bb:cc:dd:ee:ff', host.mac assert_empty host.primary_interface.compute_attributes