Exposed the Puppet 'package' resource's 'install_options' parameter via a new class parameter names 'package_options*. It takes an array of strings to pass installation options to the package provider of the targer OS (yum, apt-get, ...) Added validation of $package_options array Using stdlib' validate_array function to ensure that $package_options is a valid array (also if just empty). Cleaned array validation line Made $package_options undef by default Class parameter $package_options is now set to undef by default, validation is done in the class to ensure only an array would be passed to it if set. Added case for 'package_options' parameter Will test the use of the 'package_options' parameter being passed the YUM option --downloadonly which will see YUM return 0 but package will not be installed on system. Simplified test of 'package_options' parameter As the test 'select openjdk for Fedora 21 without installing' expects with a successful YUM run but the 'java' package not present, specifying package version is irrelevant. New case for complete installation with YUM option Added new case using 'package_options' with a a YUM option expected to not prevent rpm installation. Also added distribution parameter for test of 'pacakge_options' with yum option expected to prevent package installation. Removed validation of package name Removed validation of package name as it is not meant to be testing by 'select passed value for Fedora 21 with yum option' Removed test with '--downloadonly' The test of 'package_options* with the YUM option '---downloadonly' can't seem to be validate in CI. Other test 'select passed value for Fedora 21 with yum option' covers passing a value to 'package_options* and passes test in CI.
219 lines
11 KiB
Ruby
219 lines
11 KiB
Ruby
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 { should 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 { should contain_package('java').with_name('java-1.7.0-openjdk-devel') }
|
|
end
|
|
|
|
context 'select openjdk for Centos 6.2' do
|
|
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.2'} }
|
|
it { should contain_package('java').with_name('java-1.6.0-openjdk-devel') }
|
|
it { should_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 { should contain_package('java').with_name('jre') }
|
|
it { should contain_exec('create-java-alternatives').with_command('alternatives --install /usr/bin/java java /usr/java/jre1.7.0_67/bin/java 20000') }
|
|
it { should 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 { should 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 { should 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 { should 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 { should 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 { should 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 { should contain_package('java').with_name('jdk') }
|
|
it { should_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 { should contain_package('java').with_name('java-1.6.0-openjdk-devel') }
|
|
it { should_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 { should contain_package('java').with_name('openjdk-7-jdk') }
|
|
it { should 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 { should contain_package('java').with_name('oracle-j2re1.7') }
|
|
it { should 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 { should contain_package('java').with_name('openjdk-7-jre-headless') }
|
|
it { should 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 { should contain_package('java').with_name('openjdk-6-jdk') }
|
|
it { should 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 { should contain_package('java').with_name('sun-java6-jre') }
|
|
it { should 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 { should contain_package('java').with_name('openjdk-6-jre-headless') }
|
|
it { should 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 { should contain_package('java').with_name('openjdk-7-jdk') }
|
|
it { should 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 { should 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 { should 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 { should 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 { should 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 { should 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 { should 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 { should 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 { should 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 { should contain_package('java').with_name('java-1_7_0-openjdk-devel')}
|
|
end
|
|
|
|
context 'select jdk for OpenBSD' do
|
|
let(:facts) { {:osfamily => 'OpenBSD'} }
|
|
it { should contain_package('java').with_name('jdk') }
|
|
end
|
|
|
|
context 'select jre for OpenBSD' do
|
|
let(:facts) { {:osfamily => 'OpenBSD'} }
|
|
let(:params) { { 'distribution' => 'jre' } }
|
|
it { should 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 "should fail on #{facts[:operatingsystem]} #{facts[:operatingsystemrelease]}" do
|
|
expect { catalogue }.to raise_error Puppet::Error, /unsupported platform/
|
|
end
|
|
end
|
|
end
|
|
end
|