Skip to content

Commit 6e68bb0

Browse files
Merge pull request #12 from guidograzioli/molecule
add molecule tests
2 parents efe25f5 + d2397bf commit 6e68bb0

File tree

8 files changed

+219
-4
lines changed

8 files changed

+219
-4
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,52 @@ jobs:
126126
"python-version": "3.9"
127127
}
128128
]
129+
molecule:
130+
runs-on: ubuntu-latest
131+
strategy:
132+
matrix:
133+
python_version: ["3.11"]
134+
ansible_version: ["2.14", "2.15"]
135+
molecule_test:
136+
- stage_eap
137+
steps:
138+
- name: Check out code
139+
uses: actions/checkout@v3
140+
with:
141+
path: ansible_collections/middleware_automation/common
142+
143+
- name: Set up Python ${{ matrix.python_version }}
144+
uses: actions/setup-python@v4
145+
with:
146+
python-version: ${{ matrix.python_version }}
147+
cache: 'pip'
148+
149+
- name: Create default collection path
150+
run: |
151+
mkdir -p /home/runner/.ansible/
152+
ln -s /home/runner/work/common/common /home/runner/.ansible/collections
153+
154+
- name: Install ansible and molecule
155+
run: |
156+
python -m pip install --upgrade pip
157+
pip install 'molecule>=4.0.4' 'molecule-plugins[docker]>=23.0.0' ansible-core==${{ matrix.ansible_version }}
158+
if [ -f ansible_collections/middleware_automation/common/requirements.txt ]; then
159+
pip install -r ansible_collections/middleware_automation/common/requirements.txt
160+
fi
161+
if [ -f ansible_collections/middleware_automation/common/requirements.yml ]; then
162+
ansible-galaxy collection install -r ansible_collections/middleware_automation/common/requirements.yml -p /home/runner/.ansible/collections --force-with-deps
163+
fi
164+
if [ -f ansible_collections/middleware_automation/common/molecule/requirements.yml ]; then
165+
ansible-galaxy collection install -r ansible_collections/middleware_automation/common/molecule/requirements.yml -p /home/runner/.ansible/collections
166+
fi
167+
168+
- name: Run molecule test
169+
run: molecule test -s ${{ matrix.molecule_test }}
170+
working-directory: ./ansible_collections/middleware_automation/common
171+
env:
172+
PY_COLORS: '1'
173+
ANSIBLE_FORCE_COLOR: '1'
174+
PROD_JBOSSNETWORK_API_CLIENTID: ${{ secrets.PROD_JBOSSNETWORK_API_CLIENTID }}
175+
PROD_JBOSSNETWORK_API_SECRET: ${{ secrets.PROD_JBOSSNETWORK_API_SECRET }}
176+
STAGE_JBOSSNETWORK_API_CLIENTID: ${{ secrets.STAGE_JBOSSNETWORK_API_CLIENTID }}
177+
STAGE_JBOSSNETWORK_API_SECRET: ${{ secrets.STAGE_JBOSSNETWORK_API_SECRET }}

.github/workflows/docs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ jobs:
2626
pages: write
2727
steps:
2828
- name: Check out code
29-
uses: actions/checkout@v2
29+
uses: actions/checkout@v3
3030
with:
3131
path: ansible_collections/middleware_automation/common
3232
fetch-depth: 0
3333

3434
- name: Set up Python
35-
uses: actions/setup-python@v2
35+
uses: actions/setup-python@v4
3636
with:
3737
python-version: 3.9
38+
cache: 'pip'
3839

3940
- name: Install doc dependencies
4041
run: |

.github/workflows/release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ jobs:
2424
token: ${{ secrets.TRIGGERING_PAT }}
2525

2626
- name: Set up Python
27-
uses: actions/setup-python@v1
27+
uses: actions/setup-python@v4
2828
with:
2929
python-version: "3.x"
30+
cache: 'pip'
3031

3132
- name: Get current version
3233
id: get_version
@@ -100,4 +101,4 @@ jobs:
100101
token: ${{ secrets.TRIGGERING_PAT }}
101102
repository: ${{ matrix.repo }}
102103
event-type: "Dependency released - Common v${{ needs.release.outputs.tag_version }}"
103-
client-payload: '{ "github": ${{toJson(github)}} }'
104+
client-payload: '{ "github": ${{toJson(github)}} }'

molecule/prod_eap/converge.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
- name: Converge
3+
hosts: localhost
4+
gather_facts: no
5+
tasks:
6+
- name: Search EAP Product
7+
middleware_automation.common.product_search:
8+
client_id: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_CLIENTID') }}"
9+
client_secret: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_SECRET') }}"
10+
product_type: DISTRIBUTION
11+
product_version: '7.4'
12+
product_category: appplatform
13+
register: rhn_products
14+
no_log: false
15+
16+
- name: Search install zipfile
17+
ansible.builtin.set_fact:
18+
rhn_filtered_products: "{{ rhn_products.results | selectattr('file_path', 'match', '[^/]*/jboss-eap-7.4.0.zip$') }}"
19+
20+
- name: Retrieve product download using JBossNetwork API
21+
middleware_automation.common.product_search:
22+
client_id: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_CLIENTID') }}"
23+
client_secret: "{{ lookup('env', 'PROD_JBOSSNETWORK_API_SECRET') }}"
24+
product_type: BUGFIX
25+
product_version: '7.4'
26+
product_category: appplatform
27+
register: rhn_products
28+
no_log: true
29+
30+
- name: Determine patch versions list
31+
ansible.builtin.set_fact:
32+
filtered_versions: "{{ rhn_products.results | map(attribute='file_path') | select('match', '^[^/]*/jboss-eap-.*[0-9]*[.][0-9]*[.][0-9]*.*$') | map('regex_replace','[^/]*/jboss-eap-([0-9]*[.][0-9]*[.][0-9]*)-.*','\\1' ) | list | unique }}"
33+
34+
- name: Determine latest version
35+
ansible.builtin.debug:
36+
msg: "JBoss EAP 7.4 most recent CP is version {{ filtered_versions | middleware_automation.common.version_sort | last }}"

