Skip to content

Commit 5c7b316

Browse files
committed
COOK-3752 merge
2 parents 15d42af + d0a2b58 commit 5c7b316

File tree

6 files changed

+43
-31
lines changed

6 files changed

+43
-31
lines changed

.kitchen.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ platforms:
1919
suites:
2020
- name: client
2121
run_list:
22-
- recipe[mysql::client]
22+
- recipe[minitest-handler]
23+
- recipe[mysql_test::client]
2324
- name: ruby
2425
run_list:
2526
- recipe[mysql::ruby]

recipes/server.rb

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
unless missing_attrs.empty?
3232
Chef::Application.fatal! "You must set #{missing_attrs.join(', ')} in chef-solo mode." \
33-
" For more information, see https://github.com/opscode-cookbooks/mysql#chef-solo-note"
33+
" For more information, see https://github.com/opscode-cookbooks/mysql#chef-solo-note"
3434
end
3535
else
3636
# generate all passwords
@@ -84,9 +84,7 @@
8484
def package(*args, &blk)
8585
windows_package(*args, &blk)
8686
end
87-
end
88-
89-
unless platform_family?('windows')
87+
else
9088
group 'mysql' do
9189
action :create
9290
end
@@ -98,6 +96,13 @@ def package(*args, &blk)
9896
home node['mysql']['data_dir']
9997
shell '/sbin/nologin'
10098
end
99+
100+
node['mysql']['server']['packages'].each do |name|
101+
package name do
102+
action :install
103+
notifies :start, 'service[mysql]', :immediately
104+
end
105+
end
101106
end
102107

103108
unless platform_family?('mac_os_x')
@@ -130,26 +135,19 @@ def package(*args, &blk)
130135
source 'my.cnf.erb'
131136
owner 'root' unless platform? 'windows'
132137
group node['mysql']['root_group'] unless platform?('windows')
133-
mode '0644'
134-
case node['mysql']['reload_action']
135-
when 'restart'
136-
notifies :restart, 'service[mysql]', :delayed
137-
when 'reload'
138-
notifies :reload, 'service[mysql]', :delayed
139-
else
140-
Chef::Log.info "my.cnf updated but mysql.reload_action is #{node['mysql']['reload_action']}. No action taken."
141-
end
138+
mode '0644'
139+
case node['mysql']['reload_action']
140+
when 'restart'
141+
notifies :restart, 'service[mysql]', :delayed
142+
when 'reload'
143+
notifies :reload, 'service[mysql]', :delayed
144+
else
145+
Chef::Log.info "my.cnf updated but mysql.reload_action is #{node['mysql']['reload_action']}. No action taken."
146+
end
142147
variables :skip_federated => skip_federated
143148
end
144149
end
145150

146-
node['mysql']['server']['packages'].each do |name|
147-
package name do
148-
action :install
149-
notifies :start, 'service[mysql]', :immediately
150-
end
151-
end
152-
153151
if platform_family?('windows')
154152
require 'win32/service'
155153

@@ -192,9 +190,7 @@ def package(*args, &blk)
192190
supports :status => true, :restart => true, :reload => true
193191
action :enable
194192
end
195-
end
196193

197-
unless platform_family?('mac_os_x')
198194
template "#{node['mysql']['conf_dir']}/my.cnf" do
199195
source 'my.cnf.erb'
200196
owner 'root' unless platform? 'windows'
@@ -248,7 +244,8 @@ def package(*args, &blk)
248244
end
249245
end
250246

251-
service 'mysql' do
247+
service 'mysql-start' do
248+
service_name node['mysql']['service_name']
252249
action :start
253250
end
254251
end
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Must be specified for chef-solo for successful re-converge
2-
override['mysql']['server_root_password'] = 'e;br$il<vOp&Ceth!Hi.en>Roj7'
2+
override['mysql']['server_root_password'] = 'ilikerandompasswords'
33

4-
default['mysql_test']['database'] = 'mysql_test'
5-
default['mysql_test']['username'] = 'test_user'
6-
default['mysql_test']['password'] = 'neshFiapog'
4+
override['mysql_test']['database'] = 'mysql_test'
5+
override['mysql_test']['username'] = 'test_user'
6+
override['mysql_test']['password'] = 'neshFiapog'
77

88
override['mysql']['bind_address'] = 'localhost'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require File.expand_path('../support/helpers.rb', __FILE__)
2+
3+
describe 'mysql::client' do
4+
include Helpers::Mysql
5+
6+
it 'installs the mysql client package' do
7+
node['mysql']['client']['packages'].each do |package_name|
8+
package(package_name).must_be_installed
9+
end
10+
end
11+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
include_recipe 'yum::epel' if platform_family?('rhel')
2+
3+
include_recipe 'mysql::client'
4+

test/cookbooks/mysql_test/recipes/server.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
node.set['mysql']['server_debian_password'] = 'ilikerandompasswords'
2-
node.set['mysql']['server_root_password'] = 'ilikerandompasswords'
3-
node.set['mysql']['server_repl_password'] = 'ilikerandompasswords'
1+
node.override['mysql']['server_debian_password'] = 'ilikerandompasswords'
2+
node.override['mysql']['server_repl_password'] = 'ilikerandompasswords'
3+
node.override['mysql']['server_root_password'] = 'ilikerandompasswords'
44

55
include_recipe 'mysql::ruby'
66
include_recipe 'yum::epel' if platform_family?('rhel')

0 commit comments

Comments
 (0)