Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update allowed_hosts conditional statement
In the origin heat::db::mysql, if the value of $allowed_hosts contains or equals to $host, then puppet will complain duplicate declaration error. This patch is aim to update the allowed_hosts conditonal statement in heat::db::mysql. There are two cases to pass $allowed_hosts to $real_allowed_hosts: - If $allowed_hosts is array,then remove $host from $allowed_hosts; - elsif $allowed_hosts is string and not equivalent to $host; At last, if $real_allowed_hosts is not undef, then run heat::db::mysql::host_access Add heat_db_mysql_spec for related test. Fix bug 1206444 Change-Id: Iac6a32fb614c9ad19f9eaa3aaa883cb3bf9aa2ef
- Loading branch information
Xingchao Yu
committed
Aug 5, 2013
1 parent
3419e99
commit e9e261b
Showing
2 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
require 'spec_helper' | ||
|
||
describe 'heat::db::mysql' do | ||
let :facts do | ||
{ :osfamily => 'RedHat' } | ||
end | ||
|
||
let :pre_condition do | ||
'include mysql::server' | ||
end | ||
|
||
let :params do | ||
{ :password => 's3cr3t', | ||
:dbname => 'heat', | ||
:user => 'heat', | ||
:host => 'localhost', | ||
:charset => 'latin1' | ||
} | ||
end | ||
|
||
shared_examples_for 'heat mysql database' do | ||
|
||
context 'when omiting the required parameter password' do | ||
before { params.delete(:password) } | ||
it { expect { should raise_error(Puppet::Error) } } | ||
end | ||
|
||
it 'creates a mysql database' do | ||
should contain_mysql__db( params[:dbname] ).with( | ||
:user => params[:user], | ||
:password => params[:password], | ||
:host => params[:host], | ||
:charset => params[:charset], | ||
:require => 'Class[Mysql::Config]' | ||
) | ||
end | ||
end | ||
|
||
describe "overriding allowed_hosts param to array" do | ||
let :params do | ||
{ | ||
:password => 'heatpass', | ||
:allowed_hosts => ['localhost','%'] | ||
} | ||
end | ||
|
||
it {should_not contain_heat__db__mysql__host_access("localhost").with( | ||
:user => 'heat', | ||
:password => 'heatpass', | ||
:database => 'heat' | ||
)} | ||
it {should contain_heat__db__mysql__host_access("%").with( | ||
:user => 'heat', | ||
:password => 'heatpass', | ||
:database => 'heat' | ||
)} | ||
end | ||
|
||
describe "overriding allowed_hosts param to string" do | ||
let :params do | ||
{ | ||
:password => 'heatpass2', | ||
:allowed_hosts => '192.168.1.1' | ||
} | ||
end | ||
|
||
it {should contain_heat__db__mysql__host_access("192.168.1.1").with( | ||
:user => 'heat', | ||
:password => 'heatpass2', | ||
:database => 'heat' | ||
)} | ||
end | ||
|
||
describe "overriding allowed_hosts param equals to host param " do | ||
let :params do | ||
{ | ||
:password => 'heatpass2', | ||
:allowed_hosts => 'localhost' | ||
} | ||
end | ||
|
||
it {should_not contain_heat__db__mysql__host_access("localhost").with( | ||
:user => 'heat', | ||
:password => 'heatpass2', | ||
:database => 'heat' | ||
)} | ||
end | ||
end |