Support for installing JCE. Fixes MODULES-1681 (#326)

* Support for installing JCE. Fixes MODULES-1681

* Disabled oracle tests. Only to be enabled, if the other configuration options match the current java download URL provided by Oracle.
This commit is contained in:
Dennis Ploeger
2018-10-18 11:07:37 +02:00
committed by david22swan
parent 390805475e
commit b53a78fbe8
3 changed files with 193 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
require 'spec_helper_acceptance'
include Unix::File
# RedHat, CentOS, Scientific, Oracle prior to 5.0 : Sun Java JDK/JRE 1.6
# RedHat, CentOS, Scientific, Oracle 5.0 < x < 6.3 : OpenJDK Java JDK/JRE 1.6
# RedHat, CentOS, Scientific, Oracle after 6.3 : OpenJDK Java JDK/JRE 1.7
@@ -79,6 +81,62 @@ bogus_alternative = "class { 'java':\n"\
" java_alternative_path => '/whatever',\n"\
'}'
# Oracle installs are disabled by default, because the links to valid oracle installations
# change often. Look the parameters up from the Oracle download URLs at https://java.oracle.com and
# enable the tests:
oracle_enabled = false
oracle_version_major = '8'
oracle_version_minor = '181'
oracle_version_build = '13'
oracle_hash = '96a7b8442fe848ef90c96a2fad6ed6d1'
install_oracle_jre = <<EOL
java::oracle {
'test_oracle_jre':
version => '#{oracle_version_major}',
version_major => '#{oracle_version_major}u#{oracle_version_minor}',
version_minor => 'b#{oracle_version_build}',
url_hash => '#{oracle_hash}',
java_se => 'jre',
}
EOL
install_oracle_jdk = <<EOL
java::oracle {
'test_oracle_jdk':
version => '#{oracle_version_major}',
version_major => '#{oracle_version_major}u#{oracle_version_minor}',
version_minor => 'b#{oracle_version_build}',
url_hash => '#{oracle_hash}',
java_se => 'jdk',
}
EOL
install_oracle_jre_jce = <<EOL
java::oracle {
'test_oracle_jre':
version => '#{oracle_version_major}',
version_major => '#{oracle_version_major}u#{oracle_version_minor}',
version_minor => 'b#{oracle_version_build}',
url_hash => '#{oracle_hash}',
java_se => 'jre',
jce => true,
}
EOL
install_oracle_jdk_jce = <<EOL
java::oracle {
'test_oracle_jdk':
version => '#{oracle_version_major}',
version_major => '#{oracle_version_major}u#{oracle_version_minor}',
version_minor => 'b#{oracle_version_build}',
url_hash => '#{oracle_hash}',
java_se => 'jdk',
jce => true,
}
EOL
context 'installing java jre', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'installs jre' do
apply_manifest(java_class_jre, catch_failures: true)
@@ -155,3 +213,37 @@ context 'with failure cases' do
end
end
end
# Test oracle java installs
context 'java::oracle', if: oracle_enabled, unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
install_path = '/usr/lib/jvm'
version_suffix = ''
if fact('osfamily') == 'RedHat' || fact('osfamily') == 'Amazon'
install_path = '/usr/java'
version_suffix = '-amd64'
end
it 'installs oracle jdk' do
apply_manifest(install_oracle_jdk, catch_failures: true)
apply_manifest(install_oracle_jdk, catch_changes: true)
result = shell("test ! -e #{install_path}/jdk1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/jre/lib/security/local_policy.jar")
expect(result.exit_code).to eq(0)
end
it 'installs oracle jre' do
apply_manifest(install_oracle_jre, catch_failures: true)
apply_manifest(install_oracle_jre, catch_changes: true)
result = shell("test ! -e #{install_path}/jre1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/lib/security/local_policy.jar")
expect(result.exit_code).to eq(0)
end
it 'installs oracle jdk with jce' do
apply_manifest(install_oracle_jdk_jce, catch_failures: true)
apply_manifest(install_oracle_jdk_jce, catch_changes: true)
result = shell("test -e #{install_path}/jdk1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/jre/lib/security/local_policy.jar")
expect(result.exit_code).to eq(0)
end
it 'installs oracle jre with jce' do
apply_manifest(install_oracle_jre_jce, catch_failures: true)
apply_manifest(install_oracle_jre_jce, catch_changes: true)
result = shell("test -e #{install_path}/jre1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/lib/security/local_policy.jar")
expect(result.exit_code).to eq(0)
end
end

View File

@@ -121,6 +121,26 @@ describe 'java::oracle', type: :define do
it { is_expected.to compile }
end
context 'when installing Oracle Java SE 6 JRE with JCE' do
let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre' } }
let(:title) { 'jre6jce' }
it do
is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip')
is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jre1.6.0_99-amd64/lib/security')
end
end
context 'when installing Oracle Java SE 6 JDK with JCE' do
let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk' } }
let(:title) { 'jre6jce' }
it do
is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip')
is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jdk1.6.0_99-amd64/jre/lib/security')
end
end
end
context 'when on CentOS 32-bit' do
@@ -207,6 +227,26 @@ describe 'java::oracle', type: :define do
it { is_expected.to compile }
end
context 'when installing Oracle Java SE 6 JRE with JCE' do
let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre' } }
let(:title) { 'jre6jce' }
it do
is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip')
is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jre1.6.0_99-amd64/lib/security')
end
end
context 'when installing Oracle Java SE 6 JDK with JCE' do
let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk' } }
let(:title) { 'jre6jce' }
it do
is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip')
is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jdk1.6.0_99-amd64/jre/lib/security')
end
end
end
context 'with Ubuntu 64-bit' do
@@ -300,6 +340,26 @@ describe 'java::oracle', type: :define do
it { is_expected.to compile }
end
context 'when installing Oracle Java SE 6 JRE with JCE' do
let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre' } }
let(:title) { 'jre6jce' }
it do
is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip')
is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/lib/jvm/jre1.6.0_99/lib/security')
end
end
context 'when installing Oracle Java SE 6 JDK with JCE' do
let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk' } }
let(:title) { 'jre6jce' }
it do
is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip')
is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/lib/jvm/jdk1.6.0_99/jre/lib/security')
end
end
end
describe 'incompatible OSes' do
[