Skip to content
This repository was archived by the owner on Mar 28, 2019. It is now read-only.

Commit 2cec963

Browse files
author
Daniel Dreier
committed
Improve acceptance tests
Add an actual agent run to each test, to confirm that the master is able to serve requests in some basic capacity. Would have caught the "unicorn / nginx support broken" issue where ssl headers weren't passed right. Also moves some of the tests into common blocks to reduce duplication.
1 parent 1c8e133 commit 2cec963

File tree

5 files changed

+90
-72
lines changed

5 files changed

+90
-72
lines changed
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
require 'spec_helper_acceptance'
22

33
describe 'passenger server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
4-
context 'running on passenger' do
5-
it 'should run with no errors', :servertype => 'passenger', :webserver => 'apache' do
4+
context 'running on passenger', :servertype => 'passenger', :webserver => 'apache' do
5+
it 'should run with no errors' do
66
pp = <<-EOS
7-
class { "puppet::server":
8-
servertype => 'passenger',
9-
ca => true,
10-
servername => $::hostname,
7+
class { 'puppet::server':
8+
servertype => 'passenger',
9+
ca => true,
10+
servername => $::hostname,
1111
}
1212
EOS
1313

1414
# Run it twice and test for idempotency
1515
apply_manifest(pp, :catch_failures => true)
1616
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
1717
end
18+
it_behaves_like 'basic working puppetmaster'
1819

19-
describe port(8140) do
20-
it {
21-
should be_listening
22-
}
20+
# sanity checks to ensure the passenger setup doesn't bring in other services
21+
describe service('nginx') do
22+
it { should_not be_enabled }
23+
it { should_not be_running }
2324
end
25+
describe service('puppetmaster') do
26+
it { should_not be_enabled }
27+
it { should_not be_running }
28+
end
29+
describe service('puppetserver') do
30+
it { should_not be_enabled }
31+
it { should_not be_running }
32+
end
33+
2434
end
2535
end

spec/acceptance/thin_server_spec.rb

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
describe 'thin server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
44

5-
context 'running on thin' do
6-
it 'should run with no errors', :servertype => 'thin', :webserver => 'nginx' do
5+
context 'running on thin', :servertype => 'thin', :webserver => 'nginx' do
6+
it 'should run with no errors' do
77
pp = <<-EOS
88
class { "puppet::server":
99
servertype => 'thin',
@@ -17,24 +17,16 @@ class { "puppet::server":
1717
end
1818

1919
describe package('thin') do
20-
it {
21-
should be_installed.by('gem')
22-
}
20+
it { should be_installed.by('gem') }
2321
end
2422

2523
describe service('thin-puppetmaster') do
26-
it {
27-
should be_enabled
28-
}
29-
it {
30-
should be_running
31-
}
24+
it { should be_enabled }
25+
it { should be_running }
3226
end
3327

34-
describe port(8140) do
35-
it {
36-
should be_listening
37-
}
38-
end
28+
it_behaves_like "basic working puppetmaster"
29+
it_behaves_like "nginx-based webserver"
30+
3931
end
4032
end
Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,22 @@
11
require 'spec_helper_acceptance'
22

33
describe 'server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
4-
context 'running on unicorn' do
5-
it 'should run with no errors', :servertype => 'unicorn', :webserver => 'nginx' do
4+
context 'running on unicorn', :servertype => 'unicorn', :webserver => 'nginx' do
5+
it 'should run with no errors' do
66
pp = <<-EOS
7-
class { "puppet::server":
8-
servertype => 'unicorn',
9-
ca => true,
7+
class { 'puppet::server':
8+
servertype => 'unicorn',
9+
ca => true,
1010
}
1111
EOS
1212

1313
# Run it twice and test for idempotency
1414
apply_manifest(pp, :catch_failures => true)
1515
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
1616
end
17-
describe command('puppet agent --test --server puppet') do
18-
its(:exit_status) { should eq 0 }
19-
its(:stderr) { should_not match /Forbidden request:/ }
20-
its(:stderr) { should_not match /Error:/ }
21-
end
22-
23-
describe package('nginx') do
24-
it {
25-
should be_installed
26-
}
27-
end
2817

29-
describe service('nginx') do
30-
it {
31-
should be_enabled
32-
}
33-
it {
34-
should be_running
35-
}
36-
end
18+
it_behaves_like "basic working puppetmaster"
19+
it_behaves_like "nginx-based webserver"
3720

38-
describe port(8140) do
39-
it {
40-
should be_listening
41-
}
42-
end
4321
end
44-
4522
end
Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
require 'spec_helper_acceptance'
22

33
describe 'server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
4-
context 'running on webrick/standalone' do
5-
it 'should run with no errors', :server => 'webrick', :webserver => 'builtin' do
4+
context 'running on webrick/standalone', :server => 'webrick', :webserver => 'builtin' do
5+
it 'should run with no errors' do
66
pp = <<-EOS
7-
class { "puppet::server":
8-
servertype => 'standalone',
9-
ca => true,
7+
class { 'puppet::server':
8+
servertype => 'standalone',
9+
ca => true,
1010
}
1111
EOS
1212

@@ -16,19 +16,29 @@ class { "puppet::server":
1616
end
1717

1818
describe service('puppetmaster') do
19-
it {
20-
should be_enabled
21-
}
22-
it {
23-
should be_running
24-
}
19+
it { should be_enabled }
20+
it { should be_running }
2521
end
2622

27-
describe port(8140) do
28-
it {
29-
should be_listening
30-
}
23+
# sanity checks to ensure the webrick setup doesn't bring in other services
24+
describe service('nginx') do
25+
it { should_not be_enabled }
26+
it { should_not be_running }
3127
end
32-
end
28+
describe service('apache2') do
29+
it { should_not be_enabled }
30+
it { should_not be_running }
31+
end
32+
describe service('httpd') do
33+
it { should_not be_enabled }
34+
it { should_not be_running }
35+
end
36+
describe service('puppetserver') do
37+
it { should_not be_enabled }
38+
it { should_not be_running }
39+
end
40+
41+
it_behaves_like 'basic working puppetmaster'
3342

43+
end
3444
end

spec/spec_helper_acceptance.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,32 @@
7070
on host, "rm -rf /var/lib/puppet/ssl; puppet cert --generate $HOSTNAME"
7171

7272
end
73+
74+
shared_examples_for "basic working puppetmaster" do
75+
describe command('puppet agent --test --server puppet') do
76+
its(:exit_status) { should eq 0 }
77+
its(:stderr) { should_not match /Forbidden request:/ }
78+
its(:stderr) { should_not match /Error:/ }
79+
end
80+
describe port(8140) do
81+
it {
82+
should be_listening
83+
}
84+
end
85+
end
86+
87+
shared_examples_for "nginx-based webserver" do
88+
describe package('nginx') do
89+
it { should be_installed }
90+
end
91+
92+
describe service('nginx') do
93+
it { should be_enabled }
94+
it { should be_running }
95+
end
96+
97+
describe service('puppetmaster') do
98+
it { should_not be_enabled }
99+
it { should_not be_running }
100+
end
101+
end

0 commit comments

Comments
 (0)