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

Update options flag for nginx-prometheus-exporter to new double dash format #816

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion manifests/nginx_prometheus_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@
default => undef,
}

$options = "-nginx.scrape-uri '${scrape_uri}' ${extra_options}"
if versioncmp($version, '1.0.0') >= 0 {
$options = "--nginx.scrape-uri '${scrape_uri}' ${extra_options}"
} else {
$options = "-nginx.scrape-uri '${scrape_uri}' ${extra_options}"
}

$extract_path = "/opt/${package_name}-${version}.${os}-${arch}"
$archive_bin_path = "${extract_path}/${bin_name}"
Expand Down
26 changes: 18 additions & 8 deletions spec/acceptance/nginx_prometheus_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,26 @@ class { 'prometheus::nginx_prometheus_exporter':
describe port(9113) do
it { is_expected.to be_listening.with('tcp6') }
end

# the describe process uses `ps -C` which truncates the cmd output to 15 characters on newer versions.
describe process('nginx-prometheu') do
its(:args) { is_expected.to match %r{\ -nginx.scrape-uri http://localhost:8888/stub_status} }
end
end

describe 'update to version >= 1.0.0' do
it 'uses double-dash arguments for version >= 1.0.0' do
pp = <<-EOS
class { 'prometheus::nginx_prometheus_exporter':
scrape_uri => 'http://localhost:8888/stub_status',
version => '1.2.0',
}
EOS
apply_manifest(pp, catch_failures: true)
end

if os == 'centos-7-x86_64'
describe process('nginx-prometheus-exporter') do
its(:args) { is_expected.to match %r{\ -nginx.scrape-uri http://localhost:8888/stub_status} }
end
else
describe process('nginx-prometheu') do
its(:args) { is_expected.to match %r{\ -nginx.scrape-uri http://localhost:8888/stub_status} }
end
describe process('nginx-prometheu') do
its(:args) { is_expected.to match %r{\ --nginx.scrape-uri http://localhost:8888/stub_status} }
end
end
end
15 changes: 15 additions & 0 deletions spec/classes/nginx_prometheus_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@
it { is_expected.to contain_file('/opt/nginx-prometheus-exporter-0.11.0.linux-amd64') }
end
end

context 'with version >= 1.0.0' do
let(:params) do
{
version: '1.2.0',
}
end

it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") }

describe 'install correct binary' do
it { is_expected.to contain_file('/usr/local/bin/nginx-prometheus-exporter').with('target' => '/opt/nginx-prometheus-exporter-1.2.0.linux-amd64/nginx-prometheus-exporter') }
it { is_expected.to contain_file('/opt/nginx-prometheus-exporter-1.2.0.linux-amd64') }
end
end
end
end
end
Loading