Skip to content

Commit

Permalink
More accurately simulate component execution on workspace in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dometto committed Oct 1, 2024
1 parent 7bc965b commit a26346a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
ANSIBLE_STDOUT_CALLBACK: yaml
CRUN_VER: 1.11.2
REQUIREMENTS_FILE: molecule/requirements.txt
ANSIBLE_GALAXY_REQUIREMENTS_FILE: molecule/requirements.yml
BOOTSTRAP_KEY: foobar # defines an api bootstrap key for the molecule tests
steps:
- name: Workaround crun issue on ubuntu
Expand All @@ -41,6 +42,7 @@ jobs:
with:
python-version: '3.11'
- run: pip install -r ${{ env.REQUIREMENTS_FILE }}
- run: ansible-galaxy install -r ${{ env.ANSIBLE_GALAXY_REQUIREMENTS_FILE }}
- name: Molecule tests
run: |
BOOTSTRAP_KEY=${{ env.BOOTSTRAP_KEY }} molecule -vvv test --all
24 changes: 18 additions & 6 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
- name: Converge
hosts: all
gather_facts: false

- name: Run playbook as test
ansible.builtin.import_playbook: ../../galaxysrv.yml
vars:
src_galaxy_tool_files: "{{ playbook_dir ~ '/molecule/_testfiles/tool_list.yaml.sample' }}"
src_galaxy_workflow_files: "{{ playbook_dir ~ '/molecule/_testfiles/sample-workflow.ga' }}"
src_ibridges: 'true'
component:
name: galaxy
path: galaxysrv.yml
arguments: -i 127.0.0.1, --skip-tags {{ ansible_skip_tags | join(',') }}
parameters:
src_galaxy_tool_files: "{{ playbook_dir ~ '/molecule/_testfiles/tool_list.yaml.sample' }}"
src_galaxy_workflow_files: "{{ playbook_dir ~ '/molecule/_testfiles/sample-workflow.ga' }}"
src_ibridges: 'true'
tasks:

- name: Test the component by executing it using ansible on the workspace
ansible.builtin.command: >
ansible-playbook -c local -v -b {{ component.arguments }} --extra-vars='{{ component.parameters | to_json }}' /usr/local/{{ component.name }}/{{ component.path }}
register: ansible_on_workspace
changed_when: >
ansible_on_workspace.stdout_lines is not defined or
'changed=0' not in
ansible_on_workspace.stdout_lines[ lookup('ansible.utils.index_of', ansible_on_workspace.stdout_lines, 'regex', '\s*PLAY RECAP\s*')+1 ]
2 changes: 1 addition & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ driver:
password: $DOCKER_PW
platforms:
- name: workspace-src-ubuntu_jammy
image: ghcr.io/utrechtuniversity/src-test-workspace:ubuntu_jammy
image: ghcr.io/utrechtuniversity/src-test-workspace:ubuntu_jammy-pilot
<<: *image_settings
command: /sbin/init
volumes:
Expand Down
11 changes: 11 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
version: 9.4.0
state: present

- name: Copy local component
ansible.posix.synchronize:
src: ../../../
dest: /usr/local/galaxy
archive: false
links: true
recursive: true
rsync_opts:
- --exclude=".*"
ssh_connection_multiplexing: true

- name: Run nginx component
ansible.builtin.import_playbook: ../../plugin-nginx/plugin-nginx.yml
vars:
Expand Down
5 changes: 5 additions & 0 deletions molecule/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
collections:
- name: ansible.posix
- name: community.general
- name: ansible.utils

0 comments on commit a26346a

Please sign in to comment.