mirror of
https://github.com/prometheus-community/ansible
synced 2025-02-17 05:08:28 +00:00
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
from __future__ import (absolute_import, division, print_function)
|
|
__metaclass__ = type
|
|
|
|
from testinfra_helpers import get_target_hosts
|
|
import pytest
|
|
|
|
testinfra_hosts = get_target_hosts()
|
|
|
|
|
|
def test_directories(host):
|
|
dirs = [
|
|
"/etc/pushgateway"
|
|
]
|
|
for dir in dirs:
|
|
d = host.file(dir)
|
|
assert d.is_directory
|
|
assert d.exists
|
|
|
|
|
|
def test_service(host):
|
|
s = host.service("pushgateway")
|
|
try:
|
|
assert s.is_running
|
|
except AssertionError:
|
|
# Capture service logs
|
|
journal_output = host.run('journalctl -u pushgateway --since "1 hour ago"')
|
|
print("\n==== journalctl -u pushgateway Output ====\n")
|
|
print(journal_output)
|
|
print("\n============================================\n")
|
|
raise # Re-raise the original assertion error
|
|
|
|
|
|
def test_protecthome_property(host):
|
|
s = host.service("pushgateway")
|
|
p = s.systemd_properties
|
|
assert p.get("ProtectHome") == "yes"
|
|
|
|
|
|
@pytest.mark.parametrize("sockets", [
|
|
"tcp://127.0.0.1:8080",
|
|
"tcp://127.0.1.1:8080",
|
|
])
|
|
def test_socket(host, sockets):
|
|
assert host.socket(sockets).is_listening
|