Skip to content

Commit

Permalink
Add AMAUATs test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
replaceafill committed Apr 11, 2024
1 parent 13deee6 commit 72ad0b6
Show file tree
Hide file tree
Showing 5 changed files with 321 additions and 0 deletions.
171 changes: 171 additions & 0 deletions .github/workflows/archivematica-acceptance-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
name: "Archivematica Acceptance Tests"
on:
workflow_dispatch:
inputs:
am_version:
description: "Archivematica ref (branch, tag or SHA to checkout)"
default: "qa/1.x"
required: true
type: "string"
ss_version:
description: "Archivematica Storage Service ref (branch, tag or SHA to checkout)"
default: "qa/0.x"
required: true
type: "string"
amauats_version:
description: "Archivematica Acceptance Test ref (branch, tag or SHA to checkout)"
default: "qa/1.x"
required: true
type: "string"
jobs:
test:
name: "${{ matrix.vagrant-box.label }} / ${{ matrix.feature }}"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
vagrant-box:
- id: "rockylinux/9"
label: "rocky9"
- id: "ubuntu/jammy64"
label: "jammy"
feature:
- "aip-encryption-mirror"
- "aip-encryption"
- "checksum"
- "create-aip"
- "description-rights"
- "extract-package"
- "ingest-mkv-conformance"
- "ingest-policy-check"
- "metadata-xml"
- "reingest-aip"
- "transfer-microservices"
- "transfer-mkv-conformance"
- "transfer-policy-check"
- "uuids-for-directories"
- "virus"
browser:
- "Chrome"
steps:
- name: "Check out code"
uses: "actions/checkout@v4"
- name: "Check out AM code"
uses: "actions/checkout@v4"
with:
repository: "artefactual/archivematica"
ref: "${{ inputs.am_version }}"
path: "${{ github.workspace }}/AM"
- name: "Check out SS code"
uses: "actions/checkout@v4"
with:
repository: "artefactual/archivematica-storage-service"
ref: "${{ inputs.ss_version }}"
path: "${{ github.workspace }}/SS"
- name: "Check out AMAUATs code"
uses: "actions/checkout@v4"
with:
repository: "artefactual-labs/archivematica-acceptance-tests"
ref: "${{ inputs.amauats_version }}"
path: "${{ github.workspace }}/AMAUATs"
- name: "Install Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.9"
- name: "Install Vagrant"
run: |
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install vagrant
- name: "Install VirtualBox"
run: |
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg --dearmor
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian jammy contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt update && sudo apt install virtualbox-7.0
- name: "Install the vagrant-vbguest plugin"
run: |
vagrant plugin install vagrant-vbguest
- name: "Update vbox networks"
run: |
sudo mkdir -p /etc/vbox/
echo "* 192.168.33.0/24" | sudo tee -a /etc/vbox/networks.conf
- name: "Start VM"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
env:
VAGRANT_BOX: "${{ matrix.vagrant-box.id }}"
run: |
vagrant up
- name: "Resize root partition in Rocky 9"
if: matrix.vagrant-box.id == 'rockylinux/9'
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
vagrant ssh -c 'echo "- +" | sudo sfdisk --no-reread -N 5 /dev/sda'
vagrant reload
vagrant ssh -c 'sudo xfs_growfs /dev/sda5'
- name: "Install Archivematica"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
env:
ANSIBLE_HOST_KEY_CHECKING: "False"
run: |
ansible-galaxy install -f -p roles/ -r requirements.yml
ansible-playbook -i 192.168.33.2, playbook.yml \
-u vagrant \
--private-key ${{ github.workspace }}/tests/archivematica-acceptance-tests/.vagrant/machines/default/virtualbox/private_key \
-e "archivematica_src_am_version=${{ inputs.am_version }} archivematica_src_ss_version=${{ inputs.ss_version }}"
-v
- name: "Prepare VM for running AMAUATs"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
vagrant ssh -c 'sudo usermod -a -G archivematica vagrant'
vagrant ssh -c 'sudo ln -s /home/vagrant /home/archivematica'
- name: "Set up AMAUATs"
working-directory: "${{ github.workspace }}/AMAUATs"
run: |
python3 -m venv .venv
.venv/bin/python3 -m pip install -r requirements.txt
- name: "Run AMAUATs"
id: "amauat-run"
working-directory: "${{ github.workspace }}/AMAUATs"
env:
HEADLESS: 1
run: |
.venv/bin/behave -i ${{ matrix.feature }}.feature \
-v \
--no-capture \
--no-capture-stderr \
--no-logcapture \
--no-skipped \
-D am_version=1.9 \
-D driver_name=${{ matrix.browser }} \
-D am_username=admin \
-D am_password=archivematica \
-D am_url=http://192.168.33.2/ \
-D am_api_key="this_is_the_am_api_key" \
-D ss_username=admin \
-D ss_password=archivematica \
-D ss_api_key="this_is_the_ss_api_key" \
-D ss_url=http://192.168.33.2:8000/ \
-D home=vagrant \
-D server_user=vagrant \
-D transfer_source_path=/home/vagrant/archivematica-sampledata/TestTransfers/acceptance-tests \
-D ssh_identity_file=${{ github.workspace }}/tests/archivematica-acceptance-tests/.vagrant/machines/default/virtualbox/private_key
- name: "Save logs on failure"
if: "${{ (failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled') }}"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
mkdir /tmp/logs
vagrant ssh -c 'mkdir -p /tmp/logs/journalctl'
vagrant ssh -c 'sudo cp -r /var/log/{archivematica,mysql,elasticsearch,gearman-job-server,clamav,nginx} /tmp/logs'
vagrant ssh -c 'sudo journalctl -u archivematica-mcp-client --no-pager > /tmp/logs/journalctl/archivematica-mcp-client'
vagrant ssh -c 'sudo chown -R vagrant /tmp/logs'
scp \
-i ${{ github.workspace }}/tests/archivematica-acceptance-tests/.vagrant/machines/default/virtualbox/private_key \
-o "StrictHostKeyChecking=no" \
-r \
[email protected]:/tmp/logs /tmp/logs
- name: "Upload logs on failure"
if: "${{ (failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled') }}"
uses: "actions/upload-artifact@v4"
with:
name: "logs-${{ matrix.vagrant-box.label }}-${{ matrix.feature }}"
path: "/tmp/logs"
15 changes: 15 additions & 0 deletions tests/archivematica-acceptance-tests/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
config.vm.box = ENV.fetch("VAGRANT_BOX", "ubuntu/jammy64")
config.vm.disk :disk, size: "40GB", primary: true
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.network "private_network", ip: "192.168.33.2"
config.vm.provider "virtualbox" do |vb|
vb.memory = "8192"
vb.cpus = "2"
end
# This requires the vagrant-vbguest plugin
config.vbguest.auto_update = false
end
34 changes: 34 additions & 0 deletions tests/archivematica-acceptance-tests/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- hosts: "all"

