Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component test #17

Merged
merged 4 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/component-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Run component tests against iRODS
on:
pull_request:
paths:
- 'component.yml'
- 'molecule/component/**'
push:
paths:
- 'component.yml'
- 'molecule/component/**'
branches:
- main

jobs:
molecule:
runs-on: ubuntu-latest
if: |
${{ ! contains(github.event.head_commit.message, '#nointegrationtests') &&
( github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
)
}}
env:
ANSIBLE_FORCE_COLOR: '1'
ANSIBLE_STDOUT_CALLBACK: yaml
REQUIREMENTS_FILE: molecule/requirements.txt
MOLECULE_CONFIG: molecule/ext/molecule.yml
DRIVER: docker
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- run: pip install -r ${{ env.REQUIREMENTS_FILE }}
- run: ansible-galaxy install -r requirements.yml
- name: Run molecule tests
run: molecule -vvv -c ${{ env.MOLECULE_CONFIG }} test -s component
16 changes: 5 additions & 11 deletions .github/workflows/irods-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,21 @@ jobs:
fail-fast: false
matrix:
python:
- 3.12
- 3.11
- 3.9
- 3.8
- '3.12'
- '3.10'
ansible:
- 2.9
- 9.6.0
exclude:
- ansible: 2.9
python: 3.12
- ansible: 2.9
python: 3.11
- ansible: 2.9
python: 3.9
python: '3.12'
- ansible: 9.6.0
python: 3.8
python: '3.10'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: ${{ matrix.python }}
- run: pip install -U ansible==${{ matrix.ansible }}
- run: pip install -r ${{ env.REQUIREMENTS_FILE }}
- run: ansible-galaxy install -r requirements.yml
Expand Down
3 changes: 2 additions & 1 deletion component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
tasks:
- name: Install iBridges
pip:
name: ibridges==0.1
name: ibridges~=0.1
extra_args: "--target {{ _ibridges_custom_pip_location }}"
tags: molecule-idempotence-notest

- name: Create target directory if it does not exist
file:
Expand Down
29 changes: 29 additions & 0 deletions molecule/component/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
platforms:
- name: workspace-src-ubuntu_focal
image: ghcr.io/utrechtuniversity/src-test-workspace:ubuntu_focal
pre_build_image: true
networks:
- name: irods_test_network
registry:
url: $DOCKER_REGISTRY
credentials:
username: $DOCKER_USER
password: $DOCKER_PW
provisioner:
name: ansible
playbooks:
converge: ../ext/converge.yml
prepare: ../ext/prepare.yml
cleanup: ../default/cleanup.yml
env:
PLAYBOOK_DIR: ../../../
extra_prepare_tasks: ../files/_inc_prepare.yml
components:
- name: ibridges_sync
path: component.yml
parameters:
ibridges_password: rods
ibridges_env: '{ irods_host: irods-catalog-provider,irods_port: 1247, irods_user_name: rods, irods_default_resource: demoResc, irods_home: /tempZone/home/rods, irods_zone_name: tempZone }'
ibridges_irods_path: "~/testfiles"
ibridges_target_path: "/home/testuser/"
41 changes: 2 additions & 39 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,5 @@
hosts: all
gather_facts: false
tasks:
- name: Start irods testing environment
delegate_to: localhost
community.docker.docker_compose_v2:
project_name: ibridges_irods_test
project_src: ../files/

- name: Install ibridges
ansible.builtin.pip:
name: ibridges

- name: Create testfiles
ansible.builtin.copy:
dest: /tmp/test/testfiles
src: ./

- name: Create download test destination
ansible.builtin.file:
path: /home/rods/testfiles
state: directory

- name: Upload testfiles
ibridges_upload:
env:
irods_host: irods-catalog-provider # container name
irods_port: 1247
irods_user_name: rods
irods_default_resource: "demoResc"
irods_home: /tempZone/home/rods
irods_zone_name: tempZone
irods_path: "~/testfiles"
local_path: "/tmp/test/testfiles"
password: rods
retries: 3
delay: 5 # retry because irods server might not be available yet

- name: Add new testfile for sync test
ansible.builtin.copy:
dest: /tmp/test/testfiles/penguin.txt
content: sweet animal
- name: Include tasks
ansible.builtin.include_tasks: ../files/_inc_prepare.yml
1 change: 1 addition & 0 deletions molecule/ext/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
src: "{{ item.dir | default(lookup('env', 'PLAYBOOK_DIR')) }}/"
dest: /rsc/plugins/{{ item.name }}/
archive: false
links: true
recursive: true
rsync_opts:
- --exclude=".*"
Expand Down
40 changes: 40 additions & 0 deletions molecule/files/_inc_prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
- name: Start irods testing environment
delegate_to: localhost
community.docker.docker_compose_v2:
project_name: ibridges_irods_test
project_src: ../files

- name: Install ibridges
ansible.builtin.pip:
name: ibridges

- name: Create testfiles
ansible.builtin.copy:
dest: /tmp/test/testfiles
src: ./

- name: Create download test destination
ansible.builtin.file:
path: /home/rods/testfiles
state: directory

- name: Upload testfiles
ibridges_upload:
env:
irods_host: irods-catalog-provider # container name
irods_port: 1247
irods_user_name: rods
irods_default_resource: "demoResc"
irods_home: /tempZone/home/rods
irods_zone_name: tempZone
irods_path: "~/testfiles"
local_path: "/tmp/test/testfiles"
password: rods
retries: 10
delay: 5 # retry because irods server might not be available yet

- name: Add new testfile for sync test
ansible.builtin.copy:
dest: /tmp/test/testfiles/penguin.txt
content: sweet animal
2 changes: 1 addition & 1 deletion molecule/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ibridges~=0.1
molecule~=24.2
molecule
molecule-plugins
jmespath~=1.0
requests~=2.31.0 # https://github.com/ansible-community/molecule-plugins/issues/256
Expand Down
1 change: 1 addition & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
collections:
- name: community.docker
- name: community.general
Loading