From 43053a6e5917b9800fe8d22fc173036956903a73 Mon Sep 17 00:00:00 2001 From: lagooj Date: Thu, 12 Nov 2020 11:53:50 +0100 Subject: [PATCH] test(archive): add unofficial exporter test --- pillar.example | 2 - .../default/controls/archive_spec.rb | 42 +++++++++++++++++++ test/salt/pillar/default.sls | 27 ++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/pillar.example b/pillar.example index 95fb33c..ee277dc 100644 --- a/pillar.example +++ b/pillar.example @@ -197,8 +197,6 @@ prometheus: source: https://github.com/wrouesnel/postgres_exporter/releases/download/v0.8.0/postgres_exporter_v0.8.0_linux-amd64.tar.gz skip_verify: true - - linux: # 'Alternatives system' priority: zero disables (default) # yamllint disable-line rule:braces diff --git a/test/integration/default/controls/archive_spec.rb b/test/integration/default/controls/archive_spec.rb index 24edf10..2f60c65 100644 --- a/test/integration/default/controls/archive_spec.rb +++ b/test/integration/default/controls/archive_spec.rb @@ -8,10 +8,14 @@ control 'prometheus components' do service_dir = '/lib/systemd/system' alert_manager_service = 'prometheus-alertmanager' node_exporter_service = 'prometheus-node-exporter' + php_fpm_exporter_service = 'php-fpm_exporter' + postgres_exporter_service = 'prometheus-postgres-exporter' else service_dir = '/usr/lib/systemd/system' alert_manager_service = 'alertmanager' node_exporter_service = 'node_exporter' + php_fpm_exporter_service = 'php-fpm_exporter' + postgres_exporter_service = 'postgres_exporter' end # describe package('cron') do @@ -35,6 +39,12 @@ control 'prometheus components' do describe user('node_exporter') do it { should exist } end + describe user('php-fpm_exporter') do + it { should exist } + end + describe user('postgres_exporter') do + it { should exist } + end describe directory('/var/lib/prometheus') do it { should exist } end @@ -89,6 +99,38 @@ control 'prometheus components' do its('group') { should eq 'root' } its('mode') { should cmp '0644' } end + describe directory('/opt/prometheus/php-fpm_exporter-v0.6.1') do + it { should exist } + its('group') { should eq 'root' } + end + describe file('/opt/prometheus/php-fpm_exporter-v0.6.1/php-fpm_exporter') do + it { should exist } + its('group') { should eq 'root' } + end + describe directory('/var/lib/prometheus/php-fpm_exporter') do + it { should exist } + end + describe file("#{service_dir}/#{php_fpm_exporter_service}.service") do + it { should exist } + its('group') { should eq 'root' } + its('mode') { should cmp '0644' } + end + describe directory('/var/lib/prometheus/postgres_exporter') do + it { should exist } + end + describe directory('/opt/prometheus/postgres_exporter-v0.8.0') do + it { should exist } + its('group') { should eq 'root' } + end + describe file('/opt/prometheus/postgres_exporter-v0.8.0/postgres_exporter') do + it { should exist } + its('group') { should eq 'root' } + end + describe file("#{service_dir}/#{postgres_exporter_service}.service") do + it { should exist } + its('group') { should eq 'root' } + its('mode') { should cmp '0644' } + end describe file('/usr/local/sbin/alertmanager') do it { should exist } its('group') { should eq 'root' } diff --git a/test/salt/pillar/default.sls b/test/salt/pillar/default.sls index 2f8e3e7..98cd02d 100644 --- a/test/salt/pillar/default.sls +++ b/test/salt/pillar/default.sls @@ -15,6 +15,8 @@ prometheus: - node_exporter - blackbox_exporter - consul_exporter + - php-fpm_exporter + - postgres_exporter # - memcached_exporter # not in upstream repo, only archive exporters: @@ -171,6 +173,31 @@ prometheus: web.listen-address: ":9091" web.telemetry-path: "/metrics" + # Unoffical php fpm exporter config + php-fpm_exporter: + version: v0.6.1 + archive: + official: false + tar: false + # yamllint disable-line rule:line-length + source: https://github.com/bakins/php-fpm-exporter/releases/download/v0.6.1/php-fpm-exporter.linux.amd64 + source_hash: 40e52d84f7decb5fdad9fadacf63cb2de26ebddce56e11b20651555e8d6c6130 + service: + args: + addr: ":9253" + fastcgi: "unix:///run/php/php-fpm.sock" + + postgres_exporter: + version: v0.8.0 + service: + env: + - 'DATA_SOURCE_NAME=foo:bar@/' + archive: + official: false + # yamllint disable-line rule:line-length + source: https://github.com/wrouesnel/postgres_exporter/releases/download/v0.8.0/postgres_exporter_v0.8.0_linux-amd64.tar.gz + skip_verify: true + linux: # 'Alternatives system' priority: zero disables (default) # yamllint disable-line rule:braces