From 2cf2b919e20271fe4cd33c9f2661ed98453ac59b Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 19 Feb 2020 00:25:31 +0000 Subject: [PATCH] Copy molecule tests from next branch Add more tests in follow-up PRs. Fixes #6 --- .yamllint | 11 +++++++++++ molecule/default/Dockerfile.j2 | 14 ++++++++++++++ molecule/default/INSTALL.rst | 22 ++++++++++++++++++++++ molecule/default/molecule.yml | 18 ++++++++++++++++++ molecule/default/playbook.yml | 11 +++++++++++ molecule/default/tests/test_default.py | 18 ++++++++++++++++++ molecule/default/tests/test_default.pyc | Bin 0 -> 1129 bytes 7 files changed, 94 insertions(+) create mode 100644 .yamllint create mode 100644 molecule/default/Dockerfile.j2 create mode 100644 molecule/default/INSTALL.rst create mode 100644 molecule/default/molecule.yml create mode 100644 molecule/default/playbook.yml create mode 100644 molecule/default/tests/test_default.py create mode 100644 molecule/default/tests/test_default.pyc diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..ad0be76 --- /dev/null +++ b/.yamllint @@ -0,0 +1,11 @@ +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable + truthy: disable diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/molecule/default/Dockerfile.j2 @@ -0,0 +1,14 @@ +# Molecule managed + +{% if item.registry is defined %} +FROM {{ item.registry.url }}/{{ item.image }} +{% else %} +FROM {{ item.image }} +{% endif %} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi diff --git a/molecule/default/INSTALL.rst b/molecule/default/INSTALL.rst new file mode 100644 index 0000000..6a44bde --- /dev/null +++ b/molecule/default/INSTALL.rst @@ -0,0 +1,22 @@ +******* +Docker driver installation guide +******* + +Requirements +============ + +* Docker Engine + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ pip install 'molecule[docker]' diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..65faca2 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,18 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: instance + image: centos:7 +provisioner: + name: ansible + lint: + name: ansible-lint +verifier: + name: testinfra + lint: + name: flake8 diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml new file mode 100644 index 0000000..afffe11 --- /dev/null +++ b/molecule/default/playbook.yml @@ -0,0 +1,11 @@ +--- +- name: Converge + hosts: all + vars: + drupal_settings: + - root: /var/www/test + sites: + - name: default + filename: settings.test.php + roles: + - role: opdavies.drupal-settings diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py new file mode 100644 index 0000000..3bf2b01 --- /dev/null +++ b/molecule/default/tests/test_default.py @@ -0,0 +1,18 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + +def test_drupal_site_directory_exists(host): + directory = host.file('/var/www/test/sites/default') + + assert directory.exists + assert directory.is_directory + +def test_drupal_settings_file_exists(host): + file = host.file('/var/www/test/sites/default/settings.test.php') + + assert file.exists + assert file.is_file diff --git a/molecule/default/tests/test_default.pyc b/molecule/default/tests/test_default.pyc new file mode 100644 index 0000000000000000000000000000000000000000..982560deef278f60065e4e1a6ed68d3706ece713 GIT binary patch literal 1129 zcmeHF&2G~`5FXp4c|p4r~MFZ`nV_(k7j@Q9n)<3WUeWdtB4XTJh-NO9++J~A3oR1z!sAG zV4mIqTMhVf3DU97+cwj{Y?5Uh6ZSzFG}xl0RtjCYZk36G<0`@YldusF$vrZLYZOX` zS}X0sDvQ`NPPD4Zwk_S^mKN<{vNjoT#{43Wm0HYWmmZ>7;+AtimF7~>4sb%-c zxR>Yo{y{d8AA6J8K8=ZF7pxTJo{$EqOMAshdhjA-Gga`UD)_CFD3uGs5V>Y1;WE}j zu{qZw6NDf)C}gH%c6D_(w9_y}sn9$@r7stY`!Nk&B;y(X_ji-zFAAG5N_iGn1$N3y z+@=mV%(XqTP2M2Ltdjw6+u!ycd2Oo=Nee(d+_ipFb*Dm6m`*H>7#BR!m6X(dOK=n7 zv~Xcgv3sFg6na$e9@d-J2;p)rw33c!!ZE6^L{qBkSB(vAWw(0%7qu4EiuY`$Qo4!H O?Ui?GKJe-Bc7i{{@JcNJ literal 0 HcmV?d00001