-
-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #545 from duncaan/add-corretto
Add Amazon Corretto
- Loading branch information
Showing
10 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Cookbook:: java | ||
# Recipe:: corretto | ||
# This recipe installs and configures Amazon's Corretto package | ||
# https://aws.amazon.com/corretto/ | ||
|
||
include_recipe 'java::notify' | ||
|
||
unless node.recipe?('java::default') | ||
Chef::Log.warn('Using java::default instead is recommended.') | ||
|
||
# Even if this recipe is included by itself, a safety check is nice... | ||
if node['java']['java_home'].nil? || node['java']['java_home'].empty? | ||
include_recipe 'java::set_attributes_from_version' | ||
end | ||
end | ||
|
||
java_home = node['java']['java_home'] | ||
arch = node['java']['arch'] | ||
version = node['java']['jdk_version'].to_s | ||
tarball_url = node['java']['corretto'][version][arch]['url'] | ||
tarball_checksum = node['java']['corretto'][version][arch]['checksum'] | ||
bin_cmds = node['java']['corretto'][version]['bin_cmds'] | ||
|
||
include_recipe 'java::set_java_home' | ||
|
||
java_oracle_install 'jdk' do | ||
url tarball_url | ||
default node['java']['set_default'] | ||
md5 tarball_checksum | ||
app_home java_home | ||
bin_cmds bin_cmds | ||
alternatives_priority node['java']['alternatives_priority'] | ||
retries node['java']['ark_retries'] | ||
retry_delay node['java']['ark_retry_delay'] | ||
connect_timeout node['java']['ark_timeout'] | ||
use_alt_suffix node['java']['use_alt_suffix'] | ||
reset_alternatives node['java']['reset_alternatives'] | ||
download_timeout node['java']['ark_download_timeout'] | ||
proxy node['java']['ark_proxy'] | ||
action :install | ||
notifies :write, 'log[jdk-version-changed]', :immediately | ||
end | ||
|
||
if node['java']['set_default'] && platform_family?('debian') | ||
include_recipe 'java::default_java_symlink' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require 'spec_helper' | ||
|
||
describe 'java::corretto' do | ||
let(:chef_run) do | ||
runner = ChefSpec::SoloRunner.new | ||
runner.node.override['java']['jdk_version'] = '11' | ||
runner.node.override['java']['install_flavor'] = 'corretto' | ||
runner.converge('java::default') | ||
end | ||
|
||
it 'should include the notify recipe' do | ||
expect(chef_run).to include_recipe('java::notify') | ||
end | ||
|
||
it 'should include the set_java_home recipe' do | ||
expect(chef_run).to include_recipe('java::set_java_home') | ||
end | ||
|
||
it 'should configure an java_oracle_install[jdk] resource' do | ||
pending 'Testing LWRP use is not required at this time, this is tested post-converge.' | ||
this_should_not_get_executed | ||
end | ||
|
||
it 'should notify jdk-version-change' do | ||
expect(chef_run.java_oracle_install('jdk')).to notify('log[jdk-version-changed]')\ | ||
.to(:write).immediately | ||
end | ||
|
||
describe 'default-java' do | ||
context 'ubuntu' do | ||
let(:chef_run) do | ||
runner = ChefSpec::SoloRunner.new(platform: 'ubuntu', | ||
version: '18.04') | ||
runner.node.override['java']['jdk_version'] = '11' | ||
runner.node.override['java']['install_flavor'] = 'corretto' | ||
runner.converge('java::default') | ||
end | ||
|
||
it 'includes default_java_symlink' do | ||
expect(chef_run).to include_recipe('java::default_java_symlink') | ||
end | ||
end | ||
|
||
context 'centos' do | ||
let(:chef_run) do | ||
runner = ChefSpec::SoloRunner.new(platform: 'centos', version: '7.5') | ||
runner.node.override['java']['jdk_version'] = '11' | ||
runner.node.override['java']['install_flavor'] = 'corretto' | ||
runner.converge('java::default') | ||
end | ||
|
||
it 'does not include default_java_symlink' do | ||
expect(chef_run).to_not include_recipe('java::default_java_symlink') | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node.default['java']['jdk_version'] = '11' | ||
node.default['java']['install_flavor'] = 'corretto' | ||
|
||
include_recipe 'test::base' | ||
include_recipe 'java::default' | ||
include_recipe 'test::java_cert' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node.default['java']['jdk_version'] = '8' | ||
node.default['java']['install_flavor'] = 'corretto' | ||
|
||
include_recipe 'test::base' | ||
include_recipe 'java::default' | ||
include_recipe 'test::java_cert' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# the right version of java is installed | ||
describe command('java -version 2>&1') do | ||
its('stdout') { should match /11\.0\.3/ } | ||
end | ||
|
||
# alternatives were properly set | ||
# disable this until we come up with a cross platform test | ||
# describe command('update-alternatives --display jar') do | ||
# its('stdout') { should match /\/usr\/lib\/jvm\/java-8-oracle-amd64\/bin\/jar/ } | ||
# end | ||
|
||
unless os.bsd? | ||
# alternatives were properly set | ||
describe command('update-alternatives --display jar') do | ||
its('stdout') { should match %r{\/usr\/lib\/jvm\/java-11} } # https://rubular.com/r/H7J6J3q9GhJJ5A | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# the right version of java is installed | ||
describe command('java -version 2>&1') do | ||
its('stdout') { should match /1\.8/ } | ||
end | ||
|
||
# alternatives were properly set | ||
# disable this until we come up with a cross platform test | ||
# describe command('update-alternatives --display jar') do | ||
# its('stdout') { should match /\/usr\/lib\/jvm\/java-8-oracle-amd64\/bin\/jar/ } | ||
# end | ||
|
||
# jce is setup properly | ||
describe command('java -jar /tmp/UnlimitedSupportJCETest.jar') do | ||
its('stdout') { should match /isUnlimitedSupported=TRUE/ } | ||
its('stdout') { should match /strength: 2147483647/ } | ||
end |