geekoops-grafana/molecule/default/tests/test_default.py
Felix Niederwanger a6102deb7a
Fix molecule for Leap 15.4
Fix the molecule test for Leap 15.4
2023-01-30 16:38:31 +01:00

35 lines
1.1 KiB
Python
Executable file

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import testinfra.utils.ansible_runner
import os
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_grafana_http(host):
cmd = host.run("curl -v --fail http://127.0.0.1:3000")
assert cmd.succeeded
assert "/login" in cmd.stdout
assert "Found" in cmd.stdout
def test_influxdb(host) :
def run(command) :
cmd = host.run(command)
assert cmd.succeeded
run("influx -version")
run("influx -execute 'CREATE DATABASE apollo13'")
run("influx -database apollo13 -execute 'INSERT thermo,location=space temperature=22 5'")
run("influx -database apollo13 -execute 'INSERT thermo,location=space temperature=23 6'")
cmd = host.run("influx -database apollo13 -execute 'SELECT * FROM thermo;'")
assert cmd.succeeded
lines = cmd.stdout.split("\n")
print(lines)
def assert_line(loc, time, temperature) :
loc, time, temperature = str(loc), str(time), str(temperature)
for line in lines :
if loc in line and time in line and temperature in line : return
assert False
assert_line('space', 5, 22)
assert_line('space', 6, 23)