A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Simplify molecule tests
Fabian Kollerbfbdfe857f28
diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.ymlindex c11472361..fd965e760 100644--- a/.github/workflows/ansible.yml+++ b/.github/workflows/ansible.yml@@ -5,7 +5,7 @@ on: [push, pull_request]jobs:# https://molecule.readthedocs.io/en/latest/ci.html#github-actions- test-fresh:+ test:runs-on: ubuntu-latest# https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#github-contextif: github.event_name == 'pull_request' || (github.event_name == 'push' && contains(github.ref, 'refs/heads/'))@@ -26,36 +26,15 @@ jobs:docker --versionmolecule --versionpython --version- - name: Test fresh installation with molecule+ - name: Test installation/build/upgrade with moleculerun: |cd ansible- molecule test -s fresh- working-directory: "${{ github.repository }}"- test-update:- runs-on: ubuntu-latest- # https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#github-context- if: github.event_name == 'pull_request' || (github.event_name == 'push' && contains(github.ref, 'refs/heads/'))- steps:- - name: Check out the codebase- uses: actions/checkout@v2- with:- path: "${{ github.repository }}"- - name: Set up Python- uses: actions/setup-python@v2- - name: Set up Docker- uses: docker-practice/actions-setup-docker@master- - name: Install dependencies- run: |- python3 -m pip install --upgrade pip- python3 -m pip install molecule[ansible,docker] jmespath- ansible --version- docker --version- molecule --version- python --version- - name: Test release update with molecule- run: |- cd ansible- molecule test -s update+ molecule create+ molecule verify+ molecule converge+ molecule idempotence+ molecule verify+ molecule destroyworking-directory: "${{ github.repository }}"# # https://galaxy.ansible.com/docs/contributing/importing.html# release:diff --git a/ansible/molecule/update/converge.yml b/ansible/molecule/default/converge.ymlsimilarity index 100%rename from ansible/molecule/update/converge.ymlrename to ansible/molecule/default/converge.ymldiff --git a/ansible/molecule/fresh/molecule.yml b/ansible/molecule/default/molecule.ymlsimilarity index 100%rename from ansible/molecule/fresh/molecule.ymlrename to ansible/molecule/default/molecule.ymldiff --git a/ansible/molecule/update/prepare.yml b/ansible/molecule/default/prepare.ymlsimilarity index 85%rename from ansible/molecule/update/prepare.ymlrename to ansible/molecule/default/prepare.ymlindex 138ebdfce..e175eff5b 100644--- a/ansible/molecule/update/prepare.yml+++ b/ansible/molecule/default/prepare.yml@@ -3,7 +3,7 @@tasks:- name: set previous version as installation targetset_fact:- paperlessng_version: 1.0.0+ paperlessng_version: latest- name: install previous paperless-ng releaseinclude_role:diff --git a/ansible/molecule/default/verify.yml b/ansible/molecule/default/verify.ymlnew file mode 100644index 000000000..01dc43192--- /dev/null+++ b/ansible/molecule/default/verify.yml@@ -0,0 +1,91 @@+---+- name: Verify+ hosts: all+ gather_facts: false++ vars_files:+ - ../../defaults/main.yml++ tasks:+ - name: check if webserver is up+ uri:+ url: "http://{{ paperlessng_listen_address }}:{{ paperlessng_listen_port }}"+ status_code: [200, 302]+ return_content: yes+ register: landingpage+ failed_when: "'Sign in</button>' not in landingpage.content"++ - name: generate random name and content+ set_fact:+ content: "{{ lookup('password', '/dev/null length=64 chars=ascii_letters') }}"+ filename: "{{ lookup('password', '/dev/null length=8 chars=ascii_letters') }}"++ - name: check if document posting works+ uri:+ url: "http://{{ paperlessng_listen_address }}:{{ paperlessng_listen_port }}/api/documents/post_document/"+ method: POST+ body_format: form-multipart+ body:+ document:+ content: "{{ content }}"+ filename: "{{ filename }}.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://{{ paperlessng_listen_address }}:{{ paperlessng_listen_port }}/api/logs/"+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: logs+ failed_when: "('Consuming ' + filename + '.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://{{ paperlessng_listen_address }}:{{ paperlessng_listen_port }}/api/logs/"+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: logs+ failed_when: "filename + ' consumption finished' not in logs.content"++ - name: get documents+ uri:+ url: "http://{{ paperlessng_listen_address }}:{{ paperlessng_listen_port }}/api/documents/"+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: documents++ - name: set document index+ set_fact:+ index: "{{ documents.json['results'][0]['id'] }}"++ - name: verify uploaded document is avaiable+ uri:+ url: "http://{{ paperlessng_listen_address }}:{{ paperlessng_listen_port }}/api/documents/{{ index }}/"+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ return_content: yes+ register: document+ failed_when: "'Not found.' in document.content or content not in document.json['content']"++ - name: check if deleting uploaded document works+ uri:+ url: "http://{{ paperlessng_listen_address }}:{{ paperlessng_listen_port }}/api/documents/bulk_edit/"+ method: POST+ body_format: json+ body:+ documents: ["{{ index }}"]+ method: delete+ parameters: {}+ headers:+ Authorization: 'Basic {{ (paperlessng_superuser_name + ":" + paperlessng_superuser_password) | b64encode }}'+ register: delete_document+ failed_when: "'OK' not in delete_document.json['result']"diff --git a/ansible/molecule/fresh/converge.yml b/ansible/molecule/fresh/converge.ymldeleted file mode 100644index eec6e6444..000000000--- a/ansible/molecule/fresh/converge.yml+++ /dev/null@@ -1,10 +0,0 @@------ name: fresh installation- hosts: all- tasks:- - name: set github ref as version when available- set_fact:- paperlessng_version: "{{ lookup('env', 'GITHUB_REF') | default('latest', True) }}"- - name: install paperless-ng with default parameters- include_role:- name: ansiblediff --git a/ansible/molecule/fresh/verify.yml b/ansible/molecule/fresh/verify.ymldeleted file mode 100644index c353783ab..000000000--- a/ansible/molecule/fresh/verify.yml+++ /dev/null@@ -1,60 +0,0 @@------ 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/molecule.yml b/ansible/molecule/update/molecule.ymldeleted file mode 100644index 27f37ba63..000000000--- a/ansible/molecule/update/molecule.yml+++ /dev/null@@ -1,35 +0,0 @@-----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/verify.yml b/ansible/molecule/update/verify.ymldeleted file mode 100644index c353783ab..000000000--- a/ansible/molecule/update/verify.yml+++ /dev/null@@ -1,60 +0,0 @@------ 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"