mirror of
https://github.com/GeekOops/geekoops-grafana.git
synced 2024-05-19 20:12:23 +00:00
Merge branch 'main' of github.com:GeekOops/geekoops-grafana
This commit is contained in:
commit
9c8a29d095
42
.github/workflows/CI.yml
vendored
Normal file
42
.github/workflows/CI.yml
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
---
|
||||||
|
name: Test deployment
|
||||||
|
'on':
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
schedule:
|
||||||
|
# Run every Wednesday at 01:42
|
||||||
|
- cron: "42 1 * * 3"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out codebase
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pip3 install yamllint
|
||||||
|
- name: Lint repository
|
||||||
|
run: yamllint .
|
||||||
|
|
||||||
|
molecule:
|
||||||
|
name: Molecule
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out the codebase
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pip3 install ansible molecule[docker] docker pytest testinfra influxdb
|
||||||
|
- name: Run Molecule
|
||||||
|
run: molecule test
|
||||||
|
env:
|
||||||
|
PY_COLORS: '1'
|
||||||
|
ANSIBLE_FORCE_COLOR: '1'
|
7
molecule/default/converge.yml
Normal file
7
molecule/default/converge.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: "Include geekoops-grafana"
|
||||||
|
include_role:
|
||||||
|
name: "geekoops-grafana"
|
31
molecule/default/molecule.yml
Normal file
31
molecule/default/molecule.yml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
platforms:
|
||||||
|
- name: leap15_2
|
||||||
|
image: grisu48/leap-ansible
|
||||||
|
pre_build_image: true
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
capabilities:
|
||||||
|
- SYS_ADMIN
|
||||||
|
privileged: true
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /tmp
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
inventory:
|
||||||
|
host_vars:
|
||||||
|
leap15_2:
|
||||||
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
|
influxdb: true
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
lint:
|
||||||
|
name: flake8
|
||||||
|
lint: |
|
||||||
|
set -e
|
||||||
|
yamllint .
|
34
molecule/default/tests/test_default.py
Executable file
34
molecule/default/tests/test_default.py
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/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 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)
|
|
@ -6,7 +6,7 @@
|
||||||
state: present
|
state: present
|
||||||
tags: ['grafana']
|
tags: ['grafana']
|
||||||
|
|
||||||
- name: Ensure grafana is started
|
- name: Ensure grafana is started and enabled
|
||||||
systemd:
|
systemd:
|
||||||
name: grafana-server
|
name: grafana-server
|
||||||
state: started
|
state: started
|
||||||
|
|
Loading…
Reference in a new issue