Adding molecule unit tests
This commit is contained in:
@@ -4,3 +4,4 @@
|
||||
project_src: "{{ nextcloud_data_dir }}"
|
||||
state: present
|
||||
recreate: always
|
||||
when: not (molecule_test_mode | default(false))
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- ../../../molecule/shared/vars.yml
|
||||
roles:
|
||||
- role: nextcloud
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
options:
|
||||
requirements-file: requirements.yml
|
||||
driver:
|
||||
name: delegated
|
||||
options:
|
||||
managed: false
|
||||
ansible_connection_options:
|
||||
ansible_connection: local
|
||||
platforms:
|
||||
- name: localhost
|
||||
groups:
|
||||
- sovereign
|
||||
provisioner:
|
||||
name: ansible
|
||||
inventory:
|
||||
host_vars:
|
||||
localhost:
|
||||
ansible_connection: local
|
||||
verifier:
|
||||
name: ansible
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
- name: Verify nextcloud role
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
nextcloud_data_dir: /tmp/sovereign_test/nextcloud
|
||||
|
||||
tasks:
|
||||
- name: Check nextcloud data directory exists
|
||||
ansible.builtin.stat:
|
||||
path: /tmp/sovereign_test/nextcloud
|
||||
register: data_dir_stat
|
||||
|
||||
- name: Assert nextcloud data directory is present
|
||||
ansible.builtin.assert:
|
||||
that: data_dir_stat.stat.isdir
|
||||
fail_msg: "Data directory /tmp/sovereign_test/nextcloud was not created"
|
||||
|
||||
- name: Check nextcloud data subdirectory exists
|
||||
ansible.builtin.stat:
|
||||
path: /tmp/sovereign_test/nextcloud/data
|
||||
register: data_subdir_stat
|
||||
|
||||
- name: Assert nextcloud data subdirectory is present
|
||||
ansible.builtin.assert:
|
||||
that: data_subdir_stat.stat.isdir
|
||||
fail_msg: "Directory /tmp/sovereign_test/nextcloud/data was not created"
|
||||
|
||||
- name: Check docker-compose.yml exists
|
||||
ansible.builtin.stat:
|
||||
path: /tmp/sovereign_test/nextcloud/docker-compose.yml
|
||||
register: compose_stat
|
||||
|
||||
- name: Assert docker-compose.yml was rendered
|
||||
ansible.builtin.assert:
|
||||
that: compose_stat.stat.exists
|
||||
fail_msg: "docker-compose.yml was not rendered for nextcloud"
|
||||
|
||||
- name: Read docker-compose.yml
|
||||
ansible.builtin.slurp:
|
||||
src: /tmp/sovereign_test/nextcloud/docker-compose.yml
|
||||
register: compose_raw
|
||||
|
||||
- name: Set compose content fact
|
||||
ansible.builtin.set_fact:
|
||||
compose: "{{ compose_raw.content | b64decode }}"
|
||||
|
||||
- name: Assert nextcloud image reference in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'nextcloud:29' in compose"
|
||||
fail_msg: "Expected image 'nextcloud:29' not found in docker-compose.yml"
|
||||
|
||||
- name: Assert nextcloud host rule in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'Host(`cloud.test.example.com`)' in compose"
|
||||
fail_msg: "Expected Host rule for cloud.test.example.com not found in docker-compose.yml"
|
||||
|
||||
- name: Assert GELF logging address in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'udp://127.0.0.1:12201' in compose"
|
||||
fail_msg: "Expected GELF address udp://127.0.0.1:12201 not found in docker-compose.yml"
|
||||
|
||||
- name: Assert sovereign network is external in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'external: true' in compose"
|
||||
fail_msg: "Expected 'external: true' not found in docker-compose.yml"
|
||||
|
||||
- name: Assert nextcloud db password in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'test_nextcloud_db' in compose"
|
||||
fail_msg: "Expected nextcloud_db_password 'test_nextcloud_db' not found in docker-compose.yml"
|
||||
|
||||
- name: Assert nextcloud S3 secret key in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'test_nextcloud_s3' in compose"
|
||||
fail_msg: "Expected minio_nextcloud_secret_key 'test_nextcloud_s3' not found in docker-compose.yml"
|
||||
@@ -19,6 +19,7 @@
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ nextcloud_data_dir }}"
|
||||
state: present
|
||||
when: not (molecule_test_mode | default(false))
|
||||
|
||||
- name: Wait for Nextcloud to be ready
|
||||
ansible.builtin.command:
|
||||
@@ -28,6 +29,7 @@
|
||||
retries: 30
|
||||
delay: 10
|
||||
changed_when: false
|
||||
when: not (molecule_test_mode | default(false))
|
||||
|
||||
- name: Copy tenant logo into Nextcloud container volume
|
||||
ansible.builtin.copy:
|
||||
@@ -43,9 +45,10 @@
|
||||
- { key: name, value: "{{ tenant_name }}" }
|
||||
- { key: color, value: "{{ tenant_primary_color | default('#2563eb') }}" }
|
||||
changed_when: false
|
||||
when: not (molecule_test_mode | default(false))
|
||||
|
||||
- name: Configure Nextcloud theming — logo
|
||||
ansible.builtin.command:
|
||||
cmd: docker exec -u www-data nextcloud php occ theming:config logo /var/www/html/sovereign-logo.png
|
||||
when: tenant_logo_local_path | default('') != ''
|
||||
when: tenant_logo_local_path | default('') != '' and not (molecule_test_mode | default(false))
|
||||
changed_when: false
|
||||
|
||||
Reference in New Issue
Block a user