pre_tasks:

- include_vars: "vars.yml"
tags:
- "always"

- name: "Change home dir perms (to make transfer source visible)"
command: "chmod 755 $HOME"
become: "no"

roles:

- role: "artefactual.elasticsearch"
become: "yes"

- role: "artefactual.percona"
become: "yes"

- role: "artefactual.gearman"
become: "yes"

- role: "artefactual.clamav"
become: "yes"

- role: "artefactual.nginx"
become: "yes"

- role: "artefactual.archivematica-src"
become: "yes"
tags:
- "archivematica-src"
25 changes: 25 additions & 0 deletions tests/archivematica-acceptance-tests/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---

- src: "https://github.com/artefactual-labs/ansible-elasticsearch"
version: "master"
name: "artefactual.elasticsearch"

- src: "https://github.com/artefactual-labs/ansible-percona"
version: "master"
name: "artefactual.percona"

- src: "https://github.com/artefactual-labs/ansible-gearman"
version: "master"
name: "artefactual.gearman"

- src: "https://github.com/artefactual-labs/ansible-nginx"
version: "master"
name: "artefactual.nginx"

- src: "https://github.com/artefactual-labs/ansible-archivematica-src"
version: "qa/1.x"
name: "artefactual.archivematica-src"

- src: "https://github.com/artefactual-labs/ansible-clamav"
version: "master"
name: "artefactual.clamav"
76 changes: 76 additions & 0 deletions tests/archivematica-acceptance-tests/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---

