diff options
| author | Colin Wilk <colin.wilk@tum.de> | 2023-06-03 20:35:14 +0200 |
|---|---|---|
| committer | Colin Wilk <colin.wilk@tum.de> | 2023-06-03 20:35:14 +0200 |
| commit | 7ebb8e16cf9b37898cd167c8e523c7e10fb6891a (patch) | |
| tree | 0bdf5baf038aa901d5fe887531ee49e42dc04702 /molecule/default/tests | |
| parent | 3811c31708a6f3442ba4393d75b19716194a4234 (diff) | |
| download | ansible-role-prometheus-target-7ebb8e16cf9b37898cd167c8e523c7e10fb6891a.tar.gz ansible-role-prometheus-target-7ebb8e16cf9b37898cd167c8e523c7e10fb6891a.zip | |
Add tests for hook functionality and lineinfile parameters
Signed-off-by: Colin Wilk <colin.wilk@tum.de>
Diffstat (limited to 'molecule/default/tests')
| -rw-r--r-- | molecule/default/tests/test_check_prometheus_targets.py | 59 |
1 files changed, 50 insertions, 9 deletions
diff --git a/molecule/default/tests/test_check_prometheus_targets.py b/molecule/default/tests/test_check_prometheus_targets.py index a793478..2a45661 100644 --- a/molecule/default/tests/test_check_prometheus_targets.py +++ b/molecule/default/tests/test_check_prometheus_targets.py @@ -1,16 +1,57 @@ testinfra_hosts = ['prometheus'] - -def test_check_hosts_added(host): - t1 = host.file('/opt/target1.yml') - t2 = host.file('/opt/target2.yml') - t3 = host.file('/opt/target3.yml') +""" +Test functionality of defining exporters and default fallbacks +""" +def test_check_hosts_added_simple(host): + t1 = host.file('/opt/simple_target1.yml') + t2 = host.file('/opt/simple_target2.yml') + t3 = host.file('/opt/simple_target3.yml') assert t1.exists assert t2.exists assert t3.exists - assert ' - application' in t1.content_string - assert ' - test1' in t2.content_string - assert ' - test2' in t2.content_string - assert ' - application_AA' in t3.content_string + assert t1.content_string == \ + ' - application\n' + + + assert t2.content_string == \ + ' - test1\n' \ + ' - test2\n' + + assert t3.content_string == \ + ' - application_AA\n' + + +""" +Test hook functionality +""" +def test_check_hosts_added_hooks(host): + t1 = host.file('/opt/hook_target.yml') + t2 = host.file('/opt/hook1') + t3 = host.file('/opt/hook2') + + assert t1.content_string == \ + ' - application\n' + + assert t2.exists + assert t3.exists + + +""" +Test lineinfile strategy parameters +""" +def test_check_host_added_lineinfile(host): + t1 = host.file('/opt/lineinfile.yml') + + assert t1.user == 'prometheus' + assert t1.group == 'prometheus' + assert t1.mode == 0o600 + + assert t1.content_string == \ + '- labels:\n' \ + ' my: label\n' \ + ' targets:\n' \ + ' - existing:9100\n' \ + ' - application:9100\n' |