Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FM 7783 - Test Audit making testing more efficient #1162

Merged
merged 3 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions lib/puppet/functions/mysql_password.rb

This file was deleted.

21 changes: 0 additions & 21 deletions lib/puppet/functions/mysql_strip_hash.rb

This file was deleted.

19 changes: 0 additions & 19 deletions lib/puppet/parser/functions/mysql_strip_hash.rb

This file was deleted.

4 changes: 2 additions & 2 deletions spec/acceptance/locales_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper_acceptance'
require 'beaker/i18n_helper'

describe 'mysql localization', if: (fact('osfamily') == 'Debian' || fact('osfamily') == 'RedHat') && (Gem::Version.new(puppet_version) >= Gem::Version.new('4.10.5')) do
describe 'mysql localization', if: (os[:family] == 'debian' || os[:family] == 'redhat') && (Gem::Version.new(puppet_version) >= Gem::Version.new('4.10.5')) do
before :all do
hosts.each do |host|
on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb")
Expand All @@ -12,7 +12,7 @@
context 'when triggering puppet simple string error' do
# 'service_enabled' being set to false can cause random failures in Debian 9
let(:os_variant) do
if fact('operatingsystem') =~ %r{Debian} && fact('operatingsystemrelease') =~ %r{^9\.}
if os[:family] == 'debian' && os[:release].to_i == 9
'true'
else
'false'
Expand Down
52 changes: 2 additions & 50 deletions spec/acceptance/mysql_backup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class { 'mysql::server::backup':
}
MANIFEST
it 'when configuring mysql backups' do
execute_manifest(pp, catch_failures: true)
execute_manifest(pp, catch_failures: true)
idempotent_apply(default, pp, {})
end
end

Expand Down Expand Up @@ -104,8 +103,7 @@ class { 'mysql::server::backup':
}
MANIFEST
it 'when configuring mysql backups' do
execute_manifest(pp, catch_failures: true)
execute_manifest(pp, catch_failures: true)
idempotent_apply(default, pp, {})
end
end

Expand Down Expand Up @@ -153,50 +151,4 @@ class { 'mysql::server::backup':
# rubocop:enable RSpec/MultipleExpectations, RSpec/ExampleLength
end
end

context 'with triggers and routines' do
pre_run
pp = <<-MANIFEST
class { 'mysql::server': root_password => 'password' }
mysql::db { [
'backup1',
'backup2'
]:
user => 'backup',
password => 'secret',
}
package { 'bzip2':
ensure => present,
}
class { 'mysql::server::backup':
backupuser => 'myuser',
backuppassword => 'mypassword',
backupdir => '/tmp/backups',
backupcompress => true,
file_per_database => true,
include_triggers => #{version_is_greater_than('5.1.5')},
include_routines => true,
postscript => [
'rm -rf /var/tmp/mysqlbackups',
'rm -f /var/tmp/mysqlbackups.done',
'cp -r /tmp/backups /var/tmp/mysqlbackups',
'touch /var/tmp/mysqlbackups.done',
],
execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
require => Package['bzip2'],
}
MANIFEST
it 'when configuring mysql backups with triggers and routines' do
execute_manifest(pp, catch_failures: true)
end

it 'runs mysqlbackup.sh with no errors' do
pre_run
unless version_is_greater_than('5.7.0')
shell('/usr/local/sbin/mysqlbackup.sh') do |r|
expect(r.stderr).to eq('')
end
end
end
end
end
40 changes: 0 additions & 40 deletions spec/acceptance/mysql_db_spec.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
require 'spec_helper_acceptance'

describe 'mysql::db define' do
describe 'creating a database' do
let(:pp) do
<<-MANIFEST
class { 'mysql::server': root_password => 'password' }
mysql::db { 'spec1':
user => 'root1',
password => 'password',
}
MANIFEST
end

it_behaves_like 'a idempotent resource'

describe command("mysql -e 'show databases;'") do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{^spec1$} }
end
end

