Skip to content

Commit

Permalink
Merge pull request #216 from voxpupuli/fix-tests
Browse files Browse the repository at this point in the history
Fix tests, drop support for proxysql versions < 2.2
  • Loading branch information
bastelfreak authored Nov 1, 2024
2 parents 9026b1a + cda2710 commit 6ca41d5
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 154 deletions.
13 changes: 2 additions & 11 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The module requires Puppet 5.5.8 and above. It also depends on:
* [puppetlabs/mysql](https://forge.puppet.com/puppetlabs/mysql)
* [puppetlabs/apt](https://forge.puppet.com/puppetlabs/apt) - (Not strictly required on non Debian based systems)
* [puppetlabs/stdlib](https://forge.puppet.com/puppetlabs/stdlib)
* [camptocamp/systemd](https://forge.puppet.com/camptocamp/systemd) - (Not strictly required if installing ProxySQL 1.4)
* [camptocamp/systemd](https://forge.puppet.com/camptocamp/systemd)

For up to date details on external dependencies, please see the [metadata.json](https://github.com/voxpupuli/puppet-proxysql/blob/master/metadata.json) or for released versions, the [puppet forge page](https://forge.puppet.com/puppet/proxysql/dependencies).

Expand All @@ -48,18 +48,9 @@ include proxysql
```

By default, packages come from the official upstream package repositories which the module will configure.
On new installations, (by default), the 2.0.x repository will be configured. If ProxySQL is already installed, then the repository matching the currently installed version
On new installations, (by default), the 2.7.x repository will be configured. If ProxySQL is already installed, then the repository matching the currently installed version
will be used.

To force the use of 1.4.x packages, use the `version` parameter. (Note, the example below does not force the installation of `1.4.16`, it only ensures the correct repository
is configured and that ProxySQL will be configured as if the version installed is `1.4.16`)

```puppet
class { 'proxysql':
version => '1.4.16',
}
```

To use your Operating System's own packages set `manage_repo => false`.

```puppet
Expand Down
2 changes: 1 addition & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ Data type: `Pattern[/^[1|2]\.\d+\.\d+/]`

The version of proxysql being managed. This parameter affects the repository configured when `manage_repo == true` and how the service is managed.
It does not affect the package version being installed. It is used as a hint to the puppet module on how to configure proxysql. To control the exact version
deployed, use `package_name` or `package_source`. Currently defaults to '2.0.7' or the value of the `proxysql_version` fact.
deployed, use `package_name` or `package_source`. Currently defaults to '2.7.1' or the value of the `proxysql_version` fact.

Default value: `$proxysql::params::version`

Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
# @param version
# The version of proxysql being managed. This parameter affects the repository configured when `manage_repo == true` and how the service is managed.
# It does not affect the package version being installed. It is used as a hint to the puppet module on how to configure proxysql. To control the exact version
# deployed, use `package_name` or `package_source`. Currently defaults to '2.0.7' or the value of the `proxysql_version` fact.
# deployed, use `package_name` or `package_source`. Currently defaults to '2.7.1' or the value of the `proxysql_version` fact.
# @param package_source
# location of a proxysql package. When specified, this package will be installed with the `package\_provider` and the `manage_repo` setting will be ignored.
# Since version 4 of this module, this defaults to `undef` and needs to be specified when you don't want to use a package from a repository.
Expand Down
106 changes: 53 additions & 53 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,68 +9,68 @@
$package_provider = 'dpkg'
$package_dependencies = []

if versioncmp(fact('os.release.major'), '18.04') >= 0 {
if versioncmp(fact('os.release.major'), '18.04') == 0 {
# The 2.0.x systemd service file in ubuntu 18.04 has `ReadWritePaths=/var/lib/proxysql /var/run/proxysql`.
# This limits where we can write sockets.
$_listen_socket = "${datadir}/proxysql.sock"
$_admin_listen_socket = "${datadir}/proxysql_admin.sock"
}

$repo14 = {
comment => 'ProxySQL 1.4.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/${facts['os']['distro']['codename']}/",
$repo22 = {
comment => 'ProxySQL 2.2.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-2.2.x/${facts['os']['distro']['codename']}/",
release => './',
repos => '',
repos => ' ',
key => {
'id' => '1448BF693CA600C799EB935804A562FB79953B49',
'server' => 'keyserver.ubuntu.com',
},
}
$repo20 = {
comment => 'ProxySQL 2.0.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-2.0.x/${facts['os']['distro']['codename']}/",
$repo23 = {
comment => 'ProxySQL 2.3.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-2.3.x/${facts['os']['distro']['codename']}/",
release => './',
repos => '',
repos => ' ',
key => {
'id' => '1448BF693CA600C799EB935804A562FB79953B49',
'server' => 'keyserver.ubuntu.com',
},
}
$repo21 = {
comment => 'ProxySQL 2.1.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-2.1.x/${facts['os']['distro']['codename']}/",
$repo24 = {
comment => 'ProxySQL 2.4.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-2.4.x/${facts['os']['distro']['codename']}/",
release => './',
repos => '',
repos => ' ',
key => {
'id' => '1448BF693CA600C799EB935804A562FB79953B49',
'id' => '653F85BB38256DF8A96206C3E8CA2E8D8217C97E',
'server' => 'keyserver.ubuntu.com',
},
}
$repo22 = {
comment => 'ProxySQL 2.2.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-2.2.x/${facts['os']['distro']['codename']}/",
$repo25 = {
comment => 'ProxySQL 2.5.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-2.5.x/${facts['os']['distro']['codename']}/",
release => './',
repos => '',
repos => ' ',
key => {
'id' => '1448BF693CA600C799EB935804A562FB79953B49',
'id' => '653F85BB38256DF8A96206C3E8CA2E8D8217C97E',
'server' => 'keyserver.ubuntu.com',
},
}
$repo23 = {
comment => 'ProxySQL 2.3.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-2.3.x/${facts['os']['distro']['codename']}/",
$repo26 = {
comment => 'ProxySQL 2.6.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-2.6.x/${facts['os']['distro']['codename']}/",
release => './',
repos => '',
repos => ' ',
key => {
'id' => '1448BF693CA600C799EB935804A562FB79953B49',
'id' => '653F85BB38256DF8A96206C3E8CA2E8D8217C97E',
'server' => 'keyserver.ubuntu.com',
},
}
$repo24 = {
comment => 'ProxySQL 2.4.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-2.4.x/${facts['os']['distro']['codename']}/",
$repo27 = {
comment => 'ProxySQL 2.7.x APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-2.7.x/${facts['os']['distro']['codename']}/",
release => './',
repos => '',
repos => ' ',
key => {
'id' => '653F85BB38256DF8A96206C3E8CA2E8D8217C97E',
'server' => 'keyserver.ubuntu.com',
Expand All @@ -84,30 +84,6 @@
'2016' => '6',
default => $facts['os']['release']['major'],
}
$repo14 = {
name => 'proxysql_1_4',
descr => 'ProxySQL 1.4.x YUM repository',
baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/${repo_os_major_version}",
enabled => true,
gpgcheck => true,
gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key',
}
$repo20 = {
name => 'proxysql_2_0',
descr => 'ProxySQL 2.0.x YUM repository',
baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-2.0.x/centos/${repo_os_major_version}",
enabled => true,
gpgcheck => true,
gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key',
}
$repo21 = {
name => 'proxysql_2_1',
descr => 'ProxySQL 2.1.x YUM repository',
baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-2.1.x/centos/${repo_os_major_version}",
enabled => true,
gpgcheck => true,
gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key',
}
$repo22 = {
name => 'proxysql_2_2',
descr => 'ProxySQL 2.2.x YUM repository',
Expand All @@ -132,6 +108,30 @@
gpgcheck => true,
gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key',
}
$repo25 = {
name => 'proxysql_2_5',
descr => 'ProxySQL 2.5.x YUM repository',
baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-2.5.x/centos/${repo_os_major_version}",
enabled => true,
gpgcheck => true,
gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key',
}
$repo26 = {
name => 'proxysql_2_6',
descr => 'ProxySQL 2.6.x YUM repository',
baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-2.6.x/centos/${repo_os_major_version}",
enabled => true,
gpgcheck => true,
gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key',
}
$repo27 = {
name => 'proxysql_2_7',
descr => 'ProxySQL 2.7.x YUM repository',
baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-2.7.x/centos/${repo_os_major_version}",
enabled => true,
gpgcheck => true,
gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key',
}
}
default: {
fail("osfamily ${facts['os']['family']} is not supported")
Expand All @@ -143,7 +143,7 @@
} else {
$short_proxysql_version_fact = undef
}
$version = pick($short_proxysql_version_fact,'2.0.7')
$version = pick($short_proxysql_version_fact,'2.7.1')

$listen_socket = pick(getvar('_listen_socket'),'/tmp/proxysql.sock')
$admin_listen_socket = pick(getvar('_admin_listen_socket'),'/tmp/proxysql_admin.sock')
Expand Down
26 changes: 13 additions & 13 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

if $proxysql::manage_repo and !$proxysql::package_source {
$repo = $proxysql::version ? {
/^2\.7\./ => $proxysql::params::repo27,
/^2\.6\./ => $proxysql::params::repo26,
/^2\.5\./ => $proxysql::params::repo25,
/^2\.4\./ => $proxysql::params::repo24,
/^2\.3\./ => $proxysql::params::repo23,
/^2\.2\./ => $proxysql::params::repo22,
/^2\.1\./ => $proxysql::params::repo21,
/^2\.0\./ => $proxysql::params::repo20,
/^1\.4\./ => $proxysql::params::repo14,
default => fail("Unsupported `proxysql::version` ${proxysql::version}")
}
case $facts['os']['family'] {
Expand All @@ -27,28 +27,28 @@
}

# Purge old/unnecessary repos.
if ($proxysql::version !~ /^2\.3\./) {
yumrepo { $proxysql::params::repo23['name']:
if ($proxysql::version !~ /^2\.6\./) {
yumrepo { $proxysql::params::repo26['name']:
ensure => absent,
}
}
if ($proxysql::version !~ /^2\.2\./) {
yumrepo { $proxysql::params::repo22['name']:
if ($proxysql::version !~ /^2\.5\./) {
yumrepo { $proxysql::params::repo25['name']:
ensure => absent,
}
}
if ($proxysql::version !~ /^2\.1\./) {
yumrepo { $proxysql::params::repo21['name']:
if ($proxysql::version !~ /^2\.4\./) {
yumrepo { $proxysql::params::repo24['name']:
ensure => absent,
}
}
if ($proxysql::version !~ /^2\.0\./) {
yumrepo { $proxysql::params::repo20['name']:
if ($proxysql::version !~ /^2\.3\./) {
yumrepo { $proxysql::params::repo23['name']:
ensure => absent,
}
}
if ($proxysql::version !~ /^1\.4\./) {
yumrepo { $proxysql::params::repo14['name']:
if ($proxysql::version !~ /^2\.2\./) {
yumrepo { $proxysql::params::repo22['name']:
ensure => absent,
}
}
Expand Down
6 changes: 4 additions & 2 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
notify => Service[$proxysql::service_name],
}
service { $proxysql::service_name:
ensure => $proxysql::service_ensure,
enable => true,
ensure => $proxysql::service_ensure,
enable => true,
hasrestart => true,
hasstatus => true,
}
} else {
if $proxysql::restart {
Expand Down
63 changes: 4 additions & 59 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,12 @@
require 'spec_helper_acceptance'

describe 'proxysql class' do
unless ['18.04', '20.04'].include?(fact('os.release.major')) ||
(fact('os.name') == 'Debian' && fact('os.release.major') == '10') # There are no proxysql 1.4 packages for these OSes
context 'version 1.4' do
it 'works idempotently with no errors' do
pp = <<-EOS
class { 'proxysql':
version => '1.4.16',
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe package('proxysql') do
it { is_expected.to be_installed }
end

describe service('proxysql') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe command('proxysql --version') do
its(:exit_status) { is_expected.to eq 0 }
its(:stderr) { is_expected.to match %r{^ProxySQL version 1\.4\.} }
end
end
end

context 'Upgrading to version 2.0' do
context 'Upgrading to version 2.7' do
it 'works idempotently with no errors' do
pp = <<-EOS
class { 'proxysql':
package_ensure => latest,
version => '2.0.7',
version => '2.7.1',
}
EOS

Expand All @@ -48,7 +17,7 @@ class { 'proxysql':
apply_manifest(pp, catch_changes: true)

# Run it again, this time relying on proxysql_version fact
apply_manifest('class { \'proxysql\':}', catch_changes: true)
apply_manifest("class { 'proxysql':}", catch_changes: true)
end

describe package('proxysql') do
Expand All @@ -62,7 +31,7 @@ class { 'proxysql':

describe command('proxysql --version') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{^ProxySQL version 2\.0\.} }
its(:stdout) { is_expected.to match %r{^ProxySQL version 2\.7\.} }
end
end

Expand All @@ -71,18 +40,6 @@ class { 'proxysql':
it 'works idempotently with no errors' do
pp = <<-EOS
class { 'proxysql':
listen_port => 3306,
admin_username => 'admin',
admin_password => Sensitive('654321'),
stats_username => 'stats',
stats_password => Sensitive('567890'),
monitor_username => 'monitor',
monitor_password => Sensitive('123456'),
override_config_settings => {
mysql_variables => {
'monitor_writer_is_also_reader' => false,
}
},
}
proxy_mysql_replication_hostgroup { '10-20':
Expand Down Expand Up @@ -353,18 +310,6 @@ class { 'proxysql':
pp = <<-EOS
class { 'proxysql':
restart => true,
listen_port => 3306,
admin_username => 'admin',
admin_password => Sensitive('654321'),
stats_username => 'stats',
stats_password => Sensitive('567890'),
monitor_username => 'monitor',
monitor_password => Sensitive('123456'),
override_config_settings => {
mysql_variables => {
'monitor_writer_is_also_reader' => true,
}
},
}
EOS
apply_manifest(pp, catch_failures: true)
Expand Down
Loading

0 comments on commit 6ca41d5

Please sign in to comment.