Skip to content

Commit

Permalink
Replace inventory refresh test data
Browse files Browse the repository at this point in the history
Old test data was missing quite a few pieces of information, which
made it hard to test the inventory refresh process thoroughly.

New set of data contains data of better quality:

  * has more than one server,
  * servers actually contain some disks,
  * servers are placed in racks/chassis,
  * chassis are nested,
  * components contains location data.
  • Loading branch information
Tadej Borovšak committed Sep 20, 2018
1 parent ddc4976 commit 9b52210
Show file tree
Hide file tree
Showing 10 changed files with 2,711 additions and 859 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,55 @@
:port => 8889)
end

let(:server_id) { "/redfish/v1/Systems/System.Embedded.1" }
let(:servers) do
{
"/redfish/v1/Systems/System-1-1-1-1" => {
:server => {
:health_state => "OK",
:name => "System-1-1-1-1",
:power_state => "PoweringOn",
:raw_power_state => "PoweringOn",
},
:asset_detail => {
:description => "G5 Computer System Node",
:location => "123, Adams Ave., Chesapeake, VA",
:location_led_state => "Off",
:manufacturer => "Dell",
:model => "DSS9630M",
:rack_name => "Rack-1",
:serial_number => "CN701636AB0013",
},
:hardware => {
:cpu_total_cores => 24,
:disk_capacity => 6_017_150_230_528,
:memory_mb => 32_768,
},
},
"/redfish/v1/Systems/System-1-1-1-2" => nil,
"/redfish/v1/Systems/System-1-2-1-1" => {
:server => {
:health_state => "Critical",
:hostname => "hostname.example.com",
:name => "System-1-2-1-1",
:power_state => "On",
:raw_power_state => "On",
},
:asset_detail => {
:location => "123, Adams Ave., Chesapeake, VA",
:location_led_state => "Blinking",
:manufacturer => "Dell Inc.",
:model => "DSS9630M",
:rack_name => "Rack-1",
:serial_number => "945hjf0927mf",
},
:hardware => {
:cpu_total_cores => 20,
:disk_capacity => 412_316_860_416,
:memory_mb => 32_768,
},
},
}
end

describe "refresh", :vcr do
it "will perform a full refresh" do
Expand All @@ -22,43 +70,39 @@
end

def assert_ems
expect(ems.physical_servers.count).to eq(1)
expect(ems.physical_servers.map(&:ems_ref)).to match_array([server_id])
expect(ems.physical_server_details.count).to eq(1)
expect(ems.computer_systems.count).to eq(1)
expect(ems.hardwares.count).to eq(1)
expect(ems.physical_servers.count).to eq(3)
expect(ems.physical_servers.map(&:ems_ref)).to match_array(servers.keys)
expect(ems.physical_server_details.count).to eq(3)
expect(ems.computer_systems.count).to eq(3)
expect(ems.hardwares.count).to eq(3)
end

def check_attributes(instance, attrs, key = nil)
return if attrs.nil?
expect(instance).to have_attributes(key.nil? ? attrs : attrs[key])
end

def assert_physical_servers
s = PhysicalServer.find_by(:ems_ref => server_id)
expect(s).to have_attributes(
:ems_id => ems.id,
:health_state => "OK",
:hostname => "",
:name => "System.Embedded.1",
:power_state => "Off",
:raw_power_state => "Off",
:type => "ManageIQ::Providers::Redfish::PhysicalInfraManager::PhysicalServer",
)
servers.each do |ems_ref, attrs|
server = PhysicalServer.find_by!(:ems_ref => ems_ref)
check_attributes(server, attrs, :server)
end
end

def assert_physical_server_details
d = AssetDetail.find_by(:resource_type => "PhysicalServer")
expect(d).to have_attributes(
:location_led_state => "Off",
:manufacturer => "Dell Inc.",
:model => "DSS9630M",
:resource_type => "PhysicalServer",
:serial_number => "CN701636AB0013",
)
servers.each do |server_ems_ref, attrs|
server = PhysicalServer.find_by!(:ems_ref => server_ems_ref)
asset_detail = AssetDetail.find_by!(:resource => server)
check_attributes(asset_detail, attrs, :asset_detail)
end
end

def assert_hardwares
h = Hardware.first
expect(h).to have_attributes(
:disk_capacity => 0,
:memory_mb => 32_768,
:cpu_total_cores => 40
)
servers.each do |server_ems_ref, attrs|
server = PhysicalServer.find_by!(:ems_ref => server_ems_ref)
system = ComputerSystem.find_by!(:managed_entity => server)
hardware = Hardware.find_by!(:computer_system => system)
check_attributes(hardware, attrs, :hardware)
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9b52210

Please sign in to comment.