molecule/prod_eap/molecule.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
driver:
3+
name: docker
4+
platforms:
5+
- name: instance
6+
image: registry.access.redhat.com/ubi8/ubi-init:latest
7+
pre_build_image: true
8+
privileged: true
9+
command: "/usr/sbin/init"
10+
tmpfs:
11+
- /run
12+
- /tmp
13+
provisioner:
14+
name: ansible
15+
config_options:
16+
defaults:
17+
interpreter_python: auto_silent
18+
ssh_connection:
19+
pipelining: false
20+
playbooks:
21+
converge: converge.yml
22+
inventory:
23+
host_vars:
24+
localhost:
25+
ansible_python_interpreter: "{{ ansible_playbook_python }}"
26+
env:
27+
ANSIBLE_FORCE_COLOR: "true"
28+
verifier:
29+
name: ansible
30+
scenario:
31+
test_sequence:
32+
- cleanup
33+
- destroy
34+
- create
35+
- prepare
36+
- converge
37+
- idempotence
38+
- side_effect
39+
- verify
40+
- cleanup
41+
- destroy

molecule/requirements.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
collections:
3+
- name: ansible.posix
4+
- name: community.general
5+
- name: community.docker
6+
version: ">=1.9.1"

molecule/stage_eap/converge.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
gather_facts: yes
5+
tasks:
6+
- name: Search EAP Product
7+
middleware_automation.common.product_search:
8+
api_url: "https://jbossnetwork.stage.api.redhat.com"
9+
sso_url: "https://sso.stage.redhat.com"
10+
client_id: "{{ lookup('env', 'STAGE_JBOSSNETWORK_API_CLIENTID') }}"
11+
client_secret: "{{ lookup('env', 'STAGE_JBOSSNETWORK_API_SECRET') }}"
12+
product_type: DISTRIBUTION
13+
product_version: '7.4'
14+
product_category: appplatform
15+
register: rhn_products
16+
no_log: false
17+
18+
- name: Search install zipfile
19+
ansible.builtin.set_fact:
20+
rhn_filtered_products: "{{ rhn_products.results | selectattr('file_path', 'match', '[^/]*/jboss-eap-7.4.0.zip$') }}"
21+
22+
- name: Retrieve product download using JBossNetwork API
23+
middleware_automation.common.product_search:
24+
api_url: "https://jbossnetwork.stage.api.redhat.com"
25+
sso_url: "https://sso.stage.redhat.com"
26+
client_id: "{{ lookup('env', 'STAGE_JBOSSNETWORK_API_CLIENTID') }}"
27+
client_secret: "{{ lookup('env', 'STAGE_JBOSSNETWORK_API_SECRET') }}"
28+
product_type: BUGFIX
29+
product_version: '7.4'
30+
product_category: appplatform
31+
register: rhn_products
32+
no_log: true
33+
34+
- name: Determine patch versions list
35+
ansible.builtin.set_fact:
36+
filtered_versions: "{{ rhn_products.results | map(attribute='file_path') | select('match', '^[^/]*/jboss-eap-.*[0-9]*[.][0-9]*[.][0-9]*.*$') | map('regex_replace','[^/]*/jboss-eap-([0-9]*[.][0-9]*[.][0-9]*)-.*','\\1' ) | list | unique }}"
37+
38+
- name: Determine latest version
39+
ansible.builtin.debug:
40+
msg: "JBoss EAP 7.4 most recent CP is version {{ filtered_versions | middleware_automation.common.version_sort | last }}"

molecule/stage_eap/molecule.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
driver:
3+
name: docker
4+
platforms:
5+
- name: instance
6+
image: registry.access.redhat.com/ubi8/ubi-init:latest
7+
pre_build_image: true
8+
privileged: true
9+
command: "/usr/sbin/init"
10+
tmpfs:
11+
- /run
12+
- /tmp
13+
provisioner:
14+
name: ansible
15+
config_options:
16+
defaults:
17+
interpreter_python: auto_silent
18+
ssh_connection:
19+
pipelining: false
20+
playbooks:
21+
converge: converge.yml
22+
inventory:
23+
host_vars:
24+
localhost:
25+
ansible_python_interpreter: "{{ ansible_playbook_python }}"
26+
env:
27+
ANSIBLE_FORCE_COLOR: "true"
28+
verifier:
29+
name: ansible
30+
scenario:
31+
test_sequence:
32+
- cleanup
33+
- destroy
34+
- create
35+
- prepare
36+
- converge
37+
- idempotence
38+
- side_effect
39+
- verify
40+
- cleanup
41+
- destroy

0 commit comments

Comments
 (0)