Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ibm_i integration produces CRITICAL service check if it cannot connect #13114

Merged
merged 5 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions ibm_i/datadog_checks/ibm_i/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ def check(self, _):
try:
self.query_manager.execute()
check_status = AgentCheck.OK
hostname = self._query_manager.hostname
except AttributeError as e:
self.warning('Could not set up query manager, skipping check run: %s', e)
check_status = None
check_status = AgentCheck.CRITICAL
hostname = self.config.hostname if self.config else None
except Exception as e:
self._delete_connection_subprocess(e)
check_status = AgentCheck.CRITICAL
hostname = self.config.hostname if self.config else None

# At least one query failed, set the service check as failing
if self._current_errors:
Expand All @@ -52,8 +55,8 @@ def check(self, _):
self.service_check(
self.SERVICE_CHECK_NAME,
check_status,
tags=self.config.tags,
hostname=self._query_manager.hostname,
tags=self.config.tags if self.config else None,
iliakur marked this conversation as resolved.
Show resolved Hide resolved
hostname=hostname,
)

def cancel(self):
Expand Down
2 changes: 1 addition & 1 deletion ibm_i/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@pytest.fixture(scope='session')
def dd_environment():
yield
yield {'tags': ['foo:bar']}


@pytest.fixture
Expand Down
9 changes: 9 additions & 0 deletions ibm_i/tests/test_e2e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest

from datadog_checks.ibm_i import IbmICheck


@pytest.mark.e2e
def test_e2e(dd_agent_check, aggregator, instance):
aggregator = dd_agent_check(instance)
aggregator.assert_service_check("ibm_i.can_connect", IbmICheck.CRITICAL)
fanny-jiang marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions ibm_i/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ envlist =

[testenv]
dd_check_style = true
description=
py38: e2e ready
usedevelop = true
platform = linux|darwin|win32
extras = deps
Expand Down