mirror of
https://github.com/shouptech/ansible-role-nextcloud.git
synced 2026-02-03 15:09:42 +00:00
Add tests
This commit is contained in:
parent
275cdc129f
commit
1495bd64a3
3 changed files with 80 additions and 1 deletions
51
.travis.yml
Normal file
51
.travis.yml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
---
|
||||
sudo: required
|
||||
|
||||
env:
|
||||
- distribution: centos
|
||||
version: 7
|
||||
init: /usr/lib/systemd/systemd
|
||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
playbook: test.yml
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
# Pull container
|
||||
- 'sudo docker pull ${distribution}:${version}'
|
||||
# Customize container
|
||||
- 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'
|
||||
|
||||
script:
|
||||
- container_id=$(mktemp)
|
||||
|
||||
# Run container in detached state
|
||||
- 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/ansible-role-nextcloud:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'
|
||||
|
||||
# Ansible syntax check.
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/ansible-role-nextcloud/tests/${playbook} --syntax-check'
|
||||
|
||||
# Ansible role check.
|
||||
- 'sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/ansible-role-nextcloud/tests/${playbook}'
|
||||
|
||||
# Test role idempotence.
|
||||
- >
|
||||
sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/ansible-role-nextcloud/tests/${playbook}
|
||||
| grep -q 'changed=0.*failed=0'
|
||||
&& (echo 'Idempotence test: pass' && exit 0)
|
||||
|| (echo 'Idempotence test: fail' && exit 1)
|
||||
|
||||
|
||||
# Verify that we can see the web frontend
|
||||
- >
|
||||
sudo docker exec "$(cat ${container_id})" curl -s http://127.0.0.1/index.php 2>/dev/null
|
||||
| grep -q 'a safe home for all your data'
|
||||
&& (echo 'Nextcloud test: pass' && exit 0)
|
||||
|| (echo 'Nextcloud test: fail' && exit 1)
|
||||
|
||||
# Clean up
|
||||
- sudo docker stop "$(cat ${container_id})"
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||
28
tests/Dockerfile.centos-7
Normal file
28
tests/Dockerfile.centos-7
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
FROM centos:7
|
||||
|
||||
# Install systemd -- See https://hub.docker.com/_/centos/
|
||||
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
|
||||
RUN yum -y update; yum clean all; \
|
||||
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
|
||||
rm -f /lib/systemd/system/multi-user.target.wants/*; \
|
||||
rm -f /etc/systemd/system/*.wants/*; \
|
||||
rm -f /lib/systemd/system/local-fs.target.wants/*; \
|
||||
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
|
||||
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
|
||||
rm -f /lib/systemd/system/basic.target.wants/*; \
|
||||
rm -f /lib/systemd/system/anaconda.target.wants/*;
|
||||
|
||||
# Install Ansible
|
||||
RUN yum -y install epel-release
|
||||
RUN yum -y install git ansible sudo
|
||||
RUN yum clean all
|
||||
|
||||
# Disable requiretty
|
||||
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
|
||||
|
||||
# Install Ansible inventory file
|
||||
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
|
||||
|
||||
VOLUME ["/sys/fs/cgroup"]
|
||||
CMD ["/usr/sbin/init"]
|
||||
|
|
@ -2,4 +2,4 @@
|
|||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- nextcloud
|
||||
- ansible-role-nextcloud
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue