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
|
# frozen_string_literal: true
require 'spec_helper'
describe 'java::download', type: :define do
let(:url) { 'http://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz' }
context 'with CentOS 64-bit' do
let(:facts) { { kernel: 'Linux', os: { family: 'RedHat', architecture: 'x86_64', name: 'CentOS', release: { full: '7.0' } } } }
context 'when passing URL to url parameter' do
let(:params) do
{
ensure: 'present',
version_major: '8u201',
version_minor: 'b09',
java_se: 'jdk',
url: url
}
end
let(:title) { 'jdk8' }
it {
expect(subject).to contain_archive('/tmp/jdk-8-8u201-b09-linux-x64.rpm')
}
end
context 'when no url provided' do
let(:params) do
{
ensure: 'present',
version_major: '8u201',
version_minor: 'b09',
java_se: 'jdk'
}
end
let(:title) { 'jdk8' }
it {
expect(subject).to raise_error Puppet::Error
}
end
context 'when manage_symlink is set to true' do
let(:params) do
{
ensure: 'present',
version: '6',
java_se: 'jdk',
basedir: '/usr/java',
manage_symlink: true,
symlink_name: 'java_home',
url: url
}
end
let(:title) { 'jdk6' }
it { is_expected.to contain_file('/usr/java/java_home') }
end
context 'when manage_symlink is not set' do
let(:params) do
{
ensure: 'present',
version: '6',
java_se: 'jdk',
basedir: '/usr/java',
url: url
}
end
let(:title) { 'jdk6_nosymlink' }
it { is_expected.not_to contain_file('/usr/java/java_home') }
end
end
context 'with Ubuntu 64-bit' do
let(:facts) { { kernel: 'Linux', os: { family: 'Debian', architecture: 'amd64', name: 'Ubuntu', release: { full: '18.04' } } } }
context 'when passing URL to url parameter' do
let(:params) { { ensure: 'present', version_major: '8u201', version_minor: 'b09', java_se: 'jdk', url: url } }
let(:title) { 'jdk8' }
it { is_expected.to contain_archive('/tmp/jdk-8-8u201-b09-linux-x64.tar.gz') }
end
end
context 'with Debian 64-bit' do
let(:facts) { { kernel: 'Linux', os: { family: 'Debian', architecture: 'amd64', name: 'Debian', release: { full: '10.0' } } } }
context 'when passing URL to url parameter' do
let(:params) { { ensure: 'present', version_major: '8u201', version_minor: 'b09', java_se: 'jdk', url: url } }
let(:title) { 'jdk8' }
it { is_expected.to contain_archive('/tmp/jdk-8-8u201-b09-linux-x64.tar.gz') }
end
end
describe 'incompatible OSes' do
[
{
kernel: 'Windows',
os: {
family: 'Windows',
name: 'Windows',
release: {
full: '8.1'
}
}
},
{
kernel: 'Darwin',
os: {
family: 'Darwin',
name: 'Darwin',
release: {
full: '13.3.0'
}
}
},
{
kernel: 'AIX',
os: {
family: 'AIX',
name: 'AIX',
release: {
full: '7100-02-00-000'
}
}
},
{
kernel: 'AIX',
os: {
family: 'AIX',
name: 'AIX',
release: {
full: '6100-07-04-1216'
}
}
},
{
kernel: 'AIX',
os: {
family: 'AIX',
name: 'AIX',
release: {
full: '5300-12-01-1016'
}
}
},
].each do |facts|
let(:facts) { facts }
let(:title) { 'jdk' }
it "is_expected.to fail on #{facts[:os][:name]} #{facts[:os][:release][:full]}" do
expect { catalogue }.to raise_error Puppet::Error, %r{unsupported platform}
end
end
end
end
|