diff --git a/spec/acceptance/install_spec.rb b/spec/acceptance/install_spec.rb index 7bfa37b..54411fb 100644 --- a/spec/acceptance/install_spec.rb +++ b/spec/acceptance/install_spec.rb @@ -2,32 +2,6 @@ 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 -# Debian Jesse & Ubuntu 14.04 : OpenJDK Java JDK/JRE 1.7 or Oracle Java JDK/JRE 1.6 -# Solaris (what versions?) : Java JDK/JRE 1.7 -# OpenSuSE : OpenJDK Java JDK/JRE 1.7 -# SLES : IBM Java JDK/JRE 1.6 - -# C14677 -# C14678 -# C14679 -# C14680 -# C14681 -# C14682 -# C14684 -# C14687 -# C14692 -# C14696 -# C14697 -# C14700 check on solaris 11 -# C14701 check on sles 11 -# C14703 -# C14723 Where is oracle linux 5? -# C14724 Where is oracle linux 5? -# C14771 Where is redhat 7? Centos 7? - java_class_jre = "class { 'java':\n"\ " distribution => 'jre',\n"\ '}' @@ -56,10 +30,6 @@ oracle_jdk = "class { 'java':\n"\ " distribution => 'oracle-jdk',\n"\ '}' -incorrect_version = "class { 'java':\n"\ - " version => '14.5',\n"\ - '}' - blank_version = "class { 'java':\n"\ " version => '',\n"\ '}' @@ -91,7 +61,7 @@ oracle_version_minor = '201' oracle_version_build = '09' oracle_hash = '42970487e3af4f5aa5bca3f542482c60' -install_oracle_jre = < '#{oracle_version_major}', @@ -100,9 +70,6 @@ install_oracle_jre = < '#{oracle_hash}', java_se => 'jre', } -EOL - -install_oracle_jdk = < '#{oracle_version_major}', @@ -123,6 +90,7 @@ install_oracle_jre_jce = < 'jre', jce => true, } + EOL install_oracle_jdk_jce = < 'jdk' } } - it { is_expected.to contain_package('java').with_name('openjdk-8-jdk') } - it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/') } + it { is_expected.to contain_package('java').with_name('openjdk-7-jdk') } + it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64/') } end - context 'when select jre for Ubuntu Vivid (15.04)' do - let(:facts) { { osfamily: 'Debian', operatingsystem: 'Ubuntu', lsbdistcodename: 'vivid', operatingsystemrelease: '15.04', architecture: 'amd64' } } + context 'when select jre for Ubuntu Trusty (14.04)' do + let(:facts) { { osfamily: 'Debian', operatingsystem: 'Ubuntu', lsbdistcodename: 'trusty', operatingsystemrelease: '14.04', architecture: 'amd64' } } let(:params) { { 'distribution' => 'jre' } } - it { is_expected.to contain_package('java').with_name('openjdk-8-jre-headless') } - it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/') } + it { is_expected.to contain_package('java').with_name('openjdk-7-jre-headless') } + it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64/') } end context 'when select jdk for Ubuntu xenial (16.04) on ARM' do @@ -85,20 +85,6 @@ describe 'java', type: :class do it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-arm64/') } end - context 'when select openjdk for Amazon Linux' do - let(:facts) { { osfamily: 'RedHat', operatingsystem: 'Amazon', operatingsystemrelease: '3.4.43-43.43.amzn1.x86_64', architecture: 'x86_64' } } - - it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') } - it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-x86_64/') } - end - - context 'when select passed value for Amazon Linux' do - let(:facts) { { osfamily: 'RedHat', operatingsystem: 'Amazon', operatingsystemrelease: '5.3.4.43-43.43.amzn1.x86_64', architecture: 'x86_64' } } - let(:params) { { 'distribution' => 'jre' } } - - it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') } - end - context 'when select openjdk for Oracle Linux' do let(:facts) { { osfamily: 'RedHat', operatingsystem: 'OracleLinux', operatingsystemrelease: '6.4', architecture: 'x86_64' } } @@ -169,20 +155,6 @@ describe 'java', type: :class do it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/') } end - context 'when select jdk for OpenBSD' do - let(:facts) { { osfamily: 'OpenBSD', architecture: 'x86_64' } } - - it { is_expected.to contain_package('java').with_name('jdk') } - it { is_expected.not_to contain_file_line('java-home-environment') } - end - - context 'when select jre for OpenBSD' do - let(:facts) { { osfamily: 'OpenBSD', architecture: 'x86_64' } } - let(:params) { { 'distribution' => 'jre' } } - - it { is_expected.to contain_package('java').with_name('jre') } - end - describe 'custom java package' do let(:facts) { { osfamily: 'Debian', operatingsystem: 'Debian', lsbdistcodename: 'jessie', operatingsystemrelease: '8.6', architecture: 'amd64' } } @@ -218,31 +190,26 @@ describe 'java', type: :class do 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', diff --git a/spec/defines/oracle_spec.rb b/spec/defines/oracle_spec.rb index c9252d1..43b6d32 100644 --- a/spec/defines/oracle_spec.rb +++ b/spec/defines/oracle_spec.rb @@ -398,7 +398,6 @@ describe 'java::oracle', type: :define do describe 'incompatible OSes' do [ { - # C14706 kernel: 'Windows', os: { family: 'Windows', @@ -409,7 +408,6 @@ describe 'java::oracle', type: :define do }, }, { - # C14707 kernel: 'Darwin', os: { family: 'Darwin', @@ -420,7 +418,6 @@ describe 'java::oracle', type: :define do }, }, { - # C14708 kernel: 'AIX', os: { family: 'AIX', @@ -431,7 +428,6 @@ describe 'java::oracle', type: :define do }, }, { - # C14709 kernel: 'AIX', os: { family: 'AIX', @@ -442,7 +438,6 @@ describe 'java::oracle', type: :define do }, }, { - # C14710 kernel: 'AIX', os: { family: 'AIX', diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 0bda578..db02d65 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -21,3 +21,17 @@ RSpec.configure do |c| # Readable test descriptions c.formatter = :documentation end + +def idempotent_apply(hosts, manifest, opts = {}, &block) + block_on hosts, opts do |host| + file_path = host.tmpfile('apply_manifest.pp') + create_remote_file(host, file_path, manifest + "\n") + + puppet_apply_opts = { :verbose => nil, 'detailed-exitcodes' => nil } + on_options = { acceptable_exit_codes: [0, 2] } + on host, puppet('apply', file_path, puppet_apply_opts), on_options, &block + puppet_apply_opts2 = { :verbose => nil, 'detailed-exitcodes' => nil } + on_options2 = { acceptable_exit_codes: [0] } + on host, puppet('apply', file_path, puppet_apply_opts2), on_options2, &block + end +end diff --git a/spec/unit/facter/java_default_home_spec.rb b/spec/unit/facter/java_default_home_spec.rb index 4d2accf..31ecd68 100644 --- a/spec/unit/facter/java_default_home_spec.rb +++ b/spec/unit/facter/java_default_home_spec.rb @@ -47,7 +47,7 @@ describe 'java_default_home' do context 'when java not present, return nil' do it do allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls - expect(Facter::Util::Resolution).to receive(:which).with('java').at_least(1).and_return(false) + expect(Facter::Util::Resolution).to receive(:which).with('java').at_least(1).and_return(nil) expect(Facter.value(:java_default_home)).to be_nil end end diff --git a/spec/unit/facter/java_libjvm_path_spec.rb b/spec/unit/facter/java_libjvm_path_spec.rb index df2ea28..b6277cf 100644 --- a/spec/unit/facter/java_libjvm_path_spec.rb +++ b/spec/unit/facter/java_libjvm_path_spec.rb @@ -1,17 +1,25 @@ require 'spec_helper' describe 'java_libjvm_path' do + let(:java_default_home) { '/usr/lib/jvm/java-8-openjdk-amd64' } + before(:each) do Facter.clear allow(Facter.fact(:kernel)).to receive(:value).once.and_return('Linux') - java_default_home = '/usr/lib/jvm/java-8-openjdk-amd64' allow(Facter.fact(:java_default_home)).to receive(:value).once.and_return(java_default_home) - allow(Dir).to receive(:glob).with("#{java_default_home}/jre/lib/**/libjvm.so").and_return(['/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so']) end - context 'when on Linux, return libjvm path' do + context 'when libjvm exists' do it do + allow(Dir).to receive(:glob).with("#{java_default_home}/jre/lib/**/libjvm.so").and_return(['/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so']) expect(Facter.value(:java_libjvm_path)).to eql '/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server' end end + + context 'when libjvm does not exist' do + it do + allow(Dir).to receive(:glob).with("#{java_default_home}/jre/lib/**/libjvm.so").and_return([]) + expect(Facter.value(:java_libjvm_path)).to be nil + end + end end