Skip to content

Archivematica Acceptance Tests #242

Archivematica Acceptance Tests

Archivematica Acceptance Tests #242

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"
schedule:
- cron: "0 3 * * *"
jobs:
test:
name: "${{ matrix.feature }} / ${{ matrix.docker_image.label }}"
runs-on: "ubuntu-latest"
env:
am_version: "${{ inputs.am_version || 'qa/1.x' }}"
ss_version: "${{ inputs.ss_version || 'qa/0.x' }}"
at_version: "${{ inputs.at_version || 'qa/1.x' }}"
python_version: "3.10"
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: "oraclelinux"
tag: "9"
label: "oracle9"
- name: "ubuntu"
tag: "22.04"
label: "jammy"
- name: "ubuntu"
tag: "20.04"
label: "focal"
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 AMAUATs code"
uses: "actions/checkout@v4"
with:
repository: "artefactual-labs/archivematica-acceptance-tests"
ref: "${{ env.at_version }}"
path: "${{ github.workspace }}/AMAUATs"
- name: "Upgrade crun (supports Ubuntu's systemd in the Dockerfile)"
run: |
wget https://github.com/containers/crun/releases/download/1.15/crun-1.15-linux-amd64
sudo install crun-1.15-linux-amd64 /usr/bin/crun
rm crun-1.15-linux-amd64
- 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: "Add port to SSH client configuration"
run: |
echo -e "Host localhost\n Port 2222" > $HOME/.ssh/config
- 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 Ansible requirements"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
ansible-galaxy install -f -p roles/ -r requirements.yml
- name: "Adjust parsing of root's initial MySQL password in RedHat distros"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
sed -i "s_cat /var/log/mysqld.log | sed -n '_journalctl --no-pager | sed -n '0,/.*temporary password is generated for root@localhost: /_g" roles/artefactual.percona/tasks/secure.yml
- name: "Install Archivematica"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
env:
ANSIBLE_HOST_KEY_CHECKING: "False"
ANSIBLE_REMOTE_PORT: 2222
run: |
ansible-playbook -i localhost, playbook.yml \
-u ubuntu \
-e "archivematica_src_am_version=${{ env.am_version }} archivematica_src_ss_version=${{ env.ss_version }}" \
-v
- name: "Disable machine learning in Elasticsearch"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
podman-compose exec --user root archivematica bash -c 'echo "xpack.ml.enabled: false" | tee -a /etc/elasticsearch/elasticsearch.yml'
podman-compose exec --user root archivematica service elasticsearch restart
podman-compose exec --user root archivematica service archivematica-dashboard restart
- 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: |
podman-compose exec --user root archivematica mkdir -p /tmp/logs/journalctl
podman-compose exec --user root archivematica bash -c 'journalctl -u archivematica-mcp-client --no-pager > /tmp/logs/journalctl/archivematica-mcp-client'
- name: "Save logs on failure"
if: "${{ matrix.docker_image.name == 'ubuntu' && ((failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled')) }}"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
podman-compose exec --user root archivematica bash -c 'cp -r /var/log/{archivematica,mysql,elasticsearch,gearman-job-server,clamav,nginx} /tmp/logs'
- name: "Save logs on failure"
if: "${{ matrix.docker_image.name != 'ubuntu' && ((failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled')) }}"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
podman-compose exec --user root archivematica bash -c 'journalctl -u mysqld --no-pager > /tmp/logs/journalctl/mysql'
podman-compose exec --user root archivematica bash -c 'journalctl -u clamd@scan --no-pager > /tmp/logs/journalctl/clamd'
podman-compose exec --user root archivematica bash -c '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: |
podman cp archivematica-acceptance-test_archivematica_1:/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.docker_image.label }}-${{ matrix.feature }}"
path: "${{ github.workspace }}/tests/archivematica-acceptance-tests/logs"