forked from Checkmk/checkmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_mkbackup_check.py
188 lines (179 loc) · 4.11 KB
/
test_mkbackup_check.py
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/usr/bin/env python3
# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
import pytest
from cmk.agent_based.v1.type_defs import StringTable
from .checktestlib import Check
pytestmark = pytest.mark.checks
info_1 = [
["[[[site:heute:test]]]"],
["{"],
['"bytes_per_second":', "1578215.4167199447,"],
['"finished":', "1511788263.410466,"],
['"next_schedule":', "1511874660.0,"],
[
'"output":',
'"2017-11-27',
"14:11:02",
"---",
"Starting",
"backup",
"(Check_MK-klappfel-heute-test",
"to",
"testtgt)",
"---\\n2017-11-27",
"14:11:03",
"Verifying",
"backup",
"consistency\\n2017-11-27",
"14:11:03",
"---",
"Backup",
"completed",
"(Duration:",
"0:00:01,",
"Size:",
"1.80",
"MB,",
"IO:",
"1.51",
"MB/s)",
'---\\n",',
],
['"pid":', "20963,"],
['"size":', "1883330,"],
['"started":', "1511788262.20002,"],
['"state":', '"finished",'],
['"success":', "true"],
["}"],
]
info_2 = [
["[[[site:heute:test]]]"],
["{"],
['"bytes_per_second":', "1578215.4167199447,"],
['"finished":', "1511788263.410466,"],
['"next_schedule":', "1511874660.0,"],
[
'"output":',
'"2017-11-27',
"14:11:02",
"---",
"Starting",
"backup",
"(Check_MK-klappfel-heute-test",
"to",
"testtgt)",
"---\\n2017-11-27",
"14:11:03",
"Verifying",
"backup",
"consistency\\n2017-11-27",
"14:11:03",
"---",
"Backup",
"completed",
"(Duration:",
"0:00:01,",
"Size:",
"1.80",
"MB,",
"IO:",
"1.51",
"MB/s)",
'---\\n",',
],
['"pid":', "20963,"],
['"size":', "1883330,"],
['"started":', "1511788262.20002,"],
['"state":', '"finished",'],
['"success":', "true"],
["}"],
["[[[site:heute:test2]]]"],
["{"],
['"bytes_per_second":', "0,"],
['"finished":', "1511788748.77112,"],
['"next_schedule":', "null,"],
[
'"output":',
'"2017-11-27',
"14:19:07",
"---",
"Starting",
"backup",
"(Check_MK-klappfel-heute-test2",
"to",
"testtgt2)",
"---\\n2017-11-27",
"14:19:08",
"Verifying",
"backup",
"consistency\\n2017-11-27",
"14:19:08",
"---",
"Backup",
"completed",
"(Duration:",
"0:00:00,",
"Size:",
"87.07",
"MB,",
"IO:",
"0.00",
"B/s)",
'---\\n",',
],
['"pid":', "24201,"],
['"size":', "91299840,"],
['"started":', "1511788747.898509,"],
['"state":', '"finished",'],
['"success":', "true"],
["}"],
]
info_3 = [
["[[[system:test1]]]"],
["{"],
['"bytes_per_second":', "0,"],
['"finished":', "1474547810.309871,"],
['"next_schedule":', "null,"],
[
'"output":',
'"2016-09-22',
"14:36:50",
"---",
"Starting",
"backup",
"(Check_MK_Appliance-luss028-test1",
"to",
"test1)",
"---\\nFailed",
"to",
"create",
"the",
"backup",
"directory:",
"[Errno",
"13]",
"Permission",
"denied:",
"'/mnt/auto/DIDK7838/Anwendungen/Check_MK_Appliance-luss028-test1-incomplete'\\n\",",
],
['"pid":', "29567,"],
['"started":', "1474547810.30425,"],
['"state":', '"finished",'],
['"success":', "false"],
["}"],
]
# This only tests whether the parse function crashes or not
@pytest.mark.parametrize(
"info",
[
[],
info_1,
info_2,
info_3,
],
)
def test_mkbackup_parse(info: StringTable) -> None:
check = Check("mkbackup")
check.run_parse(info)