Skip to content

Commit

Permalink
Merge pull request #524 from serverspec/support-mysql-config
Browse files Browse the repository at this point in the history
Support checking MySQL configuration
  • Loading branch information
mizzy committed Jun 22, 2015
2 parents 4e7b4aa + 6e97a5d commit a924b2c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/serverspec/helper/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ module Serverspec
module Helper
module Type
types = %w(
base bridge bond cgroup command cron default_gateway file fstab group host
iis_website iis_app_pool interface ipfilter ipnat iptables
ip6tables kernel_module linux_kernel_parameter lxc mail_alias
package php_config port ppa process routing_table selinux
selinux_module service user yumrepo windows_feature
windows_hot_fix windows_registry_key windows_scheduled_task zfs
docker_base docker_image docker_container x509_certificate x509_private_key
base bridge bond cgroup command cron default_gateway file fstab
group host iis_website iis_app_pool interface ipfilter ipnat
iptables ip6tables kernel_module linux_kernel_parameter lxc
mail_alias mysql_config package php_config port ppa process
routing_table selinux selinux_module service user yumrepo
windows_feature windows_hot_fix windows_registry_key
windows_scheduled_task zfs docker_base docker_image
docker_container x509_certificate x509_private_key
)

types.each {|type| require "serverspec/type/#{type}" }
Expand Down
10 changes: 10 additions & 0 deletions lib/serverspec/type/mysql_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Serverspec::Type
class MysqlConfig < Base
def value
ret = @runner.run_command("mysqld --verbose --help 2> /dev/null | grep '^#{@name}'")
val = ret.stdout.match(/#{@name}\s+(.+)$/)[1]
val = val.to_i if val.match(/^\d+$/)
val
end
end
end
13 changes: 13 additions & 0 deletions spec/type/base/mysql_config_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'spec_helper'

set :os, :family => 'base'

describe mysql_config('innodb-buffer-pool-size') do
let(:stdout) { 'innodb-buffer-pool-size 134217728' }
its(:value) { should eq 134217728 }
end

describe mysql_config('socket') do
let(:stdout) { 'socket /tmp/mysql.sock' }
its(:value) { should eq '/tmp/mysql.sock' }
end

0 comments on commit a924b2c

Please sign in to comment.