Skip to content

Commit

Permalink
#22 updated molecule tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Fran Tsao committed Jan 3, 2020
1 parent ff63f78 commit 6320273
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 130 deletions.
89 changes: 0 additions & 89 deletions molecule.yml

This file was deleted.

15 changes: 15 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

RUN mkdir -p /usr/share/man/man1

RUN apt-get update && \
apt-get install -y iproute sudo systemd systemd-sysv python python-setuptools ssh cron locales ca-certificates && \
apt-get clean

RUN systemctl mask getty.target
22 changes: 22 additions & 0 deletions molecule/default/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -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]'
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---
prom2teams_user: prom2teams
prom2teams_group: prom2teams
prom2teams_config_folder: /etc/prom2teams
prom2teams_version: 2.4.0
prom2teams_logs_folder: /var/log/prom2teams

prom2teams_required_libs:
- python3
Expand Down
35 changes: 35 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
options:
config-file: .yamllint
platforms:
- name: prom2teams
groups:
- prom2teams
image: ${MOLECULE_DISTRO:-debian:stretch-slim}
privileged: false
capabilities:
- SYS_ADMIN
volumes:
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
tmpfs:
- /run
- /run/lock
command: '/lib/systemd/systemd'
stop_signal: 'RTMIN+3'
provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: default
verifier:
name: goss
lint:
name: yamllint
enabled: false
5 changes: 5 additions & 0 deletions molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Converge
hosts: all
roles:
- role: prom2teams-role
File renamed without changes.
53 changes: 53 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
# This is an example playbook to execute goss tests.
# Tests need distributed to the appropriate ansible host/groups
# prior to execution by `goss validate`.

- name: Verify
hosts: all
become: true
vars:
goss_version: v0.3.7
goss_arch: amd64
goss_sha256sum: 357f5c7f2e7949b412bce44349cd32ab19eb3947255a8ac805f884cc2c
goss_dst: /usr/local/bin/goss
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
goss_test_directory: /tmp
goss_format: documentation

tasks:
- name: Download and install Goss
get_url:
url: "{{ goss_url }}"
dest: "{{ goss_dst }}"
mode: 0755
register: download_goss
until: download_goss is succeeded
retries: 3

- name: Copy Goss tests to remote
template:
src: "{{ item }}"
dest: "{{ goss_test_directory }}/{{ item | basename }}"
with_fileglob:
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_*.yml"

- name: Register test files
shell: "ls {{ goss_test_directory }}/test_*.yml"
register: test_files

- name: Execute Goss tests
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
register: test_results
with_items: "{{ test_files.stdout_lines }}"

- name: Display details about the Goss results
debug:
msg: "{{ item.stdout_lines }}"
with_items: "{{ test_results.results }}"

- name: Fail when tests fail
fail:
msg: "Goss failed to validate"
when: item.rc != 0
with_items: "{{ test_results.results }}"
5 changes: 0 additions & 5 deletions tests/Dockerfile

This file was deleted.

31 changes: 0 additions & 31 deletions tests/goss/verifier.yml

This file was deleted.

5 changes: 0 additions & 5 deletions tests/playbook.yml

This file was deleted.

0 comments on commit 6320273

Please sign in to comment.