Skip to content

Commit

Permalink
(maint) fix mysql_login_path acceptance tests on arm
Browse files Browse the repository at this point in the history
* remove the x86_64 binaries that should not have been added to the repo
* mysql_login_path is not supported by MariaDB so skip related tests if
  the test host doesn't have the binary.
  • Loading branch information
h0tw1r3 committed May 4, 2024
1 parent 459be93 commit 33211ed
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ If required, the password can also be an empty string to allow connections witho

### Create login paths

This feature works only for the MySQL Community Edition >= 5.6.6.
This feature works only for the MySQL Community Edition >= 5.6.6, [not MariaDB](https://mariadb.com/kb/en/mysql_config_editor-compatibility/).

A login path is a set of options (host, user, password, port and socket) that specify which MySQL server to connect to and which account to authenticate as. The authentication credentials and the other options are stored in an encrypted login file named .mylogin.cnf typically under the users home directory.

Expand Down
101 changes: 50 additions & 51 deletions spec/acceptance/types/mysql_login_path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

require 'spec_helper_acceptance'

support_bin_dir = '/root/mysql_login_path'
mysql_version = if (os[:family] == 'redhat' && os[:release].to_i == 8) || (os[:family] == 'debian' && os[:release] =~ %r{9|10|11})
'8.0'
elsif os[:family] == 'ubuntu' && os[:release] =~ %r{18\.04|20\.04}
'5.7'
else
'5.6'
end
describe 'mysql_login_path' do
begin
# mysql_config_editor is not supported on mariadb
# all tests should be skipped
run_shell('mysql_config_editor -V')
rescue
return
end

describe 'mysql_login_path', unless: "#{os[:family]}-#{os[:release].to_i}".include?('suse') do
before(:all) do
run_shell("rm -rf #{support_bin_dir}")
bolt_upload_file('spec/support/mysql_login_path', support_bin_dir)
run_shell("cp #{support_bin_dir}/mysql-#{mysql_version}/my_print_defaults /usr/bin/.")
run_shell("cp #{support_bin_dir}/mysql-#{mysql_version}/mysql_config_editor /usr/bin/.")
let(:base_pp) do
<<-MANIFEST
user { 'loginpath_test':
ensure => present,
managehome => true,
}
MANIFEST
end

after(:all) do
Expand All @@ -29,36 +30,13 @@
}
MANIFEST
apply_manifest(pp_cleanup, catch_failures: true)
run_shell("rm -rf #{support_bin_dir}")
end

describe 'setup' do
pp = <<-MANIFEST
user { 'loginpath_test':
ensure => present,
managehome => true,
}
MANIFEST
it 'works with no errors' do
apply_manifest(pp, catch_failures: true)
end

it 'finds mysql_config_editor binary for the provider' do
run_shell('mysql_config_editor -V') do |r|
expect(r.stdout).to match(%r{Ver.*#{mysql_version}.*x86_64})
end
end

it 'finds my_print_defaults binary for the provider' do
run_shell('my_print_defaults -V') do |r|
expect(r.exit_status).to eq(0)
end
end
end

context 'for user root' do
describe 'add login path' do
pp = <<-MANIFEST
let(:pp) do
<<-MANIFEST
#{base_pp}
mysql_login_path { 'local_socket':
owner => root,
host => 'localhost',
Expand All @@ -75,7 +53,9 @@
port => 3306,
ensure => present,
}
MANIFEST
MANIFEST
end

it 'works without errors' do
apply_manifest(pp, catch_failures: true)
end
Expand All @@ -102,7 +82,9 @@
end

describe 'update login path' do
pp = <<-MANIFEST
let(:pp) do
<<-MANIFEST
#{base_pp}
mysql_login_path { 'local_tcp-root':
owner => root,
host => '10.0.0.1',
Expand All @@ -111,13 +93,18 @@
port => 3307,
ensure => present,
}
MANIFEST
pp2 = <<-MANIFEST
MANIFEST
end

let(:pp2) do
<<-MANIFEST
mysql_login_path { 'local_tcp-root':
ensure => present,
host => '192.168.0.1'
}
MANIFEST
MANIFEST
end

it 'works without errors' do
apply_manifest(pp, catch_failures: true)
end
Expand Down Expand Up @@ -193,7 +180,9 @@

context 'for user loginpath_test' do
describe 'add login path' do
pp = <<-MANIFEST
let(:pp) do
<<-MANIFEST
#{base_pp}
mysql_login_path { 'local_tcp':
owner => loginpath_test,
host => '10.0.0.2',
Expand All @@ -202,7 +191,9 @@
port => 3306,
ensure => present,
}
MANIFEST
MANIFEST
end

it 'works without errors' do
apply_manifest(pp, catch_failures: true)
end
Expand All @@ -225,15 +216,19 @@
end

describe 'update login path' do
pp = <<-MANIFEST
let(:pp) do
<<-MANIFEST
#{base_pp}
mysql_login_path { 'local_tcp-loginpath_test':
host => '10.0.0.3',
user => 'other2',
password => Sensitive('password'),
port => 3307,
ensure => present,
}
MANIFEST
MANIFEST
end

it 'works without errors' do
apply_manifest(pp, catch_failures: true)
end
Expand All @@ -256,12 +251,16 @@
end

describe 'delete login path' do
pp = <<-MANIFEST
let(:pp) do
<<-MANIFEST
#{base_pp}
mysql_login_path { 'local_tcp':
owner => loginpath_test,
ensure => absent,
}
MANIFEST
MANIFEST
end

it 'works without errors' do
apply_manifest(pp, catch_failures: true)
end
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 33211ed

Please sign in to comment.