Skip to content

Commit

Permalink
test(packages): check when using repo or archives
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbertoli committed Aug 21, 2020
1 parent 3014494 commit c5ad857
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
23 changes: 20 additions & 3 deletions test/integration/repo/controls/packages_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
# frozen_string_literal: true

control 'prometheus package' do
case platform[:family]
when 'redhat'
packages = %w[
prometheus2
alertmanager
node_exporter
]
when 'debian'
packages = %w[
prometheus
prometheus-alertmanager
prometheus-node-exporter
]
end

control 'prometheus packages' do
title 'should be installed'

describe package('prometheus2') do
it { should be_installed }
packages.each do |p|
describe package(p) do
it { should be_installed }
end
end
end
23 changes: 23 additions & 0 deletions test/integration/repo/controls/repositories_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

control 'repositories' do
impact 0.6
title 'Configure the repositories'
desc '
Configure the Debian/RedHat repositories for the supported platforms.
'
tag 'repositories', 'apt', 'yum'
ref 'Prometheus prerequisites - Section: Prometheus package repositories', url: 'https://prometheus.io/download'

case os[:family]
when 'debian'
describe file('/etc/apt/sources.list.d/prometheus.list') do
it { should_not exist }
end
when 'redhat', 'centos'
describe yum.repo('prometheus') do
it { should exist }
it { should be_enabled }
end
end
end
5 changes: 3 additions & 2 deletions test/salt/pillar/repo.sls
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ prometheus:
- rust
component:
- prometheus
- alertmanager # not in debian repo, only archive
- alertmanager
- node_exporter
- blackbox_exporter
# - memcached_exporter # not in upstream repo, only archive

exporters:
Expand All @@ -29,7 +30,7 @@ prometheus:
smartctl: /usr/sbin/smartctl

pkg:
use_upstream_repo: true
use_upstream_repo: {{ false if grains.os_family|lower in ('debian',) else true }}
use_upstream_archive: false

clientlibs:
Expand Down

0 comments on commit c5ad857

Please sign in to comment.