Skip to content

Commit 7c2f1f3

Browse files
authored
Merge pull request #117 from jarretlavallee/acceptance_test_updates
(maint) Add acceptance tests for the services
2 parents f57af62 + f323f24 commit 7c2f1f3

File tree

3 files changed

+77
-8
lines changed

3 files changed

+77
-8
lines changed

spec/acceptance/functions/hosts_with_pe_profile_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
notice "Received=$result"
88
MANIFEST
99
output = apply_manifest(pp).stdout
10-
expect(output).to match(%r{127.0.0.1})
10+
expect(output).to match(%r{Received=\[127.0.0.1\]})
1111
end
1212
it 'return the FQDN for the master profile' do
1313
# This influences the custom facts
@@ -17,7 +17,7 @@
1717
notice "Received=$result"
1818
MANIFEST
1919
output = apply_manifest(pp).stdout
20-
expect(output).to match(host_inventory['fqdn'])
20+
expect(output).to match(%r{Received=\[#{host_inventory['fqdn']}\]})
2121
run_shell('puppet config set storeconfigs false --section user', expect_failures: false)
2222
end
2323
end

spec/acceptance/init_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
end
1818
describe 'check puppet-metrics-collector directory' do
1919
it 'scripts folder exists' do
20-
file('/opt/puppetlabs/puppet-metrics-collector/scripts').should be_directory
20+
expect(file('/opt/puppetlabs/puppet-metrics-collector/scripts')).to be_directory
2121
end
2222
end
2323
end

spec/acceptance/pe_metric_spec.rb

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,90 @@
88
MANIFEST
99
idempotent_apply(pp)
1010
end
11-
it 'sets all puppet_* metric services to be active' do
11+
it 'all puppet_* metric services should be active or inactive' do
1212
run_shell('systemctl list-units --type=service | grep "puppet_.*metrics"') do |r|
13-
puts r.stdout
1413
expect(r.stdout).to match(%r{activ})
1514
end
1615
end
17-
it 'check for the tidy services files' do
16+
context 'all of the timers are running' do
17+
it { expect(service('puppet_ace-metrics.timer')).to be_running }
18+
it { expect(service('puppet_ace-tidy.timer')).to be_running }
19+
it { expect(service('puppet_bolt-metrics.timer')).to be_running }
20+
it { expect(service('puppet_bolt-tidy.timer')).to be_running }
21+
it { expect(service('puppet_orchestrator-metrics.timer')).to be_running }
22+
it { expect(service('puppet_orchestrator-tidy.timer')).to be_running }
23+
it { expect(service('puppet_postgres-metrics.timer')).to be_running }
24+
it { expect(service('puppet_postgres-tidy.timer')).to be_running }
25+
it { expect(service('puppet_puppetdb-metrics.timer')).to be_running }
26+
it { expect(service('puppet_puppetdb-tidy.timer')).to be_running }
27+
it { expect(service('puppet_puppetserver-metrics.timer')).to be_running }
28+
it { expect(service('puppet_puppetserver-tidy.timer')).to be_running }
29+
it { expect(service('puppet_system_cpu-metrics.timer')).to be_running }
30+
it { expect(service('puppet_system_cpu-tidy.timer')).to be_running }
31+
it { expect(service('puppet_system_memory-metrics.timer')).to be_running }
32+
it { expect(service('puppet_system_memory-tidy.timer')).to be_running }
33+
it { expect(service('puppet_system_processes-metrics.timer')).to be_running }
34+
it { expect(service('puppet_system_processes-tidy.timer')).to be_running }
35+
end
36+
it 'creates tidy services files' do
1837
files = run_shell('ls /etc/systemd/system/puppet_*-tidy.service').stdout
1938
expect(files.split("\n").count).to eq(9)
2039
end
21-
it 'check for the timer files' do
40+
it 'creates the timer files' do
2241
files = run_shell('ls /etc/systemd/system/puppet_*-tidy.timer').stdout
2342
expect(files.split("\n").count).to eq(9)
2443
end
25-
it 'checks if sysstat package is installed' do
44+
it 'sysstat package is installed' do
2645
expect(package('sysstat')).to be_installed
2746
end
47+
48+
describe file('/opt/puppetlabs/puppet-metrics-collector/puppetserver/127.0.0.1') do
49+
before(:each) { run_shell('systemctl start puppet_puppetserver-metrics.service') }
50+
51+
it { is_expected.to be_directory }
52+
it 'contains metric files' do
53+
files = run_shell('ls /opt/puppetlabs/puppet-metrics-collector/puppetserver/127.0.0.1/*').stdout
54+
expect(files.split('\n')).not_to be_empty
55+
end
56+
end
57+
58+
describe file('/opt/puppetlabs/puppet-metrics-collector/puppetdb/127.0.0.1') do
59+
before(:each) { run_shell('systemctl start puppet_puppetdb-metrics.service') }
60+
61+
it { is_expected.to be_directory }
62+
it 'contains metric files' do
63+
files = run_shell('ls /opt/puppetlabs/puppet-metrics-collector/puppetdb/127.0.0.1/*').stdout
64+
expect(files.split('\n')).not_to be_empty
65+
end
66+
end
67+
68+
describe file('/opt/puppetlabs/puppet-metrics-collector/orchestrator/127.0.0.1') do
69+
before(:each) { run_shell('systemctl start puppet_orchestrator-metrics.service') }
70+
71+
it { is_expected.to be_directory }
72+
it 'contains metric files' do
73+
files = run_shell('ls /opt/puppetlabs/puppet-metrics-collector/orchestrator/127.0.0.1/*').stdout
74+
expect(files.split('\n')).not_to be_empty
75+
end
76+
end
77+
78+
describe file('/opt/puppetlabs/puppet-metrics-collector/ace/127.0.0.1') do
79+
before(:each) { run_shell('systemctl start puppet_ace-metrics.service') }
80+
81+
it { is_expected.to be_directory }
82+
it 'contains metric files' do
83+
files = run_shell('ls /opt/puppetlabs/puppet-metrics-collector/ace/127.0.0.1/*').stdout
84+
expect(files.split('\n')).not_to be_empty
85+
end
86+
end
87+
88+
describe file('/opt/puppetlabs/puppet-metrics-collector/bolt/127.0.0.1') do
89+
before(:each) { run_shell('systemctl start puppet_bolt-metrics.service') }
90+
91+
it { is_expected.to be_directory }
92+
it 'contains metric files' do
93+
files = run_shell('ls /opt/puppetlabs/puppet-metrics-collector/bolt/127.0.0.1/*').stdout
94+
expect(files.split('\n')).not_to be_empty
95+
end
96+
end
2897
end

0 commit comments

Comments
 (0)