blob: 9ce10561435fea7374267302a7593f390f5f16be (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
testinfra_hosts = ['prometheus']
"""
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 t1.content_string == \
' - application\n'
assert t2.content_string == \
' - test1\n' \
' - test2\n'
assert t3.content_string == \
' - application_AA\n'
"""
Test prefix functionality
"""
def test_check_hosts_added_prefix(host):
t1 = host.file('/opt/prefix_target1.yml')
t2 = host.file('/opt/prefix_target2.yml')
t3 = host.file('/opt/prefix/prefix_target3.yml')
assert t1.exists
assert t2.exists
assert t3.exists
assert t1.content_string == \
' - application\n'
assert t2.content_string == \
' - application\n'
assert t3.content_string == \
' - application\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'
|