forked from puppetlabs/puppetlabs-tomcat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acceptance_2_spec.rb
219 lines (202 loc) · 7.85 KB
/
acceptance_2_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
require 'spec_helper_acceptance'
stop_test = true if UNSUPPORTED_PLATFORMS.any?{ |up| fact('osfamily') == up}
tcat_version = String.new
shell('curl http://tomcat.apache.org/download-60.cgi?Preferred=http%3A%2F%2Fmirror.symnds.com%2Fsoftware%2FApache%2F', :acceptable_exit_codes => 0) do |r|
/apache-tomcat-(.{4,7}).tar.gz/.match(r.stdout).to_a.uniq.each do |m|
if m.length < 7
tcat_version = m
break
end
end
end
describe 'Two different instances of Tomcat 6 in the same manifest', :unless => stop_test do
context 'Initial install Tomcat and verification' do
it 'Should apply the manifest without error' do
pp = <<-EOS
class { 'tomcat':}
class { 'java':}
tomcat::instance { 'tomcat6':
source_url => 'http://mirror.symnds.com/software/Apache/tomcat/tomcat-6/v#{tcat_version}/bin/apache-tomcat-#{tcat_version}.tar.gz',
catalina_base => '/opt/apache-tomcat/tomcat6',
}->
tomcat::config::server { 'tomcat6':
catalina_base => '/opt/apache-tomcat/tomcat6',
port => '8205',
}->
tomcat::config::server::connector { 'tomcat6-http':
catalina_base => '/opt/apache-tomcat/tomcat6',
port => '8280',
protocol => 'HTTP/1.1',
additional_attributes => {
'redirectPort' => '8643'
},
}->
tomcat::config::server::connector { 'tomcat6-ajp':
catalina_base => '/opt/apache-tomcat/tomcat6',
port => '8209',
protocol => 'AJP/1.3',
additional_attributes => {
'redirectPort' => '8643'
},
}->
tomcat::war { 'tomcat6-sample.war':
catalina_base => '/opt/apache-tomcat/tomcat6',
war_source => 'https://tomcat.apache.org/tomcat-8.0-doc/appdev/sample/sample.war',
war_name => 'tomcat6-sample.war',
}->
tomcat::service { 'tomcat6':
catalina_base => '/opt/apache-tomcat/tomcat6'
}
tomcat::instance { 'tomcat6039':
source_url => 'http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.39/bin/apache-tomcat-6.0.39.tar.gz',
catalina_base => '/opt/apache-tomcat/tomcat6039',
}->
tomcat::config::server { 'tomcat6039':
catalina_base => '/opt/apache-tomcat/tomcat6039',
port => '8305',
}->
tomcat::config::server::connector { 'tomcat6039-http':
catalina_base => '/opt/apache-tomcat/tomcat6039',
port => '8380',
protocol => 'HTTP/1.1',
additional_attributes => {
'redirectPort' => '8743'
},
}->
tomcat::config::server::connector { 'tomcat6039-ajp':
catalina_base => '/opt/apache-tomcat/tomcat6039',
port => '8309',
protocol => 'AJP/1.3',
additional_attributes => {
'redirectPort' => '8743'
},
}->
tomcat::war { 'tomcat6039-sample.war':
catalina_base => '/opt/apache-tomcat/tomcat6039',
war_source => 'https://tomcat.apache.org/tomcat-8.0-doc/appdev/sample/sample.war',
war_name => 'tomcat6039-sample.war',
}->
tomcat::service { 'tomcat6039':
catalina_base => '/opt/apache-tomcat/tomcat6039'
}
EOS
apply_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0,2])
shell('sleep 15')
end
# test the server
it 'tomcat6 should be serving a page on port 8280' do
shell('curl localhost:8280', :acceptable_exit_codes => 0) do |r|
r.stdout.should match(/Apache Tomcat/)
end
end
it 'tomcat6039 should be serving a page on port 8380' do
shell('curl localhost:8380', :acceptable_exit_codes => 0) do |r|
r.stdout.should match(/Apache Tomcat/)
end
end
#test the war
it 'tomcat6 should have war deployed by default' do
shell('curl localhost:8280/tomcat6-sample/hello.jsp', :acceptable_exit_codes => 0) do |r|
r.stdout.should match(/Sample Application JSP Page/)
end
end
it 'tomcat6039 should have war deployed by default' do
shell('curl localhost:8380/tomcat6039-sample/hello.jsp', :acceptable_exit_codes => 0) do |r|
r.stdout.should match(/Sample Application JSP Page/)
end
end
end
context 'Stop tomcat service' do
it 'Should apply the manifest without error' do
pp = <<-EOS
class{ 'tomcat':}
tomcat::service { 'tomcat6039':
catalina_base => '/opt/apache-tomcat/tomcat6039',
service_ensure => 'stopped',
}
tomcat::service { 'tomcat6':
catalina_base => '/opt/apache-tomcat/tomcat6',
service_ensure => 'false',
}
EOS
apply_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0,2])
shell('sleep 15')
end
it 'tomcat6 should not be serving a page on port 8280' do
shell('curl localhost:8280', :acceptable_exit_codes => 7)
end
it 'tomcat6039 should not be serving a page on port 8380' do
shell('curl localhost:8380', :acceptable_exit_codes => 7)
end
end
context 'Start Tomcat without war' do
it 'Should apply the manifest without error' do
pp = <<-EOS
class{ 'tomcat':}
tomcat::war { 'tomcat6039-sample.war':
catalina_base => '/opt/apache-tomcat/tomcat6039',
war_source => 'https://tomcat.apache.org/tomcat-8.0-doc/appdev/sample/sample.war',
war_name => 'tomcat6039-sample.war',
war_ensure => 'absent',
}->
tomcat::service { 'tomcat6039':
catalina_base => '/opt/apache-tomcat/tomcat6039',
service_ensure => 'true',
}
tomcat::war { 'tomcat6-sample.war':
catalina_base => '/opt/apache-tomcat/tomcat6',
war_source => 'https://tomcat.apache.org/tomcat-8.0-doc/appdev/sample/sample.war',
war_name => 'tomcat6-sample.war',
war_ensure => 'false',
}->
tomcat::service { 'tomcat6':
catalina_base => '/opt/apache-tomcat/tomcat6',
service_ensure => 'running',
}
EOS
apply_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0,2])
shell('sleep 15')
end
it 'tomcat6 should be display friendly message when war is not deployed' do
shell('curl localhost:8280/tomcat6-sample/hello.jsp') do |r|
r.stdout.should match(/The requested resource is not available/)
end
end
it 'tomcat6039 should be display friendly message when war is not deployed' do
shell('curl localhost:8380/tomcat6039-sample/hello.jsp') do |r|
r.stdout.should match(/The requested resource is not available/)
end
end
end
context 'deploy the war' do
it 'Should apply the manifest without error' do
pp = <<-EOS
class{ 'tomcat':}
tomcat::war { 'tomcat6-sample.war':
catalina_base => '/opt/apache-tomcat/tomcat6',
war_source => 'https://tomcat.apache.org/tomcat-8.0-doc/appdev/sample/sample.war',
war_name => 'tomcat6-sample.war',
war_ensure => 'present',
}
tomcat::war { 'tomcat6039-sample.war':
catalina_base => '/opt/apache-tomcat/tomcat6039',
war_source => 'https://tomcat.apache.org/tomcat-8.0-doc/appdev/sample/sample.war',
war_name => 'tomcat6039-sample.war',
war_ensure => 'true',
}
EOS
apply_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0,2])
shell('sleep 15')
end
it 'tomcat6 should be serving a war on port 8280' do
shell('curl localhost:8280/tomcat6-sample/hello.jsp') do |r|
r.stdout.should match(/Sample Application JSP Page/)
end
end
it 'tomcat6039 should be serving a war on port 8380' do
shell('curl localhost:8380/tomcat6039-sample/hello.jsp') do |r|
r.stdout.should match(/Sample Application JSP Page/)
end
end
end
end