diff --git a/lib/serverspec/helper/type.rb b/lib/serverspec/helper/type.rb index 7c5153ce..0fc87089 100644 --- a/lib/serverspec/helper/type.rb +++ b/lib/serverspec/helper/type.rb @@ -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}" } diff --git a/lib/serverspec/type/mysql_config.rb b/lib/serverspec/type/mysql_config.rb new file mode 100644 index 00000000..939b1ac8 --- /dev/null +++ b/lib/serverspec/type/mysql_config.rb @@ -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 diff --git a/spec/type/base/mysql_config_spec.rb b/spec/type/base/mysql_config_spec.rb new file mode 100644 index 00000000..0a3d25f6 --- /dev/null +++ b/spec/type/base/mysql_config_spec.rb @@ -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