A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
molecule scenario to test upgrading from releases
Fabian Koller8884a4dfdfd3
diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.ymlindex aacc4b44e..646c7ff81 100644--- a/.github/workflows/ansible.yml+++ b/.github/workflows/ansible.yml@@ -26,10 +26,15 @@ jobs:docker --versionmolecule --versionpython --version- - name: Test with molecule+ - name: Test fresh installation with moleculerun: |cd ansible- molecule test+ molecule test -s fresh+ working-directory: "${{ github.repository }}"+ - name: Test release update with molecule+ run: |+ cd ansible+ molecule test -s updateworking-directory: "${{ github.repository }}"# # https://galaxy.ansible.com/docs/contributing/importing.html# release:diff --git a/ansible/molecule/default/converge.yml b/ansible/molecule/default/converge.ymldeleted file mode 100644index 82067f417..000000000--- a/ansible/molecule/default/converge.yml+++ /dev/null@@ -1,7 +0,0 @@------ name: Converge- hosts: all- tasks:- - name: "Include ansible"- include_role:- name: "ansible"diff --git a/ansible/molecule/default/verify.yml b/ansible/molecule/default/verify.ymldeleted file mode 100644index 4c3b86044..000000000--- a/ansible/molecule/default/verify.yml+++ /dev/null@@ -1,14 +0,0 @@-----# This is an example playbook to execute Ansible tests.--- name: Verify- hosts: all- gather_facts: false- tasks:- - name: check if webserver is up- uri:- url: http://localhost:8000- status_code: [200, 302]- return_content: yes- register: landingpage- failed_when: "'Sign in</button>' not in landingpage.content"diff --git a/ansible/molecule/fresh/converge.yml b/ansible/molecule/fresh/converge.ymlnew file mode 100644index 000000000..99e25677b--- /dev/null+++ b/ansible/molecule/fresh/converge.yml@@ -0,0 +1,7 @@+---+- name: fresh installation+ hosts: all+ tasks:+ - name: install paperless-ng with default parameters+ include_role:+ name: ansiblediff --git a/ansible/molecule/default/molecule.yml b/ansible/molecule/fresh/molecule.ymlsimilarity index 100%rename from ansible/molecule/default/molecule.ymlrename to ansible/molecule/fresh/molecule.ymldiff --git a/ansible/molecule/fresh/verify.yml b/ansible/molecule/fresh/verify.ymlnew file mode 100644index 000000000..c353783ab--- /dev/null+++ b/ansible/molecule/fresh/verify.yml@@ -0,0 +1,60 @@+---+- name: Verify+ hosts: all+ gather_facts: false++ vars_files:+ - ../../defaults/main.yml++ tasks:+ - name: check if webserver is up+ uri:+ url: http://localhost:8000+ status_code: [200, 302]+ return_content: yes+ register: landingpage+ failed_when: "'Sign in</button>' not in landingpage.content"++ - name: check if document posting works+ uri:+ url: http://localhost:8000/api/documents/post_document/+ method: POST+ body_format: form-multipart+ body:+ document:+ content: FOO+ filename: document.txt+ mime_type: text/plain+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: post_document+ failed_when: "'OK' not in post_document.content"++ - name: verify uploaded document has been accepted+ uri:+ url: http://localhost:8000/api/logs/+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: logs+ failed_when: "'Consuming document.txt' not in logs.content"++ # assumes txt consumption finished by now, might have to sleep a bit+ - name: verify uploaded document has been consumed+ uri:+ url: http://localhost:8000/api/logs/+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: logs+ failed_when: "'document consumption finished' not in logs.content"++ - name: verify uploaded document is avaiable+ uri:+ url: http://localhost:8000/api/documents/1/+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: document+ failed_when: "'Not found.' in document.content or 'FOO' not in document.content"diff --git a/ansible/molecule/update/converge.yml b/ansible/molecule/update/converge.ymlnew file mode 100644index 000000000..b19a5981a--- /dev/null+++ b/ansible/molecule/update/converge.yml@@ -0,0 +1,11 @@+---+- name: update previous release to newest release+ hosts: all+ tasks:+ - name: set current version as installation target+ set_fact:+ paperlessng_version: 0.9.14++ - name: update to newest paperless-ng release+ include_role:+ name: ansiblediff --git a/ansible/molecule/update/molecule.yml b/ansible/molecule/update/molecule.ymlnew file mode 100644index 000000000..27f37ba63--- /dev/null+++ b/ansible/molecule/update/molecule.yml@@ -0,0 +1,35 @@+---+dependency:+ name: galaxy+driver:+ name: docker+platforms:+ - name: ubuntu_focal+ image: jrei/systemd-ubuntu:20.04+ privileged: true+ volumes:+ - /sys/fs/cgroup:/sys/fs/cgroup:ro+ tmpfs:+ - /tmp+ - /run+ - /run/lock+ override_command: False+ # ubuntu 18.04 bionic works except that+ # the default redis configuration expects IPv6 which is not enabled in docker by default+ # the default Python environment is configured for ASCII instead of UTF-8+ # ubuntu 16.04 xenial only has Python 3.5 which is EOL and breaks multiple dependencies+ - name: debian_buster+ image: jrei/systemd-debian:10+ privileged: true+ volumes:+ - /sys/fs/cgroup:/sys/fs/cgroup:ro+ tmpfs:+ - /tmp+ - /run+ - /run/lock+ override_command: False+ # debian 9 stretch only has Python 3.5 which is EOL and breaks multiple dependencies+provisioner:+ name: ansible+verifier:+ name: ansiblediff --git a/ansible/molecule/update/prepare.yml b/ansible/molecule/update/prepare.ymlnew file mode 100644index 000000000..6f3734329--- /dev/null+++ b/ansible/molecule/update/prepare.yml@@ -0,0 +1,10 @@+- name: install previous release+ hosts: all+ tasks:+ - name: set previous version as installation target+ set_fact:+ paperlessng_version: 0.9.13++ - name: install previous paperless-ng release+ include_role:+ name: ansiblediff --git a/ansible/molecule/update/verify.yml b/ansible/molecule/update/verify.ymlnew file mode 100644index 000000000..c353783ab--- /dev/null+++ b/ansible/molecule/update/verify.yml@@ -0,0 +1,60 @@+---+- name: Verify+ hosts: all+ gather_facts: false++ vars_files:+ - ../../defaults/main.yml++ tasks:+ - name: check if webserver is up+ uri:+ url: http://localhost:8000+ status_code: [200, 302]+ return_content: yes+ register: landingpage+ failed_when: "'Sign in</button>' not in landingpage.content"++ - name: check if document posting works+ uri:+ url: http://localhost:8000/api/documents/post_document/+ method: POST+ body_format: form-multipart+ body:+ document:+ content: FOO+ filename: document.txt+ mime_type: text/plain+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: post_document+ failed_when: "'OK' not in post_document.content"++ - name: verify uploaded document has been accepted+ uri:+ url: http://localhost:8000/api/logs/+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: logs+ failed_when: "'Consuming document.txt' not in logs.content"++ # assumes txt consumption finished by now, might have to sleep a bit+ - name: verify uploaded document has been consumed+ uri:+ url: http://localhost:8000/api/logs/+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: logs+ failed_when: "'document consumption finished' not in logs.content"++ - name: verify uploaded document is avaiable+ uri:+ url: http://localhost:8000/api/documents/1/+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: document+ failed_when: "'Not found.' in document.content or 'FOO' not in document.content"diff --git a/ansible/tasks/main.yml b/ansible/tasks/main.ymlindex fe139dcbf..a353a18ec 100644--- a/ansible/tasks/main.yml+++ b/ansible/tasks/main.yml@@ -155,7 +155,7 @@- name: move paperless-ngcommand:- cmd: "cp -a {{ tempdir.path }}/paperless-ng/ {{ paperlessng_directory }}"+ cmd: "cp -a {{ tempdir.path }}/paperless-ng/. {{ paperlessng_directory }}"when: not reconfigure_only- name: remove temporary directory@@ -367,7 +367,7 @@owner: "{{ paperlessng_system_user }}"group: "{{ paperlessng_system_group }}"mode: g-w,o-rwx- when: venv.changed or not not reconfigure_only+ when: venv.changed or not reconfigure_only- name: configure ghostscript for PDFlineinfile: