Skip to content

Commit 52e2c73

Browse files
committed
move exception to test to unit tests
1 parent d98f972 commit 52e2c73

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

teleport/datadog_checks/teleport/check.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,5 @@ def check(self, _):
3333

3434
def _parse_config(self):
3535
if self.diagnostic_url:
36-
self.instance.setdefault("openmetrics_endpoint", self.diagnostic_url+"/metrics")
37-
38-
# if diagnostic_url:
39-
# # We create another config to scrape Gitaly metrics, so we have two different scrapers:
40-
# # one for the main GitLab and another one for the Gitaly endpoint.
41-
# config = copy.deepcopy(self.instance)
42-
# config['openmetrics_endpoint'] = diagnostic_url + "/metrics"
43-
# config['namespace'] = 'teleport'
44-
# self.scraper_configs.append(config)
36+
self.instance.setdefault("openmetrics_endpoint", self.diagnostic_url + "/metrics")
37+
self.instance.setdefault("metrics", ["process_state"])

teleport/tests/test_integration.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99

1010
pytestmark = [pytest.mark.integration, pytest.mark.usefixtures('dd_environment')]
1111

12-
def test_connect_exception(aggregator, dd_run_check):
13-
instance = {"diagnostic_url": "https://wrong_endpoint/metrics"}
14-
check = TeleportCheck('teleport', {}, [instance])
15-
dd_run_check(check)
16-
aggregator.assert_service_check('teleport.health.up', status=AgentCheck.CRITICAL)
1712

1813
def test_connect_ok(aggregator, dd_run_check):
1914
instance = {"diagnostic_url": "http://127.0.0.1:3000"}
@@ -22,6 +17,7 @@ def test_connect_ok(aggregator, dd_run_check):
2217
aggregator.assert_service_check('teleport.health.up', status=AgentCheck.OK, count=1)
2318
aggregator.assert_service_check('teleport.health.up', status=AgentCheck.CRITICAL, count=0)
2419

20+
2521
def test_check_collects_teleport_common_metrics(aggregator, dd_run_check):
2622
instance = {"diagnostic_url": "http://127.0.0.1:3000"}
2723
check = TeleportCheck('teleport', {}, [instance])
@@ -39,4 +35,4 @@ def test_check_collects_teleport_common_metrics(aggregator, dd_run_check):
3935
]
4036

4137
for metric in common_metrics:
42-
aggregator.assert_metric(f"teleport.{metric}", tags=None, count=1)
38+
aggregator.assert_metric(f"teleport.{metric}", tags=None, count=1)

teleport/tests/test_unit.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# (C) Datadog, Inc. 2024-present
2+
# All rights reserved
3+
# Licensed under a 3-clause BSD style license (see LICENSE)
4+
5+
import pytest
6+
7+
from datadog_checks.teleport import TeleportCheck
8+
9+
pytestmark = [pytest.mark.unit]
10+
11+
12+
def test_connect_exception(dd_run_check):
13+
instance = {}
14+
check = TeleportCheck('teleport', {}, [instance])
15+
with pytest.raises(Exception):
16+
dd_run_check(check)

0 commit comments

Comments
 (0)