Skip to content

Commit

Permalink
revive some unit tests, refs #108
Browse files Browse the repository at this point in the history
  • Loading branch information
fraenki committed Feb 19, 2020
1 parent 1902fb3 commit 469bd45
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 83 deletions.
7 changes: 5 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ The following parameters are available in the `galera` class.
Data type: `Optional[Array]`

Specifies a list of additional packages that may be required for SST and
other features. Default: A vendor-, version- and OS-specific value.
other features. The module automatically discovers all additional packages
that are required for the selected vendor/sst, but this parameter can be
used to overwrite the discovered package list.
Default: A vendor-, version- and OS-specific value.

Default value: `undef`

Expand Down Expand Up @@ -158,7 +161,7 @@ puppetlabs-firewall. Default: `true`

Data type: `Boolean`

Specifies wether to configure additional repositories that are requird for
Specifies wether to configure additional repositories that are required for
installing galera. Default: `true`

##### `create_root_my_cnf`
Expand Down
1 change: 1 addition & 0 deletions spec/classes/galera_arbitrator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

it { is_expected.to compile.with_all_deps }
it { is_expected.not_to contain_class('mysql::server') }
it { is_expected.to contain_class('galera::arbitrator') }
it { is_expected.to contain_package('galera-arbitrator') }

it { is_expected.to contain_service('arbitrator-service').with_enable(true) }
Expand Down
152 changes: 71 additions & 81 deletions spec/classes/galera_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
root_password: 'test',
override_options: {},
vendor_type: 'percona',
vendor_version: '5.7',
configure_repo: true,
configure_firewall: true,
deb_sysmaint_password: 'sysmaint',
Expand All @@ -28,20 +29,20 @@
end

shared_examples_for 'galera' do
context 'with default parameters' do
context 'with default parameters (percona)' do
it { is_expected.to contain_class('galera::repo') }
it { is_expected.to contain_class('galera::firewall') }

# FIXME: package names/versions need to be reworked
# it { should contain_class('mysql::server').wit(
# :package_name => os_params[:p_mysql_package_name],
# :root_password => params[:root_password],
# :service_name => os_params[:mysql_service_name]
# ) }
it {
is_expected.to contain_class('mysql::server').with(
package_name: os_params[:p_mysql_package_name],
root_password: params[:root_password],
service_name: os_params[:p_mysql_service_name],
)
}

# FIXME: package names/versions need to be reworked
# it { should contain_package(os_params[:p_galera_package_name]).with(:ensure => 'present') }
# it { should contain_package(os_params[:p_additional_packages]).with(:ensure => 'installed') }
it { is_expected.to contain_package(os_params[:p_galera_package_name]).with(ensure: 'present') }
it { is_expected.to contain_package(os_params[:p_additional_packages]).with(ensure: 'installed') }

it { is_expected.to contain_class('mysql::server') }

Expand All @@ -66,27 +67,32 @@
end

context 'when installing mariadb' do
before(:each) { params.merge!(vendor_type: 'mariadb') }
# FIXME: package names/versions need to be reworked
# it { should contain_class('mysql::server').with(
# :package_name => os_params[:m_mysql_package_name],
# :root_password => params[:root_password],
# :service_name => os_params[:mysql_service_name]
# ) }
before(:each) { params.merge!(vendor_type: 'mariadb',vendor_version: '10.3') }
it {
should contain_class('mysql::server').with(
package_name: os_params[:m_mysql_package_name],
root_password: params[:root_password],
service_name: os_params[:m_mysql_service_name]
)
}
it { is_expected.to contain_class('mysql::server') }

# it { should contain_package(os_params[:m_galera_package_name]).with(:ensure => 'installed') }
it { is_expected.to contain_package(os_params[:m_additional_packages]).with(ensure: 'installed') }
end

# FIXME: package names/versions need to be reworked
# context 'when using xtrabackup-v2' do
# before { params.merge!( :wsrep_sst_method => 'xtrabackup-v2' ) }
# it { should contain_package(os_params[:p_xtrabackup_package]).with(:ensure => 'installed') }
# end
context 'when using xtrabackup' do
before { params.merge!( :wsrep_sst_method => 'xtrabackup' ) }
it { should contain_package(os_params[:p_xtrabackup_package]).with(:ensure => 'installed') }
end

context 'when using xtrabackup-v2' do
before { params.merge!( :wsrep_sst_method => 'xtrabackup-v2' ) }
it { should contain_package(os_params[:p_xtrabackup_package]).with(:ensure => 'installed') }
end

context 'when using mariabackup' do
before(:each) { params.merge!(vendor_type: 'mariadb', wsrep_sst_method: 'mariabackup') }
before(:each) { params.merge!(vendor_type: 'mariadb', vendor_version: '10.3',wsrep_sst_method: 'mariabackup') }
it { is_expected.to contain_package(os_params[:m_mariadb_backup_package_name]).with_ensure('installed') }
it { is_expected.to contain_package('socat').with_ensure('installed') }
end
Expand Down Expand Up @@ -135,7 +141,7 @@
# it { should contain_class('mysql::server').with(
# :package_name => os_params[:c_mysql_package_name],
# :root_password => params[:root_password],
# :service_name => os_params[:mysql_service_name]
# :service_name => os_params[:c_mysql_service_name]
# ) }
it { is_expected.to contain_class('mysql::server') }

Expand All @@ -152,7 +158,7 @@
is_expected.to contain_class('mysql::server').with(
package_name: 'mysql-package-test',
root_password: params[:root_password],
service_name: os_params[:mysql_service_name],
service_name: os_params[:p_mysql_service_name],
)
}

Expand Down Expand Up @@ -189,66 +195,50 @@

