-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathtest_metrics.py
More file actions
139 lines (118 loc) · 3.35 KB
/
test_metrics.py
File metadata and controls
139 lines (118 loc) · 3.35 KB
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
import pytest
from linodecli.exit_codes import ExitCodes
from tests.integration.helpers import (
BASE_CMDS,
assert_headers_in_lines,
exec_failing_test_command,
exec_test_command,
)
def test_dashboard_list():
res = exec_test_command(
BASE_CMDS["monitor"]
+ ["dashboards-list-all", "--text", "--delimiter=,"]
)
lines = res.splitlines()
headers = ["created", "id", "label", "service_type", "type", "updated"]
assert_headers_in_lines(headers, lines)
@pytest.fixture
def get_dashboard_id():
dashboard_ids = exec_test_command(
BASE_CMDS["monitor"]
+ [
"dashboards-list-all",
"--text",
"--no-headers",
"--delimiter",
",",
"--format",
"id",
]
).splitlines()
first_id = dashboard_ids[0].split(",")[0]
yield first_id
def test_dashboard_view(get_dashboard_id):
dashboard_id = get_dashboard_id
res = exec_test_command(
BASE_CMDS["monitor"]
+ [
"dashboards-view",
dashboard_id,
"--text",
"--delimiter=,",
]
)
lines = res.splitlines()
headers = ["created", "id", "label", "service_type", "type", "updated"]
assert_headers_in_lines(headers, lines)
def test_service_list():
res = exec_test_command(
BASE_CMDS["monitor"] + ["service-list", "--text", "--delimiter=,"]
)
lines = res.splitlines()
headers = ["label", "service_type"]
assert_headers_in_lines(headers, lines)
def test_service_view(get_service_type):
service_type = get_service_type
res = exec_test_command(
BASE_CMDS["monitor"]
+ [
"service-view",
service_type,
"--text",
"--delimiter=,",
]
)
lines = res.splitlines()
headers = ["label", "service_type"]
assert_headers_in_lines(headers, lines)
def test_dashboard_service_type_list(get_service_type):
service_type = get_service_type
res = exec_test_command(
BASE_CMDS["monitor"]
+ [
"dashboards-list",
service_type,
"--text",
"--delimiter=,",
]
)
lines = res.splitlines()
headers = ["created", "id", "label", "service_type", "type", "updated"]
assert_headers_in_lines(headers, lines)
def test_metrics_list(get_service_type):
service_type = get_service_type
res = exec_test_command(
BASE_CMDS["monitor"]
+ [
"metrics-list",
service_type,
"--text",
"--delimiter=,",
]
)
lines = res.splitlines()
headers = [
"available_aggregate_functions",
"is_alertable",
"label",
"metric",
"metric_type",
"scrape_interval",
]
assert_headers_in_lines(headers, lines)
def test_try_create_token_with_not_existing_entity(get_service_type):
service_type = get_service_type
output = exec_failing_test_command(
BASE_CMDS["monitor"]
+ [
"token-get",
service_type,
"--entity_ids",
"99999999999",
"--text",
"--delimiter=,",
],
expected_code=ExitCodes.REQUEST_FAILED,
)
assert "Request failed: 403" in output
assert "The following entity_ids are not valid - [99999999999]" in output