Revision 26095e05
Added by Shimon Shtein over 8 years ago
test/unit/host_test.rb | ||
---|---|---|
end
|
||
end
|
||
|
||
context 'hostgroup defaults' do
|
||
context 'compute resources' do
|
||
setup do
|
||
@group1 = FactoryGirl.create(:hostgroup, :compute_profile => compute_profiles(:one))
|
||
@group2 = FactoryGirl.create(:hostgroup, :compute_profile => compute_profiles(:two))
|
||
end
|
||
|
||
test 'sets proper compute attributes on hostgroup change' do
|
||
test 'set_hostgroup_defaults doesnt touch compute attributes' do
|
||
host = FactoryGirl.create(:host, :managed, :compute_resource => compute_resources(:one), :hostgroup => @group1)
|
||
assert_not_equal 4, host.compute_attributes['cpus']
|
||
|
||
host.attributes = host.apply_inherited_attributes('hostgroup_id' => @group2.id)
|
||
host.set_hostgroup_defaults
|
||
assert_not_equal 4, host.compute_attributes['cpus']
|
||
end
|
||
|
||
test 'set_compute_attributes changes the compute attributes' do
|
||
host = FactoryGirl.create(:host, :managed, :compute_resource => compute_resources(:one), :hostgroup => @group1)
|
||
assert_not_equal 4, host.compute_attributes['cpus']
|
||
|
||
host.attributes = host.apply_inherited_attributes('hostgroup_id' => @group2.id)
|
||
host.set_compute_attributes
|
||
assert_equal 4, host.compute_attributes['cpus']
|
||
end
|
||
end
|
Also available in: Unified diff
Fixes #12618 - Now calls for compute attributes are explicit.
Prevents compute attributes from being overwritten unconditionally from
the hostgroup's compute profile.
(cherry picked from commit 19d9e229ebadb9c9488786391e645c98e4c248ea)