-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Refactor statsd_exporter class to support version >= 0.5.0; bump from 0.3.0->0.8.0 #271
Merged
bastelfreak
merged 3 commits into
voxpupuli:master
from
wiebe:statsd_exporter-0.5.0-and-up
Nov 2, 2018
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'prometheus statsd exporter' do | ||
it 'statsd_exporter works idempotently with no errors' do | ||
pp = 'include prometheus::statsd_exporter' | ||
# Run it twice and test for idempotency | ||
apply_manifest(pp, catch_failures: true) | ||
apply_manifest(pp, catch_changes: true) | ||
end | ||
|
||
describe 'prometheus statsd exporter version 0.5.0' do | ||
it ' statsd_exporter installs with version 0.5.0' do | ||
pp = "class {'prometheus::statsd_exporter': version => '0.5.0' }" | ||
# Run it twice and test for idempotency | ||
apply_manifest(pp, catch_failures: true) | ||
apply_manifest(pp, catch_changes: true) | ||
end | ||
describe process('statsd_exporter') do | ||
its(:args) { is_expected.to match %r{\ -statsd.mapping-config} } | ||
end | ||
describe service('statsd_exporter') do | ||
it { is_expected.to be_running } | ||
it { is_expected.to be_enabled } | ||
end | ||
describe port(9102) do | ||
it { is_expected.to be_listening.with('tcp6') } | ||
end | ||
describe port(9125) do | ||
it { is_expected.to be_listening.with('udp6') } | ||
end | ||
end | ||
|
||
describe 'prometheus statsd exporter version 0.7.0' do | ||
it ' statsd_exporter installs with version 0.7.0' do | ||
pp = "class {'prometheus::statsd_exporter': version => '0.7.0' }" | ||
# Run it twice and test for idempotency | ||
apply_manifest(pp, catch_failures: true) | ||
apply_manifest(pp, catch_changes: true) | ||
end | ||
describe process('statsd_exporter') do | ||
its(:args) { is_expected.to match %r{\ --statsd.mapping-config} } | ||
end | ||
describe service('statsd_exporter') do | ||
it { is_expected.to be_running } | ||
it { is_expected.to be_enabled } | ||
end | ||
describe port(9102) do | ||
it { is_expected.to be_listening.with('tcp6') } | ||
end | ||
describe port(9125) do | ||
it { is_expected.to be_listening.with('udp6') } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
require 'spec_helper' | ||
|
||
describe 'prometheus::statsd_exporter' do | ||
on_supported_os.each do |os, facts| | ||
context "on #{os}" do | ||
let(:facts) do | ||
facts.merge(os_specific_facts(facts)) | ||
end | ||
|
||
context 'with version specified' do | ||
let(:params) do | ||
{ | ||
version: '0.8.0', | ||
arch: 'amd64', | ||
os: 'linux', | ||
bin_dir: '/usr/local/bin', | ||
install_method: 'url', | ||
mappings: [ | ||
{ | ||
match: 'test.dispatcher.*.*.*', | ||
name: 'dispatcher_events_total', | ||
labels: { | ||
processor: '$1', | ||
action: '$2', | ||
outcome: '$3', | ||
job: 'test_dispatcher' | ||
} | ||
}, | ||
{ | ||
match: '*.signup.*.*', | ||
name: 'signup_events_total', | ||
labels: { | ||
provider: '$2', | ||
outcome: '$3', | ||
job: '${1}_server' | ||
} | ||
} | ||
] | ||
} | ||
end | ||
|
||
it { is_expected.to contain_archive('/tmp/statsd_exporter-0.8.0.tar.gz') } | ||
|
||
describe 'compile manifest' do | ||
it { is_expected.to compile.with_all_deps } | ||
end | ||
|
||
describe 'install correct binary' do | ||
it { is_expected.to contain_file('/usr/local/bin/statsd_exporter').with('target' => '/opt/statsd_exporter-0.8.0.linux-amd64/statsd_exporter') } | ||
end | ||
|
||
describe 'required resources' do | ||
it { is_expected.to contain_prometheus__daemon('statsd_exporter').with(options: "--statsd.mapping-config='/etc/statsd-exporter-mapping.yaml' ") } | ||
it { is_expected.to contain_user('statsd-exporter') } | ||
it { is_expected.to contain_group('statsd-exporter') } | ||
it { is_expected.to contain_service('statsd_exporter') } | ||
end | ||
|
||
describe 'mapping config file' do | ||
it { | ||
is_expected.to contain_file('/etc/statsd-exporter-mapping.yaml').with( | ||
'ensure' => 'file', | ||
'owner' => 'statsd-exporter', | ||
'group' => 'statsd-exporter', | ||
'mode' => '0660', | ||
'notify' => 'Service[statsd_exporter]', | ||
'content' => <<-YAML.gsub(%r{^\s+\|}, '') | ||
|--- | ||
|mappings: | ||
|- match: test.dispatcher.*.*.* | ||
| name: dispatcher_events_total | ||
| labels: | ||
| processor: "$1" | ||
| action: "$2" | ||
| outcome: "$3" | ||
| job: test_dispatcher | ||
|- match: "*.signup.*.*" | ||
| name: signup_events_total | ||
| labels: | ||
| provider: "$2" | ||
| outcome: "$3" | ||
| job: "${1}_server" | ||
YAML | ||
) | ||
} | ||
end | ||
end | ||
|
||
context 'with older version that does not support posix like option flags specified' do | ||
let(:params) do | ||
{ | ||
version: '0.6.0', | ||
arch: 'amd64', | ||
os: 'linux', | ||
bin_dir: '/usr/local/bin', | ||
install_method: 'url' | ||
} | ||
end | ||
|
||
describe 'compile manifest' do | ||
it { is_expected.to compile.with_all_deps } | ||
end | ||
|
||
it { is_expected.to contain_prometheus__daemon('statsd_exporter').with(options: "-statsd.mapping-config='/etc/statsd-exporter-mapping.yaml' ") } | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please keep the old version? Otherwise it would be a breaking change. We want to do that in a later release for all exporters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a breaking change anyways. The configuration format changed between v0.4.0 and v0.5.0. It won't download and configure v0.3.0 or older correctly, it would require more/duplicate logic to also support the old version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The style issues are fixed now and saw that i didn't see that versions older than v0.7.0 still used the single dash options so i added some logic for that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also did an experiment to see how difficult it would be to support older versions as well but it gets quite funky and i think more confusing with the different file format and names..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We did a release of this module a few days ago. In the current merge window we want to update all exporters, so this is fine now.