Skip to content

Archivematica Acceptance Tests #102

Archivematica Acceptance Tests

Archivematica Acceptance Tests #102

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"
at_version:
description: "Archivematica Acceptance Test ref (branch, tag or SHA to checkout)"
default: "qa/1.x"
required: true
type: "string"
jobs:
test:
name: "${{ matrix.feature }} / ${{ matrix.docker_image.label }}"
runs-on: "ubuntu-latest"
env:
am_version: "${{ inputs.am_version }}"
ss_version: "${{ inputs.ss_version }}"
at_version: "${{ inputs.at_version }}"
python_version: "3.9"
strategy:
fail-fast: false
matrix:
docker_image:
- name: "rockylinux"
tag: "9"
label: "rocky9"
- name: "rockylinux"
tag: "8"
label: "rocky8"
- name: "almalinux"
tag: "9"
label: "alma9"
- name: "ubuntu"
tag: "22.04"
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: "Upgrade crun (supports Ubuntu's systemd in the Dockerfile)"
run: |
wget https://github.com/containers/crun/releases/download/1.14.4/crun-1.14.4-linux-amd64
sudo install crun-1.14.4-linux-amd64 /usr/bin/crun
rm crun-1.14.4-linux-amd64
- name: "Check out AMAUATs code"
uses: "actions/checkout@v4"
with:
repository: "artefactual-labs/archivematica-acceptance-tests"
ref: "${{ env.at_version }}"
path: "${{ github.workspace }}/AMAUATs"
- name: "Install Python"
uses: "actions/setup-python@v5"
with:
python-version: "${{ env.python_version }}"
cache: "pip"
cache-dependency-path: |
tests/archivematica-acceptance-tests/requirements.txt
- name: "Cache the virtual environment"
id: "venv-cache"
uses: "actions/cache@v4"
with:
path: |
tests/archivematica-acceptance-tests/.venv/
key: "os-${{ runner.os }}-python_version-${{ env.python_version }}-hash-${{ hashFiles('tests/archivematica-acceptance-tests/requirements.txt') }}"
- name: "Set up the virtual environment"
if: "steps.venv-cache.outputs.cache-hit == false"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
- name: "Add virtual environment to PATH"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run:
echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: "Generate an SSH key and copy it next to the Dockerfile"
run: |
mkdir $HOME/.ssh
ssh-keygen -t rsa -f $HOME/.ssh/id_rsa -N ""
cp $HOME/.ssh/id_rsa.pub ${{ github.workspace }}/tests/archivematica-acceptance-tests/ssh_pub_key
- name: "Start the Compose environment"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
env:
DOCKER_IMAGE_NAME: "${{ matrix.docker_image.name }}"
DOCKER_IMAGE_TAG: "${{ matrix.docker_image.tag }}"
run: |
podman-compose up --detach
- name: "Install Archivematica"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
env:
ANSIBLE_HOST_KEY_CHECKING: "False"
ANSIBLE_REMOTE_PORT: 2222
run: |
ansible-galaxy install -f -p roles/ -r requirements.yml
ansible-playbook -i localhost, playbook.yml \
-u ubuntu \
-e "archivematica_src_am_version=${{ env.am_version }} archivematica_src_ss_version=${{ env.ss_version }}" \
-vvv
- name: "Save logs"
if: "${{ failure() }}"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
mkdir /tmp/logs
podman-compose exec --user root archivematica cp -r /var/log /tmp/logs
podman-compose exec --user root archivematica cp -r /etc /tmp/logs
podman-compose exec --user root archivematica cp -r /usr/lib/systemd /tmp/logs
podman-compose exec --user root archivematica journalctl --no-pager > /tmp/logs/journalctl.log
podman-compose exec --user root archivematica chown -R ubuntu:ubuntu /tmp/logs
podman cp archivematica-acceptance-test_archivematica_1:/tmp/logs/ /tmp/logs
sudo chown -R $USER /tmp/logs
tar -czf /tmp/logs.tar.gz /tmp/logs
- name: "Upload logs on failure"
if: "${{ failure() }}"
uses: "actions/upload-artifact@v4"
with:
name: "logs-${{ matrix.docker_image.label }}-${{ matrix.feature }}"
path: "/tmp/logs.tar.gz"
- name: "Prepare the container for running the AMAUATs"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
podman-compose exec --user root archivematica usermod -a -G archivematica ubuntu
podman-compose exec --user root archivematica ln -s /home/ubuntu /home/archivematica
- name: "Call an Archivematica API endpoint"
run: |
curl \
--header "Authorization: ApiKey admin:this_is_the_am_api_key" \
http://localhost:8000/api/processing-configuration/
- name: "Call a Storage Service API endpoint"
run: |
curl \
--header "Authorization: ApiKey admin:this_is_the_ss_api_key" \
http://localhost:8001/api/v2/pipeline/
- 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://localhost:8000/ \
-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://localhost:8001/ \
-D home=ubuntu \
-D server_user=ubuntu \
-D transfer_source_path=/home/ubuntu/archivematica-sampledata/TestTransfers/acceptance-tests \
-D ssh_identity_file=$HOME/.ssh/id_rsa
# - name: "Save common 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 journalctl -u archivematica-mcp-client --no-pager > /tmp/logs/journalctl/archivematica-mcp-client'
# - name: "Save logs on failure"
# if: "${{ startsWith(matrix.vagrant_box.id, 'ubuntu/') && ((failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled')) }}"
# working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
# run: |
# vagrant ssh -c 'sudo cp -r /var/log/{archivematica,mysql,elasticsearch,gearman-job-server,clamav,nginx} /tmp/logs'
# - name: "Save logs on failure"
# if: "${{ (startsWith(matrix.vagrant_box.id, 'rockylinux/') || startsWith(matrix.vagrant_box.id, 'almalinux/')) && ((failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled')) }}"
# working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
# run: |
# vagrant ssh -c 'sudo journalctl -u clamd@scan --no-pager > /tmp/logs/journalctl/clamd'
# vagrant ssh -c 'sudo cp -r /var/log/{archivematica,mysqld.log,elasticsearch,nginx} /tmp/logs'
# - name: "Copy logs from VM"
# if: "${{ (failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled') }}"
# working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
# run: |
# 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"