Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for mysqld_exporter version 0.11.0 #247

Merged
merged 3 commits into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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