Skip to content

Commit

Permalink
Merge pull request #253 from bastelfreak/tests2
Browse files Browse the repository at this point in the history
add prometheus server version to alerts resource
  • Loading branch information
bastelfreak committed Aug 18, 2018
2 parents 97d3021 + aefc0f5 commit a4281f6
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
prometheus::alerts { 'alert':
alerts => $alerts,
location => $config_dir,
version => $version,
}
$_rule_files = concat(["${config_dir}/alert.rules"], $extra_rule_files, $rule_files)
}
Expand Down
56 changes: 56 additions & 0 deletions spec/acceptance/prometheus_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,60 @@
it { is_expected.to be_listening.with('tcp6') }
end
end

describe 'prometheus with complex alerts and scrape configs' do
it 'is idempotent' do
pp = <<-EOS
class { 'prometheus::server':
version => '2.3.2',
alerts => {
'groups' => [
{
'name' => 'alert.rules',
'rules' => [
{
'alert' => 'InstanceDown',
'expr' => 'up == 0',
'for' => '5m',
'labels' => {
'severity' => 'page',
},
'annotations' => {
'summary' => 'Instance {{ $labels.instance }} down',
'description' => '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes.'
}
}
]
}
]
},
scrape_configs => [
{
'job_name' => 'prometheus',
'scrape_interval' => '10s',
'scrape_timeout' => '10s',
'static_configs' => [
{
'targets' => [ 'localhost:9090' ],
'labels' => { 'alias' => 'Prometheus' }
}
]
}
]
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe service('prometheus') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end

describe port(9090) do
it { is_expected.to be_listening.with('tcp6') }
end
end
end

0 comments on commit a4281f6

Please sign in to comment.