Skip to content

Commit

Permalink
Add serverspec test, to verify that mysql listen on the good port whe…
Browse files Browse the repository at this point in the history
…n changed
  • Loading branch information
sinfomicien committed Sep 18, 2014
1 parent 082cc29 commit 6c0e4f9
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ suites:
attributes:
mariadb:
use_default_repository: true
- name: port_changed
run_list:
- recipe[mariadb::default]
attributes:
mariadb:
use_default_repository: true
mysqld:
port: 3307
11 changes: 11 additions & 0 deletions test/integration/port_changed/serverspec/install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

package_server_name = 'mariadb-server-10.0'
case backend.check_os[:family]
when 'Fedora', 'CentOS', 'RedHat'
package_server_name = 'MariaDB-server'
end

describe package(package_server_name) do
it { should be_installed }
end
66 changes: 66 additions & 0 deletions test/integration/port_changed/serverspec/mysql_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
require 'spec_helper'

describe service('mysql') do
it { should be_enabled }
it { should be_running }
end

describe port('3307') do
it { should be_listening }
end

includedir = '/etc/mysql/conf.d'
mysql_config_file = '/etc/mysql/my.cnf'
case backend.check_os[:family]
when 'Fedora', 'CentOS', 'RedHat'
includedir = '/etc/my.cnf.d'
mysql_config_file = '/etc/my.cnf'
end

describe "verify the tuning attributes set in #{mysql_config_file}" do
{
query_cache_size: '64M',
thread_cache_size: 128,
max_connections: 100,
wait_timeout: 600,
max_heap_table_size: '32M',
read_buffer_size: '2M',
read_rnd_buffer_size: '1M',
long_query_time: 10,
key_buffer_size: '128M',
max_allowed_packet: '16M',
sort_buffer_size: '4M',
myisam_sort_buffer_size: '512M'
}.each do |attribute, value|
describe command("grep -E \"^#{attribute}\\s+\" #{mysql_config_file}") do
it { should return_stdout(/#{value}/) }
end
end
end

describe 'verify the tuning attributes set in ' + includedir + '/innodb.cnf' do
{
innodb_buffer_pool_size: '256M',
innodb_flush_method: 'O_DIRECT',
innodb_file_per_table: 1,
innodb_open_files: 400
}.each do |attribute, value|
describe command("grep -E \"^#{attribute}\\s+\" " \
"#{includedir}/innodb.cnf") do
it { should return_stdout(/#{value}/) }
end
end
end

describe 'verify the tuning attributes set in ' \
+ includedir + '/replication.cnf' do
{
max_binlog_size: '100M',
expire_logs_days: 10
}.each do |attribute, value|
describe command("grep -E \"^#{attribute}\\s+\" " \
"#{includedir}/replication.cnf") do
it { should return_stdout(/#{value}/) }
end
end
end
4 changes: 4 additions & 0 deletions test/integration/port_changed/serverspec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'serverspec'

include Serverspec::Helper::Exec
include Serverspec::Helper::DetectOS

0 comments on commit 6c0e4f9

Please sign in to comment.