mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-22 03:43:09 +00:00
molecule support
Signed-off-by: Stan Rudenko <stan@truera.com>
This commit is contained in:
parent
50a4c1da4c
commit
83eee4cd08
4 changed files with 57 additions and 0 deletions
8
roles/prometheus/molecule/agentmode/converge.yml
Normal file
8
roles/prometheus/molecule/agentmode/converge.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.prometheus
|
||||
vars:
|
||||
prometheus_agent_mode: true
|
1
roles/prometheus/molecule/agentmode/molecule.yml
Normal file
1
roles/prometheus/molecule/agentmode/molecule.yml
Normal file
|
@ -0,0 +1 @@
|
|||
---
|
44
roles/prometheus/molecule/agentmode/tests/test_default.py
Normal file
44
roles/prometheus/molecule/agentmode/tests/test_default.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import yaml
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def AnsibleDefaults():
|
||||
with open("defaults/main.yml", 'r') as stream:
|
||||
return yaml.full_load(stream)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('file, content', [
|
||||
("/etc/systemd/system/prometheus.service",
|
||||
"storage.agent.path=/var/lib/prometheus"),
|
||||
("/etc/systemd/system/prometheus.service",
|
||||
"enable-feature=agent"),
|
||||
])
|
||||
def test_file_contents(host, file, content):
|
||||
f = host.file(file)
|
||||
assert f.exists
|
||||
assert f.is_file
|
||||
assert f.contains(content)
|
||||
|
||||
|
||||
def test_service(host):
|
||||
s = host.service("prometheus")
|
||||
assert s.is_running
|
||||
|
||||
|
||||
# # "/agent" page is available (http 200) when agent mode is enabled
|
||||
def test_agent_enabled(host):
|
||||
output = host.check_output('curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:9090/agent')
|
||||
assert '200' in output
|
||||
|
||||
def test_socket(host):
|
||||
s = host.socket("tcp://0.0.0.0:9090")
|
||||
assert s.is_listening
|
4
tests/integration/targets/molecule-prometheus-agentmode/runme.sh
Executable file
4
tests/integration/targets/molecule-prometheus-agentmode/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
Loading…
Reference in a new issue