Skip to content

Commit

Permalink
Update test spec to reflect new flag format in expected result
Browse files Browse the repository at this point in the history
  • Loading branch information
lbdemv authored and TheMeier committed Jan 12, 2025
1 parent b34a313 commit c94d990
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
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
4 changes: 2 additions & 2 deletions spec/classes/nginx_prometheus_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
it { is_expected.to contain_class('prometheus') }
it { is_expected.to contain_group('nginx-prometheus-exporter') }
it { is_expected.to contain_user('nginx-prometheus-exporter') }
it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "-nginx.scrape-uri 'http://localhost:8080/stub_status' ") }
it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") }

Check failure on line 36 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

prometheus::nginx_prometheus_exporter on oraclelinux-8-x86_64 with some params with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://localhost:8080/stub_status' " Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://localhost:8080/stub_status' " but it is set to "-nginx.scrape-uri 'http://localhost:8080/stub_status' "

Check failure on line 36 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

prometheus::nginx_prometheus_exporter on oraclelinux-9-x86_64 with some params with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://localhost:8080/stub_status' " Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://localhost:8080/stub_status' " but it is set to "-nginx.scrape-uri 'http://localhost:8080/stub_status' "

Check failure on line 36 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

prometheus::nginx_prometheus_exporter on redhat-8-x86_64 with some params with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://localhost:8080/stub_status' " Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://localhost:8080/stub_status' " but it is set to "-nginx.scrape-uri 'http://localhost:8080/stub_status' "

Check failure on line 36 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

prometheus::nginx_prometheus_exporter on redhat-9-x86_64 with some params with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://localhost:8080/stub_status' " Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://localhost:8080/stub_status' " but it is set to "-nginx.scrape-uri 'http://localhost:8080/stub_status' "

Check failure on line 36 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

prometheus::nginx_prometheus_exporter on centos-9-x86_64 with some params with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://localhost:8080/stub_status' " Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://localhost:8080/stub_status' " but it is set to "-nginx.scrape-uri 'http://localhost:8080/stub_status' "

Check failure on line 36 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

prometheus::nginx_prometheus_exporter on oraclelinux-8-x86_64 with some params with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://localhost:8080/stub_status' " Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://localhost:8080/stub_status' " but it is set to "-nginx.scrape-uri 'http://localhost:8080/stub_status' "

Check failure on line 36 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

prometheus::nginx_prometheus_exporter on oraclelinux-9-x86_64 with some params with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://localhost:8080/stub_status' " Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://localhost:8080/stub_status' " but it is set to "-nginx.scrape-uri 'http://localhost:8080/stub_status' "

Check failure on line 36 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

prometheus::nginx_prometheus_exporter on redhat-8-x86_64 with some params with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://localhost:8080/stub_status' " Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://localhost:8080/stub_status' " but it is set to "-nginx.scrape-uri 'http://localhost:8080/stub_status' "

Check failure on line 36 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

prometheus::nginx_prometheus_exporter on redhat-9-x86_64 with some params with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://localhost:8080/stub_status' " Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://localhost:8080/stub_status' " but it is set to "-nginx.scrape-uri 'http://localhost:8080/stub_status' "

Check failure on line 36 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

prometheus::nginx_prometheus_exporter on centos-9-x86_64 with some params with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://localhost:8080/stub_status' " Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://localhost:8080/stub_status' ") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://localhost:8080/stub_status' " but it is set to "-nginx.scrape-uri 'http://localhost:8080/stub_status' "
it { is_expected.to contain_service('nginx_prometheus_exporter') }
end

Expand Down Expand Up @@ -61,7 +61,7 @@
it { is_expected.to contain_class('prometheus') }
it { is_expected.to contain_group('nginx-prometheus-exporter') }
it { is_expected.to contain_user('nginx-prometheus-exporter') }
it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "-nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") }
it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") }

Check failure on line 64 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

prometheus::nginx_prometheus_exporter on oraclelinux-8-x86_64 with scrape_uri and extra options specified with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" but it is set to "-nginx.scrape-uri 'http://127.0.0.1/stub_status' -test"

Check failure on line 64 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

prometheus::nginx_prometheus_exporter on oraclelinux-9-x86_64 with scrape_uri and extra options specified with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" but it is set to "-nginx.scrape-uri 'http://127.0.0.1/stub_status' -test"

Check failure on line 64 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

prometheus::nginx_prometheus_exporter on redhat-8-x86_64 with scrape_uri and extra options specified with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" but it is set to "-nginx.scrape-uri 'http://127.0.0.1/stub_status' -test"

Check failure on line 64 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

prometheus::nginx_prometheus_exporter on redhat-9-x86_64 with scrape_uri and extra options specified with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" but it is set to "-nginx.scrape-uri 'http://127.0.0.1/stub_status' -test"

Check failure on line 64 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

prometheus::nginx_prometheus_exporter on centos-9-x86_64 with scrape_uri and extra options specified with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" but it is set to "-nginx.scrape-uri 'http://127.0.0.1/stub_status' -test"

Check failure on line 64 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

prometheus::nginx_prometheus_exporter on oraclelinux-8-x86_64 with scrape_uri and extra options specified with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" but it is set to "-nginx.scrape-uri 'http://127.0.0.1/stub_status' -test"

Check failure on line 64 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

prometheus::nginx_prometheus_exporter on oraclelinux-9-x86_64 with scrape_uri and extra options specified with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" but it is set to "-nginx.scrape-uri 'http://127.0.0.1/stub_status' -test"

Check failure on line 64 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

prometheus::nginx_prometheus_exporter on redhat-8-x86_64 with scrape_uri and extra options specified with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" but it is set to "-nginx.scrape-uri 'http://127.0.0.1/stub_status' -test"

Check failure on line 64 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

prometheus::nginx_prometheus_exporter on redhat-9-x86_64 with scrape_uri and extra options specified with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" but it is set to "-nginx.scrape-uri 'http://127.0.0.1/stub_status' -test"

Check failure on line 64 in spec/classes/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

prometheus::nginx_prometheus_exporter on centos-9-x86_64 with scrape_uri and extra options specified with specific params is expected to contain Prometheus::Daemon[nginx_prometheus_exporter] with options => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" Failure/Error: it { is_expected.to contain_prometheus__daemon('nginx_prometheus_exporter').with('options' => "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test") } expected that the catalogue would contain Prometheus::Daemon[nginx_prometheus_exporter] with options set to "--nginx.scrape-uri 'http://127.0.0.1/stub_status' -test" but it is set to "-nginx.scrape-uri 'http://127.0.0.1/stub_status' -test"
it { is_expected.to contain_service('nginx_prometheus_exporter') }
end

Expand Down

0 comments on commit c94d990

Please sign in to comment.