forked from puppetlabs/puppetlabs-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava_spec.rb
238 lines (203 loc) · 11.9 KB
/
java_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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
require 'spec_helper'
describe 'java', :type => :class do
context 'select openjdk for Centos 5.8' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.8'} }
it { is_expected.to contain_package('java').with_name('java-1.6.0-openjdk-devel') }
end
context 'select openjdk for Centos 6.3' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.3'} }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') }
end
context 'select openjdk for Centos 7.1.1503' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '7.1.1503'} }
it { is_expected.to contain_package('java').with_name('java-1.8.0-openjdk-devel') }
end
context 'select openjdk for Centos 6.2' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.2'} }
it { is_expected.to contain_package('java').with_name('java-1.6.0-openjdk-devel') }
it { is_expected.to_not contain_exec('update-java-alternatives') }
end
context 'select Oracle JRE with alternatives for Centos 6.3' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.3'} }
let(:params) { { 'package' => 'jre', 'java_alternative' => '/usr/bin/java', 'java_alternative_path' => '/usr/java/jre1.7.0_67/bin/java'} }
it { is_expected.to contain_package('java').with_name('jre') }
it { is_expected.to contain_exec('create-java-alternatives').with_command('alternatives --install /usr/bin/java java /usr/java/jre1.7.0_67/bin/java 20000') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('alternatives --set java /usr/java/jre1.7.0_67/bin/java') }
end
context 'select openjdk for Fedora 20' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Fedora', :operatingsystemrelease => '20'} }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') }
end
context 'select openjdk for Fedora 21' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Fedora', :operatingsystemrelease => '21'} }
it { is_expected.to contain_package('java').with_name('java-1.8.0-openjdk-devel') }
end
context 'select passed value for Fedora 20' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Fedora', :operatingsystemrelease => '20'} }
let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') }
end
context 'select passed value for Fedora 21' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Fedora', :operatingsystemrelease => '21'} }
let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('java-1.8.0-openjdk') }
end
context 'select passed value for Fedora 21 with yum option' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Fedora', :operatingsystemrelease => '21'} }
let(:params) { { 'distribution' => 'jre' } }
let(:params) { { 'package_options' => ['--skip-broken'] } }
it { is_expected.to contain_package('java') }
end
context 'select passed value for Centos 5.3' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.3'} }
let(:params) { { 'package' => 'jdk' } }
it { is_expected.to contain_package('java').with_name('jdk') }
it { is_expected.to_not contain_exec('update-java-alternatives') }
end
context 'select default for Centos 5.3' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.3'} }
it { is_expected.to contain_package('java').with_name('java-1.6.0-openjdk-devel') }
it { is_expected.to_not contain_exec('update-java-alternatives') }
end
context 'select default for Debian Wheezy' do
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'wheezy', :operatingsystemrelease => '7.1', :architecture => 'amd64',} }
it { is_expected.to contain_package('java').with_name('openjdk-7-jdk') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-1.7.0-openjdk-amd64 --jre') }
end
context 'select Oracle JRE for Debian Wheezy' do
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'wheezy', :operatingsystemrelease => '7.1', :architecture => 'amd64',} }
let(:params) { { 'distribution' => 'oracle-jre' } }
it { is_expected.to contain_package('java').with_name('oracle-j2re1.7') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('update-java-alternatives --set j2re1.7-oracle --jre') }
end
context 'select OpenJDK JRE for Debian Wheezy' do
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'wheezy', :operatingsystemrelease => '7.1', :architecture => 'amd64',} }
let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('openjdk-7-jre-headless') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-1.7.0-openjdk-amd64 --jre-headless') }
end
context 'select default for Debian Squeeze' do
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'squeeze', :operatingsystemrelease => '6.0.5', :architecture => 'amd64',} }
it { is_expected.to contain_package('java').with_name('openjdk-6-jdk') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-6-openjdk-amd64 --jre') }
end
context 'select Oracle JRE for Debian Squeeze' do
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'squeeze', :operatingsystemrelease => '6.0.5', :architecture => 'amd64',} }
let(:params) { { 'distribution' => 'sun-jre', } }
it { is_expected.to contain_package('java').with_name('sun-java6-jre') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-6-sun --jre') }
end
context 'select OpenJDK JRE for Debian Squeeze' do
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'squeeze', :operatingsystemrelease => '6.0.5', :architecture => 'amd64',} }
let(:params) { { 'distribution' => 'jre', } }
it { is_expected.to contain_package('java').with_name('openjdk-6-jre-headless') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-6-openjdk-amd64 --jre-headless') }
end
context 'select random alternative for Debian Wheezy' do
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'wheezy', :operatingsystemrelease => '7.1', :architecture => 'amd64',} }
let(:params) { { 'java_alternative' => 'bananafish' } }
it { is_expected.to contain_package('java').with_name('openjdk-7-jdk') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('update-java-alternatives --set bananafish --jre') }
end
context 'select jdk for Ubuntu Vivid (15.04)' do
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Ubuntu', :lsbdistcodename => 'vivid', :operatingsystemrelease => '15.04', :architecture => 'amd64',} }
let(:params) { { 'distribution' => 'jdk' } }
it { is_expected.to contain_package('java').with_name('openjdk-8-jdk') }
end
context 'select jre for Ubuntu Vivid (15.04)' do
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Ubuntu', :lsbdistcodename => 'vivid', :operatingsystemrelease => '15.04', :architecture => 'amd64',} }
let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('openjdk-8-jre-headless') }
end
context 'select openjdk for Amazon Linux' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Amazon', :operatingsystemrelease => '3.4.43-43.43.amzn1.x86_64'} }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') }
end
context 'select passed value for Amazon Linux' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Amazon', :operatingsystemrelease => '5.3.4.43-43.43.amzn1.x86_64'} }
let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') }
end
context 'select openjdk for Oracle Linux' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'OracleLinux', :operatingsystemrelease => '6.4'} }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') }
end
context 'select openjdk for Oracle Linux 6.2' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'OracleLinux', :operatingsystemrelease => '6.2'} }
it { is_expected.to contain_package('java').with_name('java-1.6.0-openjdk-devel') }
end
context 'select passed value for Oracle Linux' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'OracleLinux', :operatingsystemrelease => '6.3'} }
let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') }
end
context 'select passed value for Scientific Linux' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Scientific', :operatingsystemrelease => '6.4'} }
let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') }
end
context 'select default for OpenSUSE 12.3' do
let(:facts) { {:osfamily => 'Suse', :operatingsystem => 'OpenSUSE', :operatingsystemrelease => '12.3'}}
it { is_expected.to contain_package('java').with_name('java-1_7_0-openjdk-devel')}
end
context 'select default for SLES 11.3' do
let(:facts) { {:osfamily => 'Suse', :operatingsystem => 'SLES', :operatingsystemrelease => '11.3'}}
it { should contain_package('java').with_name('java-1_6_0-ibm-devel')}
end
context 'select default for SLES 11.4' do
let(:facts) { {:osfamily => 'Suse', :operatingsystem => 'SLES', :operatingsystemrelease => '11.4'}}
it { should contain_package('java').with_name('java-1_7_0-ibm-devel')}
end
context 'select default for SLES 12.1' do
let(:facts) { {:osfamily => 'Suse', :operatingsystem => 'SLES', :operatingsystemrelease => '12.1', :operatingsystemmajrelease => '12'}}
it { should contain_package('java').with_name('java-1_7_0-openjdk-devel')}
end
context 'select jdk for OpenBSD' do
let(:facts) { {:osfamily => 'OpenBSD'} }
it { is_expected.to contain_package('java').with_name('jdk') }
end
context 'select jre for OpenBSD' do
let(:facts) { {:osfamily => 'OpenBSD'} }
let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('jre') }
end
describe 'incompatible OSs' do
[
{
# C14706
:osfamily => 'windows',
:operatingsystem => 'windows',
:operatingsystemrelease => '8.1',
},
{
# C14707
:osfamily => 'Darwin',
:operatingsystem => 'Darwin',
:operatingsystemrelease => '13.3.0',
},
{
# C14708
:osfamily => 'AIX',
:operatingsystem => 'AIX',
:operatingsystemrelease => '7100-02-00-000',
},
{
# C14708
:osfamily => 'AIX',
:operatingsystem => 'AIX',
:operatingsystemrelease => '6100-07-04-1216',
},
{
# C14708
:osfamily => 'AIX',
:operatingsystem => 'AIX',
:operatingsystemrelease => '5300-12-01-1016',
},
].each do |facts|
let(:facts) { facts }
it "is_expected.to fail on #{facts[:operatingsystem]} #{facts[:operatingsystemrelease]}" do
expect { catalogue }.to raise_error Puppet::Error, /unsupported platform/
end
end
end
end