Skip to content

Commit

Permalink
Add support for mysqld_exporter version 0.11.0 (voxpupuli#247)
Browse files Browse the repository at this point in the history
Flags now use the Kingpin library, and require double-dashes. prometheus/mysqld_exporter#222
  • Loading branch information
TheMeier authored and alexjfisher committed Aug 22, 2018
1 parent 6855851 commit 2ce385e
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
7 changes: 5 additions & 2 deletions manifests/mysqld_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@
notify => $notify_service,
}

$options = "-config.my-cnf=${cnf_config_path} ${extra_options}"

if versioncmp($version, '0.11.0') < 0 {
$options = "-config.my-cnf=${cnf_config_path} ${extra_options}"
} else {
$options = "--config.my-cnf=${cnf_config_path} ${extra_options}"
}
prometheus::daemon { 'mysqld_exporter':
install_method => $install_method,
version => $version,
Expand Down
38 changes: 38 additions & 0 deletions spec/acceptance/mysqld_exporter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'spec_helper_acceptance'

describe 'prometheus mysqld exporter' do
it 'mysqld_exporter works idempotently with no errors' do
if default[:platform] =~ %r{ubuntu-18.04-amd64}
pp = "package{'iproute2': ensure => present}"
apply_manifest(pp, catch_failures: true)
end
pp = 'include prometheus::mysqld_exporter'
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe 'default install' do
describe service('mysqld_exporter') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end
# the class installs an the mysqld_exporter that listens on port 9104
describe port(9104) do
it { is_expected.to be_listening.with('tcp6') }
end
describe process('mysqld_exporter') do
its(:args) { is_expected.to match %r{\ -config.my-cnf} }
end
end

describe 'update prometheus mysqld exporter' do
it 'update mysqld_exporter to 0.11.0' do
pp = "class {'prometheus::mysqld_exporter': version => '0.11.0' }"
apply_manifest(pp, catch_failures: true)
end
describe process('mysqld_exporter') do
its(:args) { is_expected.to match %r{\ --config.my-cnf} }
end
end
end
29 changes: 29 additions & 0 deletions spec/classes/mysqld_exporter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'spec_helper'

describe 'prometheus::mysqld_exporter' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge(os_specific_facts(facts))
end

context 'default' do
describe 'options is correct' do
it { is_expected.to contain_prometheus__daemon('mysqld_exporter').with('options' => '-config.my-cnf=/etc/.my.cnf ') }
end
end

context 'with version >= 0.11.0' do
let(:params) do
{
version: '0.11.0'
}
end

describe 'options is correct' do
it { is_expected.to contain_prometheus__daemon('mysqld_exporter').with('options' => '--config.my-cnf=/etc/.my.cnf ') }
end
end
end
end
end

0 comments on commit 2ce385e

Please sign in to comment.