Skip to content

Commit

Permalink
fix tests on RHEL/CentOS 6, refs #118
Browse files Browse the repository at this point in the history
  • Loading branch information
fraenki committed Mar 6, 2020
1 parent 1866063 commit c987481
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
3 changes: 2 additions & 1 deletion data/RedHat-6.yaml → data/RedHat-6-family.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
galera::codership::bootstrap_command: 'service mysql start --wsrep_cluster_address=gcomm://'
galera::mariadb::bootstrap_command: 'service mysql start --wsrep_cluster_address=gcomm://'
galera::percona::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
# No systemd on CentOS/RHEL 6
galera::percona::55::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
galera::percona::56::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
galera::percona::57::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
galera::percona::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
6 changes: 6 additions & 0 deletions data/RedHat-family-6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
# No systemd on CentOS/RHEL 6
galera::percona::55::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
galera::percona::56::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
galera::percona::57::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
galera::percona::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
11 changes: 7 additions & 4 deletions hiera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ hierarchy:
- name: 'Set important hiera options'
path: "hiera_options.yaml"

- name: 'Full Version'
- name: 'Distribution Full Version'
path: '%{facts.os.name}-%{facts.os.release.full}.yaml'

- name: 'Major Version'
- name: 'Distribution Major Version'
path: '%{facts.os.name}-%{facts.os.release.major}.yaml'

- name: 'Distribution Name'
path: '%{facts.os.name}.yaml'

- name: 'Operating System Family'
- name: 'OS Family Major Version'
path: '%{facts.os.family}-%{facts.os.release.major}-family.yaml'

- name: 'OS Family'
path: '%{facts.os.family}-family.yaml'

- name: 'Operating System Kernel'
- name: 'OS Kernel'
path: '%{facts.kernel}.yaml'

- name: 'common'
Expand Down
9 changes: 9 additions & 0 deletions spec/acceptance/galera_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
describe 'default parameters' do
let(:pp) do
<<-MANIFEST
# Workaround a known issue on CentOS 6, see https://tickets.puppetlabs.com/browse/MODULES-5653
if ($facts['os']['family'] == 'RedHat') and (versioncmp($facts['os']['release']['major'], '7') < 0) {
exec { 'create empty iptables configs':
path => '/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin:/usr/local/sbin',
command => 'touch /etc/sysconfig/iptables; touch /etc/sysconfig/ip6tables',
before => Class['firewall'],
}
}
# Setup firewall package and service, otherwise adding firewall
# rules will fail.
class { 'firewall': }
Expand Down
15 changes: 15 additions & 0 deletions spec/classes/galera_redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
it { is_expected.to contain_service('mysql@bootstrap') }
end

context 'when node is the master' do
before(:each) { params.merge!(galera_master: facts[:fqdn]) }
it { is_expected.to contain_exec('bootstrap_galera_cluster').with_command(%r{systemctl start [email protected]}) }
end

context 'when installing mariadb' do
before(:each) { params.merge!(vendor_type: 'mariadb', vendor_version: '10.3') }

Expand All @@ -43,6 +48,14 @@
end
end

shared_examples_for 'galera on RedHat 6' do
context 'when node is the master' do
before(:each) { params.merge!(galera_master: facts[:fqdn]) }
it { is_expected.to contain_exec('bootstrap_galera_cluster').with_command(%r{/etc/init.d/mysql bootstrap-pxc}) }
end

end

on_supported_os.each do |os, facts|
context "on #{os}" do # rubocop:disable RSpec/EmptyExampleGroup
let(:facts) do
Expand All @@ -59,6 +72,8 @@
when 'RedHat'
if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '7') >= 0
it_configures 'galera on RedHat'
elsif facts[:operatingsystemmajrelease] == '6'
it_configures 'galera on RedHat 6'
end
end
end
Expand Down

0 comments on commit c987481

Please sign in to comment.