Molecule tests for Monitor deployment (#176)

* Monitor deployment testing - initial commit.

* deployment-monitor job

* one job

* Additional tests.

* server port.

* lint

* all jobs
This commit is contained in:
Przemyslaw Rzad 2019-08-02 10:34:53 +02:00 committed by GitHub
parent 40be5a5f8e
commit f3419cbec4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 132 additions and 0 deletions

@ -128,6 +128,13 @@ jobs:
steps:
- checkout
- run: deployment/molecule/molecule.sh ui
deployment-monitor:
machine:
image: circleci/classic:latest
docker_layer_caching: true
steps:
- checkout
- run: deployment/molecule/molecule.sh monitor
ultimate-native-to-erc:
machine:
image: circleci/classic:latest
@ -217,4 +224,5 @@ workflows:
- monitor-e2e
- deployment-oracle
- deployment-ui
- deployment-monitor
- ultimate-native-to-erc

@ -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

@ -0,0 +1,56 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
enabled: True
options:
config-data:
ignore: ../../hosts.yml
platforms:
- name: monitor-host
groups:
- example
children:
- monitor
image: ubuntu:16.04
privileged: true
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
provisioner:
name: ansible
lint:
name: ansible-lint
enabled: True
options:
r: ["bug"]
playbooks:
prepare: ../prepare.yml
converge: ../../site.yml
inventory:
host_vars:
monitor-host:
bridge_repo_branch: $CODEBASE_BRANCH
syslog_server_port: "udp://127.0.0.1:514"
verifier:
name: testinfra
lint:
name: flake8
additional_files_or_dirs:
- ../../tests/*
scenario:
name: monitor
test_sequence:
- lint
- cleanup
- destroy
- dependency
- syntax
- create
- prepare
- converge
- verify
- destroy

@ -0,0 +1,54 @@
import os
import pytest
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('monitor')
@pytest.mark.parametrize("name", [
("monitor_monitor_1")
])
def test_docker_containers(host, name):
container = host.docker(name)
assert container.is_running
@pytest.mark.parametrize("service", [
("tokenbridge-monitor"),
("rsyslog")
])
def test_services(host, service):
assert host.service(service).is_enabled
assert host.service(service).is_running
@pytest.mark.parametrize("filename", [
("/etc/rsyslog.d/33-monitor-docker.conf"),
("/etc/rsyslog.d/38-monitor-remote-logging.conf")
])
def test_logging(host, filename):
assert host.file(filename).exists
assert host.file(filename).mode == 0o0644
def test_home_exists(host):
assert host.run_test(
'curl -s http://localhost:3003 | '
'grep -q -i "home"'
)
def test_foreign_exists(host):
assert host.run_test(
'curl -s http://localhost:3003 | '
'grep -q -i "foreign"'
)
def test_no_error(host):
assert host.run_expect(
[1],
'curl -s http://localhost:3003 | '
'grep -i -q "error"'
)