3 describe 'openstacklib::db::mysql' do
6 'include mysql::server'
9 let (:title) { 'nova' }
11 let :required_params do
12 { :password_hash => 'AA1420F182E88B9E5F874F6FBE7459291E8F4601' }
15 shared_examples 'openstacklib::db::mysql examples' do
17 context 'with only required parameters' do
22 it { is_expected.to contain_mysql_database(title).with(
24 :collate => 'utf8_general_ci'
26 it { is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
33 context 'with overriding dbname parameter' do
35 { :dbname => 'foobar' }.merge(required_params)
38 it { is_expected.to contain_mysql_database(params[:dbname]).with(
40 :collate => 'utf8_general_ci'
42 it { is_expected.to contain_openstacklib__db__mysql__host_access("#{params[:dbname]}_127.0.0.1").with(
44 :database => params[:dbname],
49 context 'with overriding user parameter' do
51 { :user => 'foobar' }.merge(required_params)
54 it { is_expected.to contain_mysql_database(title).with(
56 :collate => 'utf8_general_ci'
58 it { is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
59 :user => params[:user],
65 context 'when overriding charset parameter' do
67 { :charset => 'latin1' }.merge(required_params)
70 it { is_expected.to contain_mysql_database(title).with_charset(params[:charset]) }
73 context 'when omitting the required parameter password_hash' do
75 required_params.delete(:password_hash)
77 it { expect { is_expected.to raise_error(Puppet::Error) } }
80 context 'when notifying other resources' do
82 'exec {"nova-db-sync":}'
85 { :notify => 'Exec[nova-db-sync]'}.merge(required_params)
88 it { is_expected.to contain_exec('nova-db-sync').that_subscribes_to("Openstacklib::Db::Mysql[#{title}]") }
91 context 'when required for other openstack services' do
93 'service {"keystone":}'
99 { :before => 'Service[keystone]'}.merge(required_params)
102 it { is_expected.to contain_service('keystone').that_requires("Openstacklib::Db::Mysql[keystone]") }
105 context "overriding allowed_hosts parameter with array value" do
107 { :allowed_hosts => ['127.0.0.1','%'] }.merge(required_params)
110 it {is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
112 :password_hash => params[:password_hash],
115 it {is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_%").with(
117 :password_hash => params[:password_hash],
122 context "overriding allowed_hosts parameter with string value" do
124 { :allowed_hosts => '192.168.1.1' }.merge(required_params)
127 it {is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_192.168.1.1").with(
129 :password_hash => params[:password_hash],
134 context "overriding allowed_hosts parameter equals to host param " do
136 { :allowed_hosts => '127.0.0.1' }.merge(required_params)
139 it {is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
141 :password_hash => params[:password_hash],
148 context 'on a Debian osfamily' do
150 { :osfamily => "Debian" }
153 include_examples 'openstacklib::db::mysql examples'
156 context 'on a RedHat osfamily' do
158 { :osfamily => 'RedHat' }
161 include_examples 'openstacklib::db::mysql examples'