Skip to content

Commit aa17ed1

Browse files
authored
Merge pull request #545 from duncaan/add-corretto
Add Amazon Corretto
2 parents 03afa97 + 1cc54d0 commit aa17ed1

File tree

10 files changed

+184
-0
lines changed

10 files changed

+184
-0
lines changed

.kitchen.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,25 @@ suites:
198198
- test/integration/remove-adoptopenjdk
199199
attrs:
200200
- test/integration/adoptopenjdk/attributes/adoptopenjdk-11-openj9.yml
201+
- name: corretto-8
202+
includes:
203+
- amazon-linux
204+
- centos-6
205+
- centos-7
206+
- debian-8
207+
- debian-9
208+
- ubuntu-16.04
209+
- ubuntu-18.04
210+
run_list:
211+
- recipe[test::corretto8]
212+
- name: corretto-11
213+
includes:
214+
- amazon-linux
215+
- centos-6
216+
- centos-7
217+
- debian-8
218+
- debian-9
219+
- ubuntu-16.04
220+
- ubuntu-18.04
221+
run_list:
222+
- recipe[test::corretto11]

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This file is used to list changes made in each version of the Java cookbook.
44

55
## Unreleased
66

7+
- Added new install flavor "corretto" for Amazon's Corretto distribution of OpenJDK
8+
79
## 4.0.0 - 2019-04-19
810

911
- Added new install flavor "adoptopenjdk" for AdoptOpenJDK's distribution of Java

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ While public YUM repos for Oracle Java 7 and prior are available, you need to do
178178