# archivematica-src role

archivematica_src_configure_dashboard: "yes"
archivematica_src_configure_ss: "yes"

archivematica_src_configure_am_user: "admin"
archivematica_src_configure_am_password: "archivematica"
archivematica_src_configure_am_email: "[email protected]"
archivematica_src_configure_am_api_key: "this_is_the_am_api_key"
archivematica_src_configure_am_site_url: "http://192.168.33.2"

archivematica_src_configure_ss_user: "admin"
archivematica_src_configure_ss_password: "archivematica"
archivematica_src_configure_ss_api_key: "this_is_the_ss_api_key"
archivematica_src_configure_ss_url: "http://192.168.33.2:8000"
archivematica_src_configure_ss_email: "[email protected]"

archivematica_src_am_db_password: "aaGKHyMls.20ki$"
archivematica_src_ss_db_password: "aaGKHyMls.20ki$"

# By default the archivematica-src role sets `MCP` and `SS` as the database
# names and a single `archivematica` user for both services. The
# artefactual.percona overwrites existing user privileges when it creates
# databases (it should set `append_privs: true` on the `mysql_user` module call)
# so the SS database privileges overwrite the MCP ones. Setting different
# users for each database works around this issue.
archivematica_src_am_db_user: "archivematica"
archivematica_src_ss_db_user: "ss"

# percona role

mysql_version_major: "8"
mysql_version_minor: "0"

mysql_root_password: "aaGKHyMls.20ki$"

mysql_databases:
- name: "{{ archivematica_src_am_db_name }}"
collation: "{{ archivematica_src_am_db_collation }}"
encoding: "{{ archivematica_src_am_db_encoding }}"
- name: "{{ archivematica_src_ss_db_name }}"
collation: "{{ archivematica_src_ss_db_collation }}"
encoding: "{{ archivematica_src_ss_db_encoding }}"

mysql_users:
- name: "{{ archivematica_src_am_db_user }}"
pass: "{{ archivematica_src_am_db_password }}"
priv: "{{ archivematica_src_am_db_name }}.*:ALL,GRANT"
host: "{{ archivematica_src_am_db_host }}"
- name: "{{ archivematica_src_ss_db_user }}"
pass: "{{ archivematica_src_ss_db_password }}"
priv: "{{ archivematica_src_ss_db_name }}.*:ALL,GRANT"
host: "{{ archivematica_src_ss_db_host }}"

archivematica_src_ss_environment:
SS_DB_URL: "mysql://{{ archivematica_src_ss_db_user }}:{{ archivematica_src_ss_db_password }}@{{ archivematica_src_ss_db_host }}:{{ archivematica_src_ss_db_port }}/{{ archivematica_src_ss_db_name }}"

# Enable XML metadata validation

archivematica_src_am_mcpclient_environment:
ARCHIVEMATICA_MCPCLIENT_MCPCLIENT_METADATA_XML_VALIDATION_ENABLED: "true"
METADATA_XML_VALIDATION_SETTINGS_FILE: "/home/{{ ansible_user_id }}/archivematica-sampledata/xml-validation/xml_validation.py"

# Disable FITS

archivematica_src_configure_fpcommand:
FITS:
enabled: '0'
field_name: 'description'

archivematica_src_configure_fprule:
c3b06895-ef9d-401e-8c51-ac585f955655:
enabled: '0'
field_name: 'uuid'

0 comments on commit 72ad0b6

Please sign in to comment.