Sha256: 70fab7428d604d9e6709488cc14fd7aa47975bd59cc69e2f7bd9336890305eb1

Contents?: true

Size: 1.88 KB

Versions: 7

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper_system'

describe 'mysql class' do
  case node.facts['osfamily']
  when 'RedHat'
    package_name = 'mysql-server'
    service_name = 'mysqld'
  when 'Suse'
    package_name = 'mysql-community-server'
    service_name = 'mysql'
  when 'Debian'
    package_name = 'mysql-server'
    service_name = 'mysql'
  end

  describe 'running puppet code' do
    # Using puppet_apply as a helper
    it 'should work with no errors' do
      pp = <<-EOS
        class { 'mysql::server': }
      EOS

      # Run it twice and test for idempotency
      puppet_apply(pp) do |r|
        r.exit_code.should_not == 1
        r.refresh
        r.exit_code.should be_zero
      end
    end

    describe package(package_name) do
      it { should be_installed }
    end

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

  describe 'my.cnf' do
    it 'should contain sensible values' do
      pp = <<-EOS
        class { 'mysql::server': }
      EOS
      puppet_apply(pp) do |r|
        r.exit_code.should_not == 1
      end
    end

    describe file('/etc/my.cnf') do
      it { should contain 'key_buffer = 16M' }
      it { should contain 'max_binlog_size = 100M' }
      it { should contain 'query_cache_size = 16M' }
    end
  end

  describe 'my.cnf changes' do
    it 'sets values' do
      pp = <<-EOS
        class { 'mysql::server':
          override_options => { 'mysqld' => 
            { 'key_buffer'       => '32M',
              'max_binlog_size'  => '200M',
              'query_cache_size' => '32M',
            }
          }  
        }
      EOS
      puppet_apply(pp) do |r|
        r.exit_code.should_not == 1
      end
    end

    describe file('/etc/my.cnf') do
      it { should contain 'key_buffer = 32M' }
      it { should contain 'max_binlog_size = 200M' }
      it { should contain 'query_cache_size = 32M' }
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
freighthop-0.6.1 modules/mysql/spec/system/mysql_server_spec.rb
freighthop-0.6.0 modules/mysql/spec/system/mysql_server_spec.rb
freighthop-0.5.2 modules/mysql/spec/system/mysql_server_spec.rb
freighthop-0.5.1 modules/mysql/spec/system/mysql_server_spec.rb
freighthop-0.5.0 modules/mysql/spec/system/mysql_server_spec.rb
freighthop-0.4.1 modules/mysql/spec/system/mysql_server_spec.rb
freighthop-0.4.0 modules/mysql/spec/system/mysql_server_spec.rb