179179
This recipe installs the `AdoptOpenJDK` flavor of Java from [https://adoptopenjdk.net/.](https://adoptopenjdk.net/.) It also uses the `alternatives` system on the RHEL/Debian families to set the default Java.
180180

181+
### Amazon Corretto
182+
This recipe installs the `Amazon Corretto` flavor of OpenJDK from https://aws.amazon.com/corretto/. It also uses the `alternatives` system on RHEL/Debian families to set the default Java.
183+
181184
### windows
182185

183186
Because as of 26 March 2012 you can no longer directly download the JDK msi from Oracle's website without using a special cookie. This recipe requires you to set `node['java']['oracle']['accept_oracle_download_terms']` to true or host it internally on your own http repo or s3 bucket.

attributes/default.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,12 @@
173173
default['java']['adoptopenjdk']['12']['x86_64']['openj9-large-heap']['checksum'] = nil
174174
# TODO: Update list when released
175175
default['java']['adoptopenjdk']['12']['bin_cmds']['default'] = %w(jar jarsigner java javac javadoc javap jcmd jconsole jdb jdeprscan jdeps jhsdb jimage jinfo jjs jlink jmap jmod jps jrunscript jshell jstack jstat jstatd keytool pack200 rmic rmid rmiregistry serialver unpack200)
176+
177+
# Amazon Corretto
178+
default['java']['corretto']['8']['x86_64']['url'] = 'https://d3pxv6yz143wms.cloudfront.net/8.212.04.2/amazon-corretto-8.212.04.2-linux-x64.tar.gz'
179+
default['java']['corretto']['8']['x86_64']['checksum'] = '782d5452cd7395340d791dbdd0f418a8'
180+
default['java']['corretto']['8']['bin_cmds'] = %w(appletviewer clhsdb extcheck hsdb idlj jar jarsigner java java-rmi.cgi javac javadoc javafxpackager javah javap javapackager jcmd jconsole jdb jdeps jhat jinfo jjs jmap jps jrunscript jsadebugd jstack jstat jstatd keytool native2ascii orbd pack200 policytool rmic rmid rmiregistry schemagen serialver servertool tnameserv unpack200 wsgen wsimport xjc)
181+
182+
default['java']['corretto']['11']['x86_64']['url'] = 'https://d3pxv6yz143wms.cloudfront.net/11.0.3.7.1/amazon-corretto-11.0.3.7.1-linux-x64.tar.gz'
183+
default['java']['corretto']['11']['x86_64']['checksum'] = '08a0cea184824c5477a62ce6a6a0fb0b'
184+
default['java']['corretto']['11']['bin_cmds'] = %w(jaotc jar jarsigner java javac javadoc javap jcmd jconsole jdb jdeprscan jdeps jhsdb jimage jinfo jjs jlink jmap jmod jps jrunscript jshell jstack jstat jstatd keytool pack200 rmic rmid rmiregistry serialver unpack200)

recipes/corretto.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Cookbook:: java
2+
# Recipe:: corretto
3+
# This recipe installs and configures Amazon's Corretto package
4+
# https://aws.amazon.com/corretto/
5+
6+
include_recipe 'java::notify'
7+
8+
unless node.recipe?('java::default')
9+
Chef::Log.warn('Using java::default instead is recommended.')
10+
11+
# Even if this recipe is included by itself, a safety check is nice...
12+
if node['java']['java_home'].nil? || node['java']['java_home'].empty?
13+
include_recipe 'java::set_attributes_from_version'
14+
end
15+
end
16+
17+
java_home = node['java']['java_home']
18+
arch = node['java']['arch']
19+
version = node['java']['jdk_version'].to_s
20+
tarball_url = node['java']['corretto'][version][arch]['url']
21+
tarball_checksum = node['java']['corretto'][version][arch]['checksum']
22+
bin_cmds = node['java']['corretto'][version]['bin_cmds']
23+
24+
include_recipe 'java::set_java_home'
25+
26+
java_oracle_install 'jdk' do
27+
url tarball_url
28+
default node['java']['set_default']
29+
md5 tarball_checksum
30+
app_home java_home
31+
bin_cmds bin_cmds
32+
alternatives_priority node['java']['alternatives_priority']
33+
retries node['java']['ark_retries']
34+
retry_delay node['java']['ark_retry_delay']
35+
connect_timeout node['java']['ark_timeout']
36+
use_alt_suffix node['java']['use_alt_suffix']
37+
reset_alternatives node['java']['reset_alternatives']
38+
download_timeout node['java']['ark_download_timeout']
39+
proxy node['java']['ark_proxy']
40+
action :install
41+
notifies :write, 'log[jdk-version-changed]', :immediately
42+
end
43+
44+
if node['java']['set_default'] && platform_family?('debian')
45+
include_recipe 'java::default_java_symlink'
46+
end

spec/corretto_spec.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
require 'spec_helper'
2+
3+
describe 'java::corretto' do
4+
let(:chef_run) do
5+
runner = ChefSpec::SoloRunner.new
6+
runner.node.override['java']['jdk_version'] = '11'
7+
runner.node.override['java']['install_flavor'] = 'corretto'
8+
runner.converge('java::default')
9+
end
10+
11+
it 'should include the notify recipe' do
12+
expect(chef_run).to include_recipe('java::notify')
13+
end
14+
15+
it 'should include the set_java_home recipe' do
16+
expect(chef_run).to include_recipe('java::set_java_home')
17+
end
18+
19+
it 'should configure an java_oracle_install[jdk] resource' do
20+
pending 'Testing LWRP use is not required at this time, this is tested post-converge.'
21+
this_should_not_get_executed
22+
end
23+
24+
it 'should notify jdk-version-change' do
25+
expect(chef_run.java_oracle_install('jdk')).to notify('log[jdk-version-changed]')\
26+
.to(:write).immediately
27+
end
28+
29+
describe 'default-java' do
30+
context 'ubuntu' do
31+
let(:chef_run) do
32+
runner = ChefSpec::SoloRunner.new(platform: 'ubuntu',
33+
version: '18.04')
34+
runner.node.override['java']['jdk_version'] = '11'
35+
runner.node.override['java']['install_flavor'] = 'corretto'
36+
runner.converge('java::default')
37+
end
38+
39+
it 'includes default_java_symlink' do
40+
expect(chef_run).to include_recipe('java::default_java_symlink')
41+
end
42+
end
43+
44+
context 'centos' do
45+
let(:chef_run) do
46+
runner = ChefSpec::SoloRunner.new(platform: 'centos', version: '7.5')
47+
runner.node.override['java']['jdk_version'] = '11'
48+
runner.node.override['java']['install_flavor'] = 'corretto'
49+
runner.converge('java::default')
50+
end
51+
52+
it 'does not include default_java_symlink' do
53+
expect(chef_run).to_not include_recipe('java::default_java_symlink')
54+
end
55+
end
56+
end
57+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node.default['java']['jdk_version'] = '11'
2+
node.default['java']['install_flavor'] = 'corretto'
3+
4+
include_recipe 'test::base'
5+
include_recipe 'java::default'
6+
include_recipe 'test::java_cert'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node.default['java']['jdk_version'] = '8'
2+
node.default['java']['install_flavor'] = 'corretto'
3+
4+
include_recipe 'test::base'
5+
include_recipe 'java::default'
6+
include_recipe 'test::java_cert'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# the right version of java is installed
2+
describe command('java -version 2>&1') do
3+
its('stdout') { should match /11\.0\.3/ }
4+
end
5+
6+
# alternatives were properly set
7+
# disable this until we come up with a cross platform test
8+
# describe command('update-alternatives --display jar') do
9+
# its('stdout') { should match /\/usr\/lib\/jvm\/java-8-oracle-amd64\/bin\/jar/ }
10+
# end
11+
12+
unless os.bsd?
13+
# alternatives were properly set
14+
describe command('update-alternatives --display jar') do
15+
its('stdout') { should match %r{\/usr\/lib\/jvm\/java-11} } # https://rubular.com/r/H7J6J3q9GhJJ5A
16+
end
17+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# the right version of java is installed
2+
describe command('java -version 2>&1') do
3+
its('stdout') { should match /1\.8/ }
4+
end
5+
6+
# alternatives were properly set
7+
# disable this until we come up with a cross platform test
8+
# describe command('update-alternatives --display jar') do
9+
# its('stdout') { should match /\/usr\/lib\/jvm\/java-8-oracle-amd64\/bin\/jar/ }
10+
# end
11+
12+
# jce is setup properly
13+
describe command('java -jar /tmp/UnlimitedSupportJCETest.jar') do
14+
its('stdout') { should match /isUnlimitedSupported=TRUE/ }
15+
its('stdout') { should match /strength: 2147483647/ }
16+
end

0 commit comments

Comments
 (0)