describe 'creating a database with post-sql' do
let(:pp) do
<<-MANIFEST
Expand All @@ -44,25 +25,4 @@ class { 'mysql::server': override_options => { 'root_password' => 'password' } }
its(:stdout) { is_expected.to match %r{^table1$} }
end
end

describe 'creating a database with dbname parameter' do
let(:check_command) { ' | grep realdb' }
let(:pp) do
<<-MANIFEST
class { 'mysql::server': override_options => { 'root_password' => 'password' } }
mysql::db { 'spec1':
user => 'root1',
password => 'password',
dbname => 'realdb',
}
MANIFEST
end

it_behaves_like 'a idempotent resource'

describe command("mysql -e 'show databases;'") do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{^realdb$} }
end
end
end
48 changes: 0 additions & 48 deletions spec/acceptance/mysql_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,41 +46,6 @@ class { 'mysql::server':
it_behaves_like 'a idempotent resource'
end

describe 'minimal config' do
before(:all) do
@tmpdir = default.tmpdir('mysql')
end
# 'manage_config_file'/'service_enabled' being set to false can cause random failures in Debian 9
let(:os_variant) do
if fact('operatingsystem') =~ %r{Debian} && fact('operatingsystemrelease') =~ %r{^9\.}
'true'
else
'false'
end
end
let(:pp) do
<<-MANIFEST
class { 'mysql::server':
manage_config_file => '#{os_variant}',
override_options => { 'mysqld' => { 'key_buffer_size' => '32M' }},
package_ensure => 'present',
purge_conf_dir => 'false',
remove_default_accounts => 'false',
restart => 'false',
root_group => 'root',
root_password => 'test',
service_enabled => '#{os_variant}',
service_manage => 'false',
users => {},
grants => {},
databases => {},
}
MANIFEST
end

it_behaves_like 'a idempotent resource'
end

describe 'syslog configuration' do
let(:pp) do
<<-MANIFEST
Expand All @@ -92,17 +57,4 @@ class { 'mysql::server':

it_behaves_like 'a idempotent resource'
end

context 'when changing the password' do
let(:password) { 'THE NEW SECRET' }
let(:pp) { "class { 'mysql::server': root_password => '#{password}' }" }

it 'does not display the password' do
result = execute_manifest(pp, catch_failures: true)
# this does not actually prove anything, as show_diff in the puppet config defaults to false.
expect(result.stdout).not_to match %r{#{password}}
end

it_behaves_like 'a idempotent resource'
end
end
2 changes: 1 addition & 1 deletion spec/acceptance/sql_task_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# run a test task
require 'spec_helper_acceptance'

describe 'mysql tasks', if: puppet_version =~ %r{(5\.\d\.\d)} && fact('operatingsystem') != 'SLES' do
describe 'mysql tasks', if: puppet_version =~ %r{(5\.\d\.\d)} && os[:family] != 'sles' do
describe 'execute some sql' do
pp = <<-MANIFEST
class { 'mysql::server': root_password => 'password' }
Expand Down
3 changes: 1 addition & 2 deletions spec/acceptance/types/mysql_database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class { 'mysql::server': }
}
MANIFEST
it 'creates two db of different types idempotently' do
execute_manifest(pp, catch_failures: true)
execute_manifest(pp, catch_changes: true)
idempotent_apply(default, pp, {})
end

it 'finds latin1 db #stdout' do
Expand Down
16 changes: 8 additions & 8 deletions spec/acceptance/types/mysql_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
# of mysql) have varying levels of support for plugins and have
# different plugins available. Choose a plugin that works or don't try
# to test plugins if not available.
if fact('osfamily') =~ %r{RedHat}
if fact('operatingsystemrelease') =~ %r{^5\.}
if fact('osfamily') == 'redhat'
if os[:release].to_i == 5
plugin = nil # Plugins not supported on mysql on RHEL 5
elsif fact('operatingsystemrelease') =~ %r{^6\.}
elsif os[:release].to_i == 6
plugin = 'example'
plugin_lib = 'ha_example.so'
elsif fact('operatingsystemrelease') =~ %r{^7\.}
elsif os[:release].to_i == 7
plugin = 'pam'
plugin_lib = 'auth_pam.so'
end
elsif fact('osfamily') =~ %r{Debian}
if fact('operatingsystem') =~ %r{Ubuntu}
if fact('operatingsystemrelease') =~ %r{^16\.04|^18\.04}
elsif fact('osfamily') == 'debian'
if os[:family] == 'ubuntu'
if os[:release] =~ %r{^16\.04|^18\.04}
# On Xenial running 5.7.12, the example plugin does not appear to be available.
plugin = 'validate_password'
plugin_lib = 'validate_password.so'
Expand All @@ -25,7 +25,7 @@
plugin_lib = 'ha_example.so'
end
end
elsif fact('osfamily') =~ %r{Suse}
elsif fact('osfamily') == 'suse'
plugin = nil # Plugin library path is broken on Suse http://lists.opensuse.org/opensuse-bugs/2013-08/msg01123.html
end

Expand Down
1 change: 0 additions & 1 deletion spec/classes/mysql_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

describe 'mysql::client' do
on_supported_os.each do |os, facts|
next if facts[:osfamily] == 'Archlinux'
context "on #{os}" do
let(:facts) do
facts.merge(root_home: '/root')
Expand Down
18 changes: 7 additions & 11 deletions spec/defines/mysql_db_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

it 'subscribes to database if sql script is given' do
params['sql'] = 'test_sql'
is_expected.to contain_mysql_database('test_db')
is_expected.to contain_exec('test_db-import').with_subscribe('Mysql_database[test_db]')
end

Expand All @@ -29,21 +30,19 @@
is_expected.to contain_exec('test_db-import').with_refreshonly(true)
end

it 'imports sql script on creation if enforcing #refreshonly' do
it 'imports sql script on creation' do
params.merge!('sql' => 'test_sql', 'enforce_sql' => true)
# ' if enforcing #refreshonly'
is_expected.to contain_exec('test_db-import').with_refreshonly(false)
end
it 'imports sql script on creation if enforcing #command' do
params.merge!('sql' => 'test_sql', 'enforce_sql' => true)
# 'if enforcing #command'
is_expected.to contain_exec('test_db-import').with_command('cat test_sql | mysql test_db')
end

it 'imports sql script with custom command on creation if enforcing #refreshonly' do
it 'imports sql script with custom command on creation ' do
params.merge!('sql' => 'test_sql', 'enforce_sql' => true, 'import_cat_cmd' => 'zcat')
# if enforcing #refreshonly
is_expected.to contain_exec('test_db-import').with_refreshonly(false)
end
it 'imports sql script with custom command on creation if enforcing #command' do
params.merge!('sql' => 'test_sql', 'enforce_sql' => true, 'import_cat_cmd' => 'zcat')
# if enforcing #command
is_expected.to contain_exec('test_db-import').with_command('zcat test_sql | mysql test_db')
end

Expand All @@ -55,9 +54,6 @@
it 'does not create database' do
params.merge!('ensure' => 'absent', 'host' => 'localhost')
is_expected.to contain_mysql_database('test_db').with_ensure('absent')
end
it 'does not create database user' do
params.merge!('ensure' => 'absent', 'host' => 'localhost')
is_expected.to contain_mysql_user('testuser@localhost').with_ensure('absent')
end

Expand Down
4 changes: 4 additions & 0 deletions spec/functions/mysql_password_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
is_expected.to run.with_params('password').and_return('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19')
end

it 'password should be String' do
is_expected.to run.with_params(123).and_raise_error(ArgumentError)
end

it 'converts an empty password into a empty string' do
is_expected.to run.with_params('').and_return('')
end
Expand Down
Loading