Skip to content

Commit efd1f79

Browse files
committed
Add node_exporter acceptance test for proxy settings
1 parent 44bd327 commit efd1f79

File tree

6 files changed

+55
-3
lines changed

6 files changed

+55
-3
lines changed

.github/workflows/ci.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
---
2-
# Managed by modulesync - DO NOT EDIT
3-
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
4-
52
name: CI
63

74
on: pull_request
@@ -74,11 +71,16 @@ jobs:
7471
with:
7572
ruby-version: '3.0'
7673
bundler-cache: true
74+
- name: Start squid
75+
run: ./scripts/start-squid.sh
7776
- name: Run tests
7877
run: bundle exec rake beaker
7978
env:
8079
BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }}
8180
BEAKER_setfile: ${{ matrix.setfile.value }}
81+
- name: squid logs
82+
run: docker logs squid --tail 50
83+
if: always()
8284

8385
tests:
8486
needs:

.sync.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ spec/spec_helper.rb:
33
spec_overrides: "require 'spec_helper_methods'"
44
spec/spec_helper_acceptance.rb:
55
unmanaged: false
6+
.github/workflows/ci.yml:
7+
unmanaged: true

scripts/start-squid.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
cat << EOF > /tmp/squid.conf
4+
http_port 3128
5+
http_access allow all
6+
logfile_rotate 0
7+
cache_log stdio:/dev/stdout
8+
access_log stdio:/dev/stdout
9+
cache_store_log stdio:/dev/stdout
10+
EOF
11+
12+
docker run --detach --rm \
13+
--name squid \
14+
--hostname squid \
15+
--publish 3128:3128 \
16+
--env='SQUID_CONFIG_FILE=/etc/squid/my-squid.conf' \
17+
--volume=/tmp/squid.conf:/etc/squid/my-squid.conf:ro \
18+
b4tman/squid
19+
20+
sleep 3
21+
docker logs squid --tail 100
22+
23+
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' squid > ~/SQUID_IP

spec/acceptance/node_exporter_spec.rb

+18
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,22 @@
5454
end
5555
end
5656
# rubocop:enable RSpec/RepeatedExampleGroupBody,RSpec/RepeatedExampleGroupDescription
57+
58+
describe 'install with proxy' do
59+
it 'installs idempotently with no errors' do
60+
pp = "class{'prometheus::node_exporter': proxy_server => 'http://squid:3128', proxy_type => 'http'}"
61+
# Run it twice and test for idempotency
62+
apply_manifest(pp, catch_failures: true)
63+
apply_manifest(pp, catch_changes: true)
64+
end
65+
66+
describe service('node_exporter') do
67+
it { is_expected.to be_running }
68+
it { is_expected.to be_enabled }
69+
end
70+
71+
describe port(9100) do
72+
it { is_expected.to be_listening.with('tcp6') }
73+
end
74+
end
5775
end

spec/setup_acceptance_node.pp

+5
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44
ensure => present,
55
}
66
}
7+
8+
file_line { '/etc/hosts-squid':
9+
path => '/etc/hosts',
10+
line => "${facts['squid_ip']} squid",
11+
}

spec/spec_helper_acceptance.rb

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
require 'voxpupuli/acceptance/spec_helper_acceptance'
77

8+
ENV['BEAKER_FACTER_SQUID_IP'] = File.read(File.expand_path('~/SQUID_IP')).chomp
9+
810
configure_beaker
911

1012
Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f }

0 commit comments

Comments
 (0)