Skip to content

Commit

Permalink
add parameter max_open_files to server class
Browse files Browse the repository at this point in the history
  • Loading branch information
kubicgruenfeld committed Feb 12, 2020
1 parent 0f4b811 commit 056e543
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

assert_private()

$max_open_files = $prometheus::max_open_files
$max_open_files = $prometheus::server::max_open_files

$prometheus_v2 = versioncmp($prometheus::server::version, '2.0.0') >= 0

Expand Down
1 change: 1 addition & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
Boolean $manage_config = $prometheus::manage_config,
Optional[Variant[Stdlib::HTTPurl, Stdlib::Unixpath, String[1]]] $external_url = $prometheus::external_url,
Optional[Array[Hash[String[1], Any]]] $collect_scrape_jobs = $prometheus::collect_scrape_jobs,
Optional[Integer] $max_open_files = $prometheus::max_open_files,
Stdlib::Absolutepath $usershell = $prometheus::usershell,
) inherits prometheus {

Expand Down
51 changes: 51 additions & 0 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require 'spec_helper'

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

[{ version: '2.0.0-rc.1', bin_dir: '/usr/local/bin', install_method: 'url' }].each do |parameters|
context "with parameters #{parameters}" do
let(:params) do
parameters
end

if ['centos-7-x86_64', 'centos-8-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'ubuntu-16.04-x86_64', 'ubuntu-18.04-x86_64'].include?(os)
prom_version = parameters[:version] || '1.5.2'
prom_major = prom_version[0]
it {
is_expected.to contain_class('systemd')
}

it {
is_expected.to contain_systemd__unit_file('prometheus.service').with(
'content' => File.read(fixtures('files', "prometheus#{prom_major}.systemd"))
)
}
describe 'max_open_files' do
context 'by default' do
it {
content = catalogue.resource('systemd::unit_file', 'prometheus.service').send(:parameters)[:content]
expect(content).not_to include('LimitNOFILE')
}
end
context 'when set to 1000000' do
let(:params) do
parameters.merge('max_open_files' => 1_000_000)
end

it {
content = catalogue.resource('systemd::unit_file', 'prometheus.service').send(:parameters)[:content]
expect(content).to include('LimitNOFILE=1000000')
}
end
end
end
end
end
end
end
end

0 comments on commit 056e543

Please sign in to comment.