Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spec test for a full refresh #138

Merged
merged 3 commits into from
Mar 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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