Skip to content

Commit

Permalink
Fix tests (#114)
Browse files Browse the repository at this point in the history
* Add tar.gz

Signed-off-by: Timur Gadiev <[email protected]>

* Add azure tests

Signed-off-by: Timur Gadiev <[email protected]>

* Change corretto_linux_distro

Signed-off-by: Timur Gadiev <[email protected]>

* Fix corretto

Signed-off-by: Timur Gadiev <[email protected]>

* Fix adopt

Signed-off-by: Timur Gadiev <[email protected]>

* Update tests

Signed-off-by: Timur Gadiev <[email protected]>

* Fix #112

Signed-off-by: Timur Gadiev <[email protected]>
  • Loading branch information
tgadiev authored Jul 6, 2020
1 parent e26ce65 commit 8d88e24
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 51 deletions.
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Lint:
tags:
- lint

Docker java-on-defaults:
.Docker java-on-defaults:
stage: deployment test
script:
- molecule test -s default
Expand Down Expand Up @@ -92,10 +92,10 @@ AZURE java-8 Windows:
- aws

# Windows tests are preferrably run in Azure
AZURE openjdk-13 Windows chocolatey:
AZURE openjdk-14 Windows chocolatey:
stage: deployment test
script:
- molecule test -s cloud-azure-windows-openjdk13-chocolatey
- molecule test -s cloud-azure-windows-openjdk14-chocolatey
tags:
- azure

Expand Down Expand Up @@ -178,7 +178,7 @@ AZURE java-11 Windows:
tags:
- azure

AWS java-12:
.AWS java-12:
variables:
AWS_REGION: us-east-1
stage: deployment test
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ java role
=========
[![License](https://img.shields.io/badge/license-Apache-green.svg?style=flat)](https://raw.githubusercontent.com/lean-delivery/ansible-role-java/master/LICENSE)
[![Build Status](https://travis-ci.org/lean-delivery/ansible-role-java.svg?branch=master)](https://travis-ci.org/lean-delivery/ansible-role-java)
[![Build Status](https://gitlab.com/lean-delivery/ansible-role-java/badges/master/build.svg)](https://gitlab.com/lean-delivery/ansible-role-java/pipelines)
[![Build Status](https://gitlab.com/lean-delivery/ansible-role-java/badges/master/pipeline.svg)](https://gitlab.com/lean-delivery/ansible-role-java/pipelines)
[![Galaxy](https://img.shields.io/badge/galaxy-lean__delivery.java-blue.svg)](https://galaxy.ansible.com/lean_delivery/java)
![Ansible](https://img.shields.io/ansible/role/d/27687.svg)
![Ansible](https://img.shields.io/badge/dynamic/json.svg?label=min_ansible_version&url=https%3A%2F%2Fgalaxy.ansible.com%2Fapi%2Fv1%2Froles%2F27687%2F&query=$.min_ansible_version)
Expand Down
19 changes: 19 additions & 0 deletions molecule/cloud-aws-coretto-11/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,25 @@ platforms:
- corretto
- repositories

- name: test-aws-Amazon2-corretto-11-fb
image: ami-0b898040803850657
platform: amazon2
instance_type: t3.micro
profile_name: epmldi-instance-profile
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
spot_price: 0.004
security_group_name:
- default
wait_timeout: 1800
ssh_user: ec2-user
groups:
- rhel_family
- corretto
- fallback
- package

provisioner:
name: ansible
log: false
Expand Down
3 changes: 2 additions & 1 deletion molecule/cloud-aws-direct-11/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ provisioner:
group_vars:
web:
transport: web
transport_web: "{{ lookup('env','STORAGE_AWS') }}/oracle-java/jdk-11.0.2_linux-x64_bin.tar.gz"
transport_web: >-
{{ hostvars['localhost']['s3_link_tar']['url'] }}
s3:
transport: s3
transport_s3_bucket: java-molecule-s3-test
Expand Down
16 changes: 16 additions & 0 deletions molecule/cloud-aws-direct-11/playbook.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
---
- name: Prepare host to S3 transport
hosts: localhost
gather_facts: true
vars:
transport_s3_bucket: java-molecule-s3-test
java_download_path: /tmp
tasks:

- name: Generate s3 link for tar.gz
aws_s3:
bucket: '{{ transport_s3_bucket }}'
object: java/jdk-11.0.2_linux-x64_bin.tar.gz
mode: geturl
register: s3_link_tar
changed_when: false

- name: Converge
hosts: all
roles:
Expand Down
6 changes: 4 additions & 2 deletions molecule/cloud-aws-direct-6/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ provisioner:
java_major_version: 6
java_tarball_install: true
transport: web
transport_web: "{{ lookup('env','STORAGE_AWS') }}/oracle-java/jdk-6u45-linux-x64.tar.gz"
transport_web: >-
{{ hostvars['localhost']['s3_link_tar']['url'] }}
java_unlimited_policy_enabled: true
java_unlimited_policy_transport: fallback

Expand All @@ -67,7 +68,8 @@ provisioner:
java_major_version: 6
java_tarball_install: false
transport: web
transport_web: "{{ lookup('env','STORAGE_AWS') }}/oracle-java/jdk-6u45-linux-x64.rpm"
transport_web: >-
{{ hostvars['localhost']['s3_link_rpm']['url'] }}
java_unlimited_policy_enabled: true
java_unlimited_policy_transport: fallback
playbooks:
Expand Down
23 changes: 23 additions & 0 deletions molecule/cloud-aws-direct-6/playbook.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
---
- name: Prepare host to S3 transport
hosts: localhost
gather_facts: true
vars:
transport_s3_bucket: java-molecule-s3-test
java_download_path: /tmp
tasks:
- name: Generate s3 link for rpm
aws_s3:
bucket: '{{ transport_s3_bucket }}'
object: 'java/jdk-6u45-linux-x64.rpm'
mode: geturl
register: s3_link_rpm
changed_when: false

- name: Generate s3 link for tar.gz
aws_s3:
bucket: '{{ transport_s3_bucket }}'
object: 'java/jdk-6u45-linux-x64.tar.gz'
mode: geturl
register: s3_link_tar
changed_when: false

- name: Converge
hosts: all
roles:
Expand Down
2 changes: 1 addition & 1 deletion molecule/cloud-azure-adoptopenjdk-windows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ provisioner:
java_major_version: 11
chocolatey:
transport: chocolatey
java_major_version: 13
java_major_version: 14
windows:
ansible_password: "{{ lookup('env', 'WINRM_ADMIN_PWD') | default('M0leCule123!', true) }}"
ansible_winrm_transport: credssp
Expand Down
2 changes: 1 addition & 1 deletion molecule/cloud-azure-windows-8/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ provisioner:
oracle-java/jdk-8u45-windows-x64.exe?\
{{ hostvars['localhost']['storage_sig']['response']['serviceSasToken'] }}"
java_unlimited_policy_transport: fallback
java_unlimited_policy_enabled: true
java_unlimited_policy_enabled: false
playbooks:
create: ../resources/provisioning/AZURE/create.yml
prepare: prepare.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ provisioner:
chocolatey:
java_distribution: openjdk
transport: chocolatey
java_major_version: 13
java_major_version: 14
playbooks:
create: ../resources/provisioning/AZURE/create.yml
destroy: ../resources/provisioning/AZURE/destroy.yml
verify: ../resources/tests/verify_win.yml
lint:
name: ansible-lint
scenario:
name: cloud-azure-windows-openjdk13-chocolatey
name: cloud-azure-windows-openjdk14-chocolatey
verifier:
name: ansible
lint:
Expand Down
18 changes: 6 additions & 12 deletions tasks/Linux/fetch/corretto-fallback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,17 @@
msg: Amazon Corretto currently supports x64 platform only
when: java_arch != 'x64'

- name: 'Fetch root page {{ corretto_root_page }}'
uri:
url: '{{ corretto_root_page }}'
return_content: true
register: root_page

- name: Find release url
set_fact:
release_url: >-
{{ root_page['content']
| regex_search('(https://corretto.aws/downloads/latest/amazon-corretto-'
~ java_major_version ~ '-' ~ java_arch ~ '-linux-' ~ java_package ~'\.' ~ java_package_type ~')')
{{ 'https://corretto.aws/downloads/latest/amazon-corretto-'
~ java_major_version ~ '-' ~ java_arch ~ '-' ~ corretto_linux_distro ~ '-' ~ java_package ~'.'
~ java_package_type
}}
release_checksum: >-
{{ root_page['content']
| regex_search('(https://corretto.aws/downloads/latest_checksum/amazon-corretto-'
~ java_major_version ~ '-' ~ java_arch ~ '-linux-' ~ java_package ~ '\.' ~ java_package_type ~')')
{{ 'https://corretto.aws/downloads/latest_checksum/amazon-corretto-'
~ java_major_version ~ '-' ~ java_arch ~ '-' ~ corretto_linux_distro ~ '-' ~ java_package ~ '.'
~ java_package_type
}}
- name: 'Download artifact from {{ release_url }}'
Expand Down
8 changes: 0 additions & 8 deletions tasks/Linux/install/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
---
- name: debug jdk_package
debug:
var: jdk_package

- name: debug java_artifact
debug:
var: java_artifact

- name: Install java packages
yum:
name: '{{ (transport == "repositories") | ternary(jdk_package, java_artifact) }}'
Expand Down
18 changes: 6 additions & 12 deletions tasks/Win32NT/fetch/corretto-fallback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,17 @@
msg: Amazon Corretto currently supports x64 platform only
when: java_arch != 'x64'

- name: 'Fetch root page {{ corretto_root_page }}'
win_uri:
url: '{{ corretto_root_page }}'
return_content: true
register: root_page

- name: Find release url
set_fact:
release_url: >-
{{ root_page['content']
| regex_search('(https://corretto.aws/downloads/latest/amazon-corretto-'
~ java_major_version ~ '-' ~ java_arch ~ '-windows-' ~ java_package ~'\.' ~ java_package_type ~')')
{{ 'https://corretto.aws/downloads/latest/amazon-corretto-'
~ java_major_version ~ '-' ~ java_arch ~ '-windows-' ~ java_package ~'.'
~ java_package_type
}}
release_checksum: >-
{{ root_page['content']
| regex_search('(https://corretto.aws/downloads/latest_checksum/amazon-corretto-'
~ java_major_version ~ '-' ~ java_arch ~ '-windows-' ~ java_package ~ '\.' ~ java_package_type ~')')
{{ 'https://corretto.aws/downloads/latest_checksum/amazon-corretto-'
~ java_major_version ~ '-' ~ java_arch ~ '-windows-' ~ java_package ~ '.'
~ java_package_type
}}
- name: 'Download artifact from {{ release_url }}'
Expand Down
1 change: 1 addition & 0 deletions tasks/Win32NT/finalize_paths.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---

- name: Find java_folder
win_find:
paths: '{{ java_path }}'
Expand Down
8 changes: 4 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@
loop_var: transport_driver

- name: Choose platform based task
include_tasks: '{{ platform }}'
include_tasks: '{{ java_os_platform }}'
with_first_found:
- '{{ ansible_system }}/system_{{ transport }}.yml'
- '{{ ansible_system }}/system_{{ java_binary_type }}.yml'
- '{{ ansible_system }}/system.yml'
- not-supported.yml
loop_control:
loop_var: platform
loop_var: java_os_platform

- name: Finalize binary paths
include_tasks: '{{ ansible_system }}/finalize_paths.yml'
when: java_setup_path | bool

- name: Apply security policy patch
include_tasks: '{{ platform }}'
include_tasks: '{{ java_os_platform }}'
with_first_found:
- '{{ ansible_system }}/security_policy.yml'
- not-supported.yml
loop_control:
loop_var: platform
loop_var: java_os_platform
when:
- java_setup_path
- java_unlimited_policy_enabled
Expand Down
8 changes: 5 additions & 3 deletions vars/java_distro_configs/corretto_vars.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
corretto_root_page: https://docs.aws.amazon.com/corretto/latest/corretto-{{ java_major_version }}-ug/downloads-list.partial.html

parts: >-
{{ java_artifact_basename | default('undefined', true)
Expand All @@ -8,10 +7,13 @@ parts: >-
~ '(linux|windows)?[-]*.*\.(deb|rpm|tar\.gz|msi|zip)')
| default([[]], true) | first | list }}
corretto_linux_distro: >-
{{ (ansible_distribution == 'Amazon') | ternary('al2', 'linux') }}
java_product_id_ver:
8: '{0D179FFA-5BD7-4775-83C2-7770EFF5D7EC}'
11: '{F8D0022C-B409-42FE-9124-CDE4F2F487E0}'
8: '{86C0B400-6A93-4979-8E5E-46152223B361}'
11: '{6B99B794-0612-4841-BC11-C09DEB8AA0C6}'

jdk_package: >-
{{ (java_major_version|int == 11) | ternary(corretto11_package, corretto8_package) }}
Expand Down

0 comments on commit 8d88e24

Please sign in to comment.