Skip to content

Commit

Permalink
Merge pull request #138 from skovic/full-refresh-test
Browse files Browse the repository at this point in the history
Add spec test for a full refresh
  • Loading branch information
agrare authored Mar 12, 2018
2 parents e615a3e + b6997d2 commit 36d36fd
Show file tree
Hide file tree
Showing 3 changed files with 5,158 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
VCR.insert_cassette("#{vcr_path}/mock_aicc", options)
VCR.insert_cassette("#{vcr_path}/mock_cabinet", options)
VCR.insert_cassette("#{vcr_path}/mock_config_patterns", options)
VCR.insert_cassette("#{vcr_path}/full_refresh", options)
end
after(:all) do
while VCR.cassettes.last
Expand All @@ -30,6 +31,19 @@
ems
end

let(:ems2) do
# Note: The hostname below cannot be an IP address because it will
# cause the full refresh test to fail when being executed
# on the Travis CI site.
ems2 = FactoryGirl.create(:physical_infra,
:name => "LXCA2",
:hostname => "lxcahost",
:port => "443",
:ipaddress => "https://10.243.9.123:443")
ems2.authentications = [auth]
ems2
end

let(:targets) { [ems] }

let(:refresher) { described_class.new(targets) }
Expand All @@ -49,4 +63,35 @@
it 'will execute post_process_refresh_classes' do
expect(refresher.post_process_refresh_classes).to eq([])
end

it 'will perform a full refresh' do
# Perform the refresh twice to verify that a second run with existing data
# does not change anything
2.times do
EmsRefresh.refresh(ems2)
ems2.reload

assert_table_counts
assert_guest_table_contents
end
end

def assert_table_counts
expect(PhysicalServer.count).to eq(2)
expect(GuestDevice.count).to eq(5)
end

def assert_guest_table_contents
server = PhysicalServer.find_by(:ems_ref => "7936DD182C5311E3A8D6000AF7256738")
nic = server.hardware.nics.first
ports = nic.child_devices
port1 = ports.find_by(:device_name => "Physical Port 1")
port2 = ports.find_by(:device_name => "Physical Port 2")

expect(nic.device_name).to eq("Broadcom 2-port 1GbE NIC Card for IBM")
expect(port1.device_name).to eq("Physical Port 1")
expect(port1.address).to eq("00:0A:F7:25:67:38")
expect(port2.device_name).to eq("Physical Port 2")
expect(port2.address).to eq("00:0A:F7:25:67:39")
end
end
Loading

0 comments on commit 36d36fd

Please sign in to comment.