let(:os_params) do
if facts[:osfamily] == 'RedHat'
{ p_mysql_package_name: 'Percona-XtraDB-Cluster-server-55',
p_galera_package_name: 'Percona-XtraDB-Cluster-galera-2',
p_client_package_name: 'Percona-XtraDB-Cluster-client-55',
p_libgalera_location: '/usr/lib64/libgalera_smm.so',
p_additional_packages: 'rsync',
p_xtrabackup_package: 'percona-xtrabackup',
m_mysql_package_name: 'MariaDB-Galera-server',
m_galera_package_name: 'galera',
{ c_additional_packages: 'rsync',
c_client_package_name: 'mysql-wsrep-client-5.7',
c_galera_package_name: 'galera-3',
c_libgalera_location: '/usr/lib64/galera-3/libgalera_smm.so',
c_mysql_package_name: 'mysql-wsrep-5.7',
c_mysql_service_name: 'mysql',
m_additional_packages: 'rsync',
m_client_package_name: 'MariaDB-client',
m_galera_package_name: 'galera',
m_libgalera_location: '/usr/lib64/galera/libgalera_smm.so',
m_additional_packages: 'rsync',
c_mysql_package_name: 'mysql-wsrep-5.5',
m_mariadb_backup_package_name: 'MariaDB-backup',
m_mysql_package_name: 'MariaDB-server',
m_mysql_service_name: 'mariadb',
p_additional_packages: 'rsync',
p_client_package_name: 'Percona-XtraDB-Cluster-client-57',
p_galera_package_name: 'Percona-XtraDB-Cluster-galera-3',
p_libgalera_location: '/usr/lib64/libgalera_smm.so',
p_mysql_package_name: 'Percona-XtraDB-Cluster-server-57',
p_mysql_service_name: 'mysql',
p_xtrabackup_package: 'percona-xtrabackup-24',
nmap_package_name: 'nmap' }
elsif facts[:osfamily] == 'Debian'
{ c_additional_packages: 'rsync',
c_client_package_name: 'mysql-wsrep-client-5.7',
c_galera_package_name: 'galera-3',
c_client_package_name: 'mysql-wsrep-client-5.5',
c_libgalera_location: '/usr/lib64/galera-3/libgalera_smm.so',
c_additional_packages: 'rsync',
c_libgalera_location: '/usr/lib/libgalera_smm.so',
c_mysql_package_name: 'mysql-wsrep-5.7',
c_mysql_service_name: 'mysql',
m_additional_packages: 'rsync',
m_client_package_name: 'mariadb-client-10.3',
m_galera_package_name: 'mariadb',
m_libgalera_location: '/usr/lib/galera/libgalera_smm.so',
m_mariadb_backup_package_name: 'mariadb-backup',
m_mysql_package_name: 'mariadb-server-10.3',
m_mysql_service_name: 'mysql',
p_additional_packages: 'rsync',
p_client_package_name: 'percona-xtradb-cluster-client-5.7',
p_galera_package_name: 'percona-xtradb-cluster-galera-3.x',
p_libgalera_location: '/usr/lib/galera/libgalera_smm.so',
p_mysql_package_name: 'percona-xtradb-cluster-server-5.7',
p_mysql_service_name: 'mysql',
p_xtrabackup_package: 'percona-xtrabackup-24',
mysql_service_name: 'mysql',
m_mariadb_backup_package_name: 'MariaDB-backup' }
elsif facts[:osfamily] == 'Debian'
if facts[:os]['release']['major'] == '8'
{
p_mysql_package_name: 'percona-xtradb-cluster-server-5.5',
p_galera_package_name: 'percona-xtradb-cluster-galera-2.x',
p_client_package_name: 'percona-xtradb-cluster-client-5.5',
p_libgalera_location: '/usr/lib/libgalera_smm.so',
p_additional_packages: 'rsync',
p_xtrabackup_package: 'percona-xtrabackup',
m_mysql_package_name: 'mariadb-galera-server-5.5',
m_galera_package_name: 'galera',
m_client_package_name: 'mariadb-client-5.5',
m_libgalera_location: '/usr/lib/galera/libgalera_smm.so',
m_additional_packages: 'rsync',
c_mysql_package_name: 'mysql-wsrep-5.5',
c_galera_package_name: 'galera-3',
c_client_package_name: 'mysql-wsrep-client-5.5',
c_libgalera_location: '/usr/lib/libgalera_smm.so',
c_additional_packages: 'rsync',
mysql_service_name: 'mysql',
m_mariadb_backup_package_name: 'mariadb-backup',
} else {
p_mysql_package_name: 'percona-xtradb-cluster-server-5.7',
p_galera_package_name: 'percona-xtradb-cluster-galera-3.x',
p_client_package_name: 'percona-xtradb-cluster-client-5.7',
p_libgalera_location: '/usr/lib/libgalera_smm.so',
p_additional_packages: 'rsync',
p_xtrabackup_package: 'percona-xtrabackup-24',
m_mysql_package_name: 'mariadb-server-10.3',
m_galera_package_name: 'mariadb',
m_client_package_name: 'mariadb-client-10.3',
m_libgalera_location: '/usr/lib/galera/libgalera_smm.so',
m_additional_packages: 'rsync',
c_mysql_package_name: 'mysql-wsrep-5.7',
c_galera_package_name: 'galera-3',
c_client_package_name: 'mysql-wsrep-client-5.7',
c_libgalera_location: '/usr/lib/libgalera_smm.so',
c_additional_packages: 'rsync',
mysql_service_name: 'mysql',
m_mariadb_backup_package_name: 'mariadb-backup',
}
end
nmap_package_name: 'nmap' }
end
end

Expand Down

0 comments on commit 469bd45

Please sign in to comment.