Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

add alternative tests #65

Merged
merged 1 commit into from
Dec 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions molecule/alternative/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: bionic
image: paulfantom/ubuntu-molecule:18.04
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: xenial
image: paulfantom/ubuntu-molecule:16.04
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: stretch
image: paulfantom/debian-molecule:9
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: jessie
image: paulfantom/debian-molecule:8
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: centos7
image: paulfantom/centos-molecule:7
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: fedora
image: paulfantom/fedora-molecule:27
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
create: ../default/create.yml
prepare: ../default/prepare.yml
converge: playbook.yml
destroy: ../default/destroy.yml
scenario:
name: alternative
verifier:
name: testinfra
lint:
name: flake8
enabled: true
10 changes: 10 additions & 0 deletions molecule/alternative/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Run role
hosts: all
any_errors_fatal: true
roles:
- ansible-node-exporter
vars:
node_exporter_textfile_dir: ""
node_exporter_enabled_collectors:
- systemd
29 changes: 29 additions & 0 deletions molecule/alternative/tests/test_alternative.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os
import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_directories(host):
dirs = [
"/var/lib/node_exporter"
]
for dir in dirs:
d = host.file(dir)
assert not d.exists


def test_service(host):
s = host.service("node_exporter")
# assert s.is_enabled
assert s.is_running


def test_socket(host):
sockets = [
"tcp://127.0.0.1:9100"
]
for socket in sockets:
s = host.socket(socket)
assert s.is_listening