ansible-collection-prometheus/roles/pushgateway/molecule/alternative/tests/test_alternative.py
gardar 3b679c9161
fix: skip running testinfra on excluded ansible versions
Signed-off-by: gardar <gardar@users.noreply.github.com>
2024-09-20 19:48:18 +00:00

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