From 0ea083b643fc343e3fe9f9edefefb1543ad77355 Mon Sep 17 00:00:00 2001 From: Bryan Jen Date: Wed, 17 Aug 2016 09:55:33 -0700 Subject: [PATCH 1/2] (MODULES-3716) Fixes mysql_grant tests to create procedure before grant --- spec/acceptance/types/mysql_grant_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/acceptance/types/mysql_grant_spec.rb b/spec/acceptance/types/mysql_grant_spec.rb index 95ddec6..b985c63 100644 --- a/spec/acceptance/types/mysql_grant_spec.rb +++ b/spec/acceptance/types/mysql_grant_spec.rb @@ -2,14 +2,14 @@ require 'spec_helper_acceptance' describe 'mysql_grant' do - describe 'setup' do - it 'setup mysql::server' do - pp = <<-EOS - class { 'mysql::server': } - EOS + before(:all) do + pp = <<-EOS + class { 'mysql::server': + root_password => 'password', + } + EOS - apply_manifest(pp, :catch_failures => true) - end + apply_manifest(pp, :catch_failures => true) end describe 'missing privileges for user' do @@ -414,7 +414,7 @@ describe 'mysql_grant' do pp = <<-EOS if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemmajrelease, '16.00') > 0 { exec { 'simpleproc-create': - command => 'mysql --database=mysql --delimiter="//" -NBe "CREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN SELECT COUNT(*) INTO param1 FROM t; end//"', + command => 'mysql --user="root" --password="password" --database=mysql --delimiter="//" -NBe "CREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN SELECT COUNT(*) INTO param1 FROM t; end//"', path => '/usr/bin/', before => Mysql_user['test2@tester'], } From 561a6b067c40862bd49d382123b6e9b1500b93c9 Mon Sep 17 00:00:00 2001 From: Bryan Jen Date: Wed, 17 Aug 2016 13:48:09 -0700 Subject: [PATCH 2/2] (maint) clean up some tests and skip skip-name-resolve for now on 5.7+ --- spec/acceptance/mysql_backup_spec.rb | 11 +---------- spec/acceptance/mysql_helper.rb | 8 ++++++++ spec/acceptance/types/mysql_grant_spec.rb | 11 ++++++++--- 3 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 spec/acceptance/mysql_helper.rb diff --git a/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb index e5fcfd5..88a90cc 100644 --- a/spec/acceptance/mysql_backup_spec.rb +++ b/spec/acceptance/mysql_backup_spec.rb @@ -1,18 +1,9 @@ require 'spec_helper_acceptance' require 'puppet' require 'puppet/util/package' +require_relative './mysql_helper.rb' describe 'mysql::server::backup class' do - - def pre_run - apply_manifest("class { 'mysql::server': root_password => 'password' }", :catch_failures => true) - @mysql_version = (on default, 'mysql --version').output.chomp.match(/\d+\.\d+\.\d+/)[0] - end - - def version_is_greater_than(version) - return Puppet::Util::Package.versioncmp(@mysql_version, version) > 0 - end - context 'should work with no errors' do it 'when configuring mysql backups' do pp = <<-EOS diff --git a/spec/acceptance/mysql_helper.rb b/spec/acceptance/mysql_helper.rb new file mode 100644 index 0000000..7a5dd57 --- /dev/null +++ b/spec/acceptance/mysql_helper.rb @@ -0,0 +1,8 @@ + def pre_run + apply_manifest("class { 'mysql::server': root_password => 'password' }", :catch_failures => true) + @mysql_version = (on default, 'mysql --version').output.chomp.match(/\d+\.\d+\.\d+/)[0] + end + + def version_is_greater_than(version) + return Puppet::Util::Package.versioncmp(@mysql_version, version) > 0 + end diff --git a/spec/acceptance/types/mysql_grant_spec.rb b/spec/acceptance/types/mysql_grant_spec.rb index b985c63..ccf2b27 100644 --- a/spec/acceptance/types/mysql_grant_spec.rb +++ b/spec/acceptance/types/mysql_grant_spec.rb @@ -1,10 +1,12 @@ require 'spec_helper_acceptance' +require 'puppet' +require 'puppet/util/package' +require_relative '../mysql_helper.rb' describe 'mysql_grant' do - before(:all) do pp = <<-EOS - class { 'mysql::server': + class { 'mysql::server': root_password => 'password', } EOS @@ -484,7 +486,10 @@ describe 'mysql_grant' do end it 'should fail with fqdn' do - expect(shell("mysql -NBe \"SHOW GRANTS FOR test@fqdn.com\"", { :acceptable_exit_codes => 1}).stderr).to match(/There is no such grant defined for user 'test' on host 'fqdn.com'/) + pre_run + if ! version_is_greater_than('5.7.0') + expect(shell("mysql -NBe \"SHOW GRANTS FOR test@fqdn.com\"", { :acceptable_exit_codes => 1}).stderr).to match(/There is no such grant defined for user 'test' on host 'fqdn.com'/) + end end it 'finds ipv4' do shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'192.168.5.7'\"") do |r|