Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12740529
test_prometheus.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
test_prometheus.py
View Options
#!/usr/bin/env python3
from
importlib.machinery
import
SourceFileLoader
import
unittest
salt_test_case
=
SourceFileLoader
(
"salt_test_case"
,
"salt_test_case.py"
)
.
load_module
()
prometheus
=
SourceFileLoader
(
"prometheus"
,
"../_modules/prometheus.py"
)
.
load_module
()
class
Testinstance
(
unittest
.
TestCase
,
salt_test_case
.
SaltTestCase
):
def
setUp
(
self
):
self
.
initialize_mocks
()
self
.
instance
=
prometheus
self
.
mock_pillar
(
"data/prometheus.yaml"
)
self
.
mock_salt
()
self
.
mock_salt_pillar_get
()
def
test_resolve_service
(
self
):
service
=
{
"service"
:
"green"
,
"port"
:
"9090"
,
}
self
.
assertEqual
(
"emerald:9090"
,
prometheus
.
_resolve_service
(
service
))
def
test_resolve_service_list
(
self
):
service
=
{
"service"
:
"blue:all"
,
"port"
:
"9090"
,
}
expected
=
[
"cyan:9090"
,
"turquoise:9090"
,
"ultramarine:9090"
,
]
self
.
assertEqual
(
expected
,
prometheus
.
_resolve_service_list
(
service
))
def
test_get_scrape_configs
(
self
):
expected
=
self
.
import_data_from_yaml
(
"data/prometheus_scrape_configs.yml"
)
actual
=
prometheus
.
get_scrape_configs
()
self
.
assertEqual
(
expected
,
actual
)
if
__name__
==
"__main__"
:
unittest
.
main
()
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Sun, Nov 16, 13:01 (4 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3156444
Default Alt Text
test_prometheus.py (1 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment