Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'spec_helper'
describe 'Running mysql percona container' do
it 'should have mysql-server' do
expect(file('/usr/sbin/mysqld')).to exist
end
it 'should have mysql server configuration syntax correct' do
expect(command('mysqld --help').exit_status).to eq 0
end
it 'should have mysql percona listening on port 3306 open' do
expect(command('netstat -tulapn').stdout).to match(/0.0.0.0:3306|:::3306/)
end
it 'should run mysql as a non privileged user' do
expect(command('ps -u mysql').exit_status).to eq 0
end
it 'should generate index logs if feature replication-master is enabled' do
command('echo "MYSQL_FEATURES=replication-master" > /etc/default/envvars').stdout
command('supervisorctl restart percona').stdout
expect(file('/var/lib/mysql/master-bin.index')).to exist
end
it 'should generate index relay logs if feature replication-slave is enabled' do
command('echo "MYSQL_FEATURES=replication-slave" > /etc/default/envvars').stdout
command('supervisorctl restart percona').stdout
command('mysql -e "START SLAVE;"').stdout
expect(file('/var/lib/mysql/mysql-relay-bin.index')).to exist
end
it 'should generate slow-log logs if feature slow-log is enabled and a slow query is triggered' do
command('echo "MYSQL_FEATURES=slow-query-log" > /etc/default/envvars').stdout
command('supervisorctl restart percona').stdout
expect(file('/var/log/mysql/mysql-slow.log')).to exist
end
it 'should set the server-id when MYSQL_SERVER_ID is set' do
command('echo "MYSQL_SERVER_ID=4" > /etc/default/envvars').stdout
command('supervisorctl restart percona').stdout
expect(file('/etc/mysql/conf.d/server-id.cnf')).to exist
expect(file('/etc/mysql/conf.d/server-id.cnf').content).to match(/server-id=4/)
end
it 'should be able to run queries using local command line mysql tool' do
expect(command('mysql -e "show databases;"').exit_status).to eq 0
end
it 'should take InnoDB tuninig configuration parameters' do
expect(command('mysql -B -e "SHOW VARIABLES LIKE \'default_storage_engine\'"').stdout.chomp.split(' ').last).to eq "InnoDB"
end
it 'should take MyISAM tuninig configuration parameters' do
expect(command('mysql -B -e "SHOW VARIABLES LIKE \'key_buffer_size\'"').stdout.chomp.split(' ').last.to_i / 1024 / 1024).to eq 16
end
it 'should take General Performance tuninig configuration parameters' do
expect(command('mysql -B -e "SHOW VARIABLES LIKE \'back_log\'"').stdout.chomp.split(' ').last.to_i).to eq 50
end
it 'should take Query Cache tuninig configuration parameters' do
expect(command('mysql -B -e "SHOW VARIABLES LIKE \'query_alloc_block_size\'"').stdout.chomp.split(' ').last.to_i / 1024).to eq 16
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.