From d48e65ebd2f1a45ad820db091ab0519ec7576490 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Tue, 27 Aug 2024 09:03:07 -0400 Subject: [PATCH 1/2] Add vmware/vcsim as a service in GHA --- .github/workflows/ci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 803aac595..7b11eceae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,6 +25,10 @@ jobs: --health-retries 5" ports: - 5432:5432 + vcsim: + image: vmware/vcsim + ports: + - 8989:8989 env: PGHOST: localhost PGPASSWORD: smartvm From 08958ed286cea8750278cd8c8d980d189a942fd6 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Tue, 27 Aug 2024 09:07:04 -0400 Subject: [PATCH 2/2] WIP test connecting to live vcsim --- .../manageiq/providers/vmware/infra_manager_spec.rb | 13 +------------ spec/spec_helper.rb | 6 ++++++ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/spec/models/manageiq/providers/vmware/infra_manager_spec.rb b/spec/models/manageiq/providers/vmware/infra_manager_spec.rb index 44c86e988..76fec0b75 100644 --- a/spec/models/manageiq/providers/vmware/infra_manager_spec.rb +++ b/spec/models/manageiq/providers/vmware/infra_manager_spec.rb @@ -42,22 +42,11 @@ end context ".verify_credentials" do - let(:verify_params) { {"endpoints" => {"default" => {"hostname" => "vcenter"}}, "authentications" => {"default" => {"username" => "root", "password" => "vmware"}}} } + let(:verify_params) { {"endpoints" => {"default" => {"hostname" => "localhost", "port" => 8989}}, "authentications" => {"default" => {"username" => "root", "password" => "vmware"}}} } let(:current_time) { Time.now.utc.to_s } let(:is_virtual_center) { true } let(:api_version) { '6.5.0' } - before do - miq_vim = double("VMwareWebService/MiqVim") - allow(miq_vim).to receive(:isVirtualCenter).and_return(is_virtual_center) - allow(miq_vim).to receive(:currentTime).and_return(current_time) - allow(miq_vim).to receive(:apiVersion).and_return(api_version) - allow(miq_vim).to receive(:disconnect) - - require "VMwareWebService/MiqVim" - expect(MiqVim).to receive(:new).and_return(miq_vim) - end - context "virtual-center" do it "is successful" do expect(described_class.verify_credentials(verify_params)).to be_truthy diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0add26cf6..3e7cce125 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,6 +15,12 @@ end VCR.configure do |config| + # Allow connections to a local vcsim + config.ignore_request do |req| + uri = URI(req.uri) + uri.host == "localhost" && uri.port = 8989 + end + config.ignore_hosts 'codeclimate.com' if ENV['CI'] config.cassette_library_dir = File.join(ManageIQ::Providers::Vmware::Engine.root, 'spec/vcr_cassettes')