Project

General

Profile

« Previous | Next » 

Revision 5da9eed3

Added by Thomas McKay almost 8 years ago

fixes #14265 - import content hosts with hypervisors and guests

View differences:

test/content_hosts_test.rb
hammer.run(%W{csv content-hosts --verbose --file #{file.path}})
}
stderr.must_equal ''
stdout[0..-2].must_equal "Creating content host '#{hostname}'...done\nUpdating hypervisor and guest associations...done"
file.unlink
stdout[0..-2].must_equal "Creating content host '#{hostname}'...done"
# Update system
file = Tempfile.new('systems_test')
file.write("Name,Count,Organization,Environment,Content View,System Groups,Virtual,Host,OS,Arch,Sockets,RAM,Cores,SLA,Products,Subscriptions\n")
file.write("#{hostname},1,Mega Corporation,Library,Default Organization View,Mega Corp HQ,No,,RHEL 6.4,x86_64,1,8,1,,,\n")
file.rewind
stdout,stderr = capture {
hammer.run(%W{csv content-hosts --verbose --csv-file #{file.path}})
hammer.run(%W{csv content-hosts --verbose --file #{file.path}})
}
stderr.must_equal ''
stdout[0..-2].must_equal "Updating content host '#{hostname}'...done\nUpdating hypervisor and guest associations...done"
stdout[0..-2].must_equal "Updating content host '#{hostname}'...done"
file.unlink
stdout,stderr = capture {
hammer.run(%W{organization list --search megacorp})
hammer.run(%W{organization list --search label=megacorp})
}
stdout.split("\n").length.must_equal 5
organization_id = stdout.split("\n")[3].split('|')[0].to_i
# Verify system
system = api.resource(:systems).call(:index, {
# Verify host
host = api.resource(:hosts).call(:index, {
'organization_id' => organization_id,
'search' => hostname
'search' => "name=#{hostname}"
})['results']
system.wont_be_nil
system.wont_be_empty
system[0]['name'].must_equal hostname
host.wont_be_nil
host.wont_be_empty
host[0]['name'].must_equal hostname
# Clean up
api.resource(:systems).call(:destroy, {
'id' => system[0]['id']
})
api.resource(:hosts).call(:destroy, {
'id' => host[0]['id']
})
end
end

Also available in: Unified diff