Revision 43c4bd72
Added by Marek Hulán over 9 years ago
test/unit/location_test.rb | ||
---|---|---|
|
||
test 'it should return array of used ids by hosts' do
|
||
location = taxonomies(:location1)
|
||
subnet = FactoryGirl.create(:subnet)
|
||
domain = FactoryGirl.create(:domain)
|
||
FactoryGirl.create(:host,
|
||
:compute_resource => compute_resources(:one),
|
||
:domain => domains(:mydomain),
|
||
:domain => domain,
|
||
:environment => environments(:production),
|
||
:location => location,
|
||
:medium => media(:one),
|
||
... | ... | |
:owner => users(:restricted),
|
||
:puppet_proxy => smart_proxies(:puppetmaster),
|
||
:realm => realms(:myrealm),
|
||
:subnet => subnets(:one))
|
||
:subnet => subnet)
|
||
FactoryGirl.create(:os_default_template,
|
||
:config_template => config_templates(:mystring2),
|
||
:operatingsystem => operatingsystems(:centos5_3),
|
||
... | ... | |
# get results from Host object
|
||
environment_ids = Host.where(:location_id => location.id).pluck(:environment_id).compact.uniq
|
||
hostgroup_ids = Host.where(:location_id => location.id).pluck(:hostgroup_id).compact.uniq
|
||
subnet_ids = Host.where(:location_id => location.id).pluck(:subnet_id).compact.uniq
|
||
domain_ids = Host.where(:location_id => location.id).pluck(:domain_id).compact.uniq
|
||
subnet_ids = Host.where(:location_id => location.id).joins(:primary_interface => :subnet).pluck(:subnet_id).map(&:to_i).compact.uniq
|
||
domain_ids = Host.where(:location_id => location.id).joins(:primary_interface => :domain).pluck(:domain_id).map(&:to_i).compact.uniq
|
||
realm_ids = Host.where(:location_id => location.id).pluck(:realm_id).compact.uniq
|
||
medium_ids = Host.where(:location_id => location.id).pluck(:medium_id).compact.uniq
|
||
compute_resource_ids = Host.where(:location_id => location.id).pluck(:compute_resource_id).compact.uniq
|
||
... | ... | |
# match to raw fixtures data
|
||
assert_equal used_ids[:environment_ids].sort, [environments(:production).id]
|
||
assert_equal used_ids[:hostgroup_ids], []
|
||
assert_equal used_ids[:subnet_ids], [subnets(:one).id]
|
||
assert_equal used_ids[:domain_ids], [domains(:mydomain).id]
|
||
assert_equal used_ids[:subnet_ids], [subnet.id]
|
||
assert_equal used_ids[:domain_ids], [domain.id]
|
||
assert_equal used_ids[:medium_ids], [media(:one).id]
|
||
assert_equal used_ids[:compute_resource_ids], [compute_resources(:one).id]
|
||
assert_equal used_ids[:user_ids], [users(:restricted).id]
|
||
assert_equal used_ids[:smart_proxy_ids].sort, [smart_proxies(:one).id, smart_proxies(:two).id, smart_proxies(:three).id, smart_proxies(:puppetmaster).id, smart_proxies(:realm).id].sort
|
||
assert_includes used_ids[:smart_proxy_ids].sort, smart_proxies(:puppetmaster).id
|
||
assert_includes used_ids[:smart_proxy_ids].sort, smart_proxies(:realm).id
|
||
assert_equal used_ids[:config_template_ids], [config_templates(:mystring2).id]
|
||
end
|
||
|
||
... | ... | |
|
||
test "used_and_selected_or_inherited_ids for inherited location" do
|
||
parent = taxonomies(:location1)
|
||
subnet = FactoryGirl.create(:subnet)
|
||
domain1 = FactoryGirl.create(:domain)
|
||
domain2 = FactoryGirl.create(:domain)
|
||
parent.update_attribute(:domains,[domain1,domain2])
|
||
parent.update_attribute(:subnets,[subnet])
|
||
# we're no longer using the fixture dhcp/dns/tftp proxy to create the host, so remove them
|
||
parent.update_attribute(:smart_proxies,[smart_proxies(:puppetmaster),smart_proxies(:realm)])
|
||
|
||
location = Location.create :name => "rack1", :parent_id => parent.id
|
||
FactoryGirl.create(:host,
|
||
:compute_resource => compute_resources(:one),
|
||
:domain => domains(:mydomain),
|
||
:domain => domain1,
|
||
:environment => environments(:production),
|
||
:location => parent,
|
||
:organization => taxonomies(:organization1),
|
||
... | ... | |
:owner => users(:restricted),
|
||
:puppet_proxy => smart_proxies(:puppetmaster),
|
||
:realm => realms(:myrealm),
|
||
:subnet => subnets(:one))
|
||
:subnet => subnet)
|
||
FactoryGirl.create(:host,
|
||
:location => parent,
|
||
:domain => domains(:yourdomain))
|
||
:domain => domain2)
|
||
FactoryGirl.create(:os_default_template,
|
||
:config_template => config_templates(:mystring2),
|
||
:operatingsystem => operatingsystems(:centos5_3),
|
||
:template_kind => TemplateKind.find_by_name('provision'))
|
||
# check that inherited_ids of location matches selected_ids of parent
|
||
|
||
# check that inherited_ids of location matches selected_ids of parent
|
||
location.selected_or_inherited_ids.each do |k,v|
|
||
assert_equal v.sort, parent.used_and_selected_ids[k].sort
|
||
end
|
Also available in: Unified diff
Fixes #7456 - Extract primary interface from host
Contributions from:All host must have at least one primary interface and one provision (can
be the same interface). Primary interface gives host a name so even
unamanaged host have primary interface (we skip validations of other
attributes for unamanged hosts though).
Host still have name attribute which is a cache of primary interface name.
Therefore we can use the host name in SQL queries, as a friendly_id etc.
- realm moved to the primary tab
- fqdn in nics table
- flags in nics table
- checkboxes for provision and primary flags
- modal resize fix
- original fields for primary NIC removed
- skipping validation for new resources
- warnings before switching flags and table update
- host name and primary interface name connected
- host domain name in the page title
- nics on host show page
- clearing modal window on cancel
- fixed domain validation in NIC::Base
- ip suggestion for all interfaces
- flags switchable from the overview table
- use icons instead of text for primary/provision on NICs overview tab
- attempt to fix sending NIC template
- fix fqdn algorithm
- ip addres in the overview table
- fix for class name collision
- better behavior of host name <-> primary name sync
- fix for subnet combobox values
- fix for modal poping up on form submission
- network partial for CRs moved from VM tab to modal
- fix ip suggestion race for ipam=db