forked from Checkmk/checkmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_f5_bigip_vserver.py
101 lines (96 loc) · 3 KB
/
test_f5_bigip_vserver.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
#!/usr/bin/env python3
# Copyright (C) 2023 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.
from collections.abc import Mapping, Sequence
import pytest
from .checktestlib import Check
@pytest.mark.parametrize(
"info, item, expected_item_data",
[
(
[
[
"/path/to-1",
"1",
"1",
"The virtual server is available",
"1.2.3.4",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
],
],
"/path/to-1",
{
"connections": [9],
"connections_duration_max": [0.002],
"connections_duration_mean": [0.003],
"connections_duration_min": [0.001],
"connections_rate": [8],
"detail": "The virtual server is available",
"enabled": "1",
"if_in_octets": [6],
"if_in_pkts": [4],
"if_out_octets": [7],
"if_out_pkts": [5],
"ip_address": "-",
"packet_velocity_asic": [10],
"status": "1",
},
),
(
[
[
"/path/to-1",
"1",
"1",
"The virtual server is available",
"\n\x10˂",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
],
],
"/path/to-1",
{
"connections": [9],
"connections_duration_max": [0.002],
"connections_duration_mean": [0.003],
"connections_duration_min": [0.001],
"connections_rate": [8],
"detail": "The virtual server is available",
"enabled": "1",
"if_in_octets": [6],
"if_in_pkts": [4],
"if_out_octets": [7],
"if_out_pkts": [5],
"ip_address": "-",
"packet_velocity_asic": [10],
"status": "1",
},
),
],
)
def test_f5_bigip_vserver_parsing(
info: list[Sequence[str]],
item: str,
expected_item_data: Mapping[str, str | Sequence[float]],
) -> None:
parsed = Check("f5_bigip_vserver").run_parse(info)
assert isinstance(parsed, dict)
assert sorted(parsed[item].items()) == sorted(expected_item_data.items())