forked from ManageIQ/manageiq-providers-lenovo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb0a4f9
commit ea1ee31
Showing
4 changed files
with
259 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 51 additions & 61 deletions
112
spec/models/manageiq/providers/lenovo/physical_infra_manager/refresh_parser_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,60 @@ | ||
describe ManageIQ::Providers::Lenovo::PhysicalInfraManager::RefreshParser do | ||
context 'refresh parser' do | ||
host = 'https://10.243.9.123' | ||
uri = '/sessions' | ||
|
||
before do | ||
WebMock.allow_net_connect! | ||
stub_request(:post, File.join(host, uri)).to_return(:status => [200, 'OK']) | ||
it 'will retrieve physical servers' do | ||
pim = FactoryGirl.create(:physical_infra, | ||
:name => "LXCA", | ||
:hostname => "https://10.243.9.123", | ||
:port => "443", | ||
:ipaddress => "https://10.243.9.123:443") | ||
auth = FactoryGirl.create(:authentication, | ||
:userid => 'admin', | ||
:password => 'password', | ||
:authtype => 'default') | ||
pim.authentications = [auth] | ||
rp = described_class.new(pim) | ||
|
||
result = VCR.use_cassette("#{described_class.name.underscore}_ems_inv_to_hashes") do | ||
rp.ems_inv_to_hashes | ||
end | ||
|
||
it 'will retrieve physical servers' do | ||
pim = FactoryGirl.create(:physical_infra, | ||
:name => "LXCA", | ||
:hostname => "https://10.243.9.123", | ||
:port => "443", | ||
:ipaddress => "https://10.243.9.123:443") | ||
auth = FactoryGirl.create(:authentication, | ||
:userid => 'admin', | ||
:password => 'password', | ||
:authtype => 'default') | ||
pim.authentications = [auth] | ||
rp = described_class.new(pim) | ||
|
||
result = VCR.use_cassette("#{described_class.name.underscore}_ems_inv_to_hashes") do | ||
rp.ems_inv_to_hashes | ||
end | ||
expect(result[:physical_servers].size).to eq(4) | ||
end | ||
|
||
expect(result[:physical_servers].size).to eq(4) | ||
it 'will retrieve addin cards on the physical servers' do | ||
pim = FactoryGirl.create(:physical_infra, | ||
:name => "LXCA", | ||
:hostname => "https://10.243.9.123", | ||
:port => "443", | ||
:ipaddress => "https://10.243.9.123:443") | ||
auth = FactoryGirl.create(:authentication, | ||
:userid => 'admin', | ||
:password => 'password', | ||
:authtype => 'default') | ||
pim.authentications = [auth] | ||
rp = described_class.new(pim) | ||
|
||
result = VCR.use_cassette("#{described_class.name.underscore}_retrieve_addin_cards") do | ||
rp.ems_inv_to_hashes | ||
end | ||
|
||
it 'will retrieve addin cards on the physical servers' do | ||
pim = FactoryGirl.create(:physical_infra, | ||
:name => "LXCA", | ||
:hostname => "https://10.243.9.123", | ||
:port => "443", | ||
:ipaddress => "https://10.243.9.123:443") | ||
auth = FactoryGirl.create(:authentication, | ||
:userid => 'admin', | ||
:password => 'password', | ||
:authtype => 'default') | ||
pim.authentications = [auth] | ||
rp = described_class.new(pim) | ||
|
||
result = VCR.use_cassette("#{described_class.name.underscore}_retrieve_addin_cards") do | ||
rp.ems_inv_to_hashes | ||
end | ||
|
||
physical_server = result[:physical_servers][0] | ||
computer_system = physical_server[:computer_system] | ||
hardware = computer_system[:hardware] | ||
guest_device = hardware[:guest_devices][0] | ||
|
||
expect(guest_device[:device_name]).to eq("Broadcom 2-port 1GbE NIC Card for IBM") | ||
expect(guest_device[:device_type]).to eq("ethernet") | ||
expect(guest_device[:firmwares][0][:name]).to eq("Primary 17.4.4.2a-Active") | ||
expect(guest_device[:firmwares][0][:version]).to eq("17.4.4.2a") | ||
expect(guest_device[:manufacturer]).to eq("IBM") | ||
expect(guest_device[:field_replaceable_unit]).to eq("90Y9373") | ||
expect(guest_device[:location]).to eq("Bay 7") | ||
|
||
expect(guest_device[:child_devices][0][:address]).to eq("00:0A:F7:25:67:38") | ||
expect(guest_device[:child_devices][0][:device_type]).to eq("physical_port") | ||
expect(guest_device[:child_devices][0][:device_name]).to eq("Physical Port 1") | ||
end | ||
physical_server = result[:physical_servers][0] | ||
computer_system = physical_server[:computer_system] | ||
hardware = computer_system[:hardware] | ||
guest_device = hardware[:guest_devices][0] | ||
|
||
expect(guest_device[:device_name]).to eq("Broadcom 2-port 1GbE NIC Card for IBM") | ||
expect(guest_device[:device_type]).to eq("ethernet") | ||
expect(guest_device[:firmwares][0][:name]).to eq("Primary 17.4.4.2a-Active") | ||
expect(guest_device[:firmwares][0][:version]).to eq("17.4.4.2a") | ||
expect(guest_device[:manufacturer]).to eq("IBM") | ||
expect(guest_device[:field_replaceable_unit]).to eq("90Y9373") | ||
expect(guest_device[:location]).to eq("Bay 7") | ||
|
||
expect(guest_device[:child_devices][0][:address]).to eq("00:0A:F7:25:67:38") | ||
expect(guest_device[:child_devices][0][:device_type]).to eq("physical_port") | ||
expect(guest_device[:child_devices][0][:device_name]).to eq("Physical Port 1") | ||
end | ||
|
||
it 'will return its miq_template_type' do | ||
expect(described_class.miq_template_type).to eq("ManageIQ::Providers::Lenovo::PhysicalInfraManager::Template") | ||
end | ||
it 'will return its miq_template_type' do | ||
expect(described_class.miq_template_type).to eq("ManageIQ::Providers::Lenovo::PhysicalInfraManager::Template") | ||
end | ||
end |
66 changes: 28 additions & 38 deletions
66
spec/models/manageiq/providers/lenovo/physical_infra_manager/refresher_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,39 @@ | ||
describe ManageIQ::Providers::Lenovo::PhysicalInfraManager::Refresher do | ||
context 'inventory' do | ||
host = 'https://10.243.9.123' | ||
uri = '/sessions' | ||
|
||
before do | ||
WebMock.allow_net_connect! | ||
stub_request(:post, File.join(host, uri)).to_return(:status => [200, 'OK']) | ||
end | ||
|
||
let(:auth) do | ||
FactoryGirl.create(:authentication, | ||
:userid => 'admin', | ||
:password => 'password', | ||
:authtype => 'default') | ||
end | ||
|
||
let(:ems) do | ||
FactoryGirl.create(:physical_infra, | ||
:name => "LXCA", | ||
:hostname => "https://10.243.9.123", | ||
:port => "443", | ||
:ipaddress => "https://10.243.9.123:443") | ||
end | ||
let(:auth) do | ||
FactoryGirl.create(:authentication, | ||
:userid => 'admin', | ||
:password => 'password', | ||
:authtype => 'default') | ||
end | ||
|
||
let(:targets) { [ems] } | ||
let(:refresher) { described_class.new(targets) } | ||
let(:ems) do | ||
FactoryGirl.create(:physical_infra, | ||
:name => "LXCA", | ||
:hostname => "https://10.243.9.123", | ||
:port => "443", | ||
:ipaddress => "https://10.243.9.123:443") | ||
end | ||
|
||
it 'will parse the legacy inventory' do | ||
ems.authentications = [auth] | ||
let(:targets) { [ems] } | ||
let(:refresher) { described_class.new(targets) } | ||
|
||
result = VCR.use_cassette("#{described_class.name.underscore}_parse_legacy_inventory") do | ||
refresher.parse_legacy_inventory(ems) | ||
end | ||
it 'will parse the legacy inventory' do | ||
ems.authentications = [auth] | ||
|
||
expect(result[:physical_servers].size).to eq(3) | ||
result = VCR.use_cassette("#{described_class.name.underscore}_parse_legacy_inventory") do | ||
refresher.parse_legacy_inventory(ems) | ||
end | ||
|
||
it 'will save the inventory' do | ||
ems.authentications = [auth] | ||
expect(result[:physical_servers].size).to eq(3) | ||
end | ||
|
||
refresher.save_inventory(ems, {}, {}) | ||
end | ||
it 'will save the inventory' do | ||
ems.authentications = [auth] | ||
|
||
it 'will execute post_process_refresh_classes' do | ||
expect(refresher.post_process_refresh_classes).to eq([]) | ||
end | ||
refresher.save_inventory(ems, {}, {}) | ||
end | ||
|
||
it 'will execute post_process_refresh_classes' do | ||
expect(refresher.post_process_refresh_classes).to eq([]) | ||
end | ||
end |
Oops, something